#!/bin/sh
### Startup script for the Hercules S/390 emulator
### Copyright (C) 2001 Karsten Hopp <karsten@redhat.de>
### Copyright (C) 2003 Florian La Roche <laroche@redhat.com>
# This is your "hercules network" between your machine running the
# hercules emulator and the Linux guest running in hercules.
HERCNET="192.168.200.0/24"
PATH=/sbin:/usr/sbin:/bin:/usr/bin
export PATH
unset LANG LC_COLLATE
if [ `id -u` != 0 ]; then
echo "This script requires root permissions."
exit 1
fi
# This device must be present for hercules to setup networking.
[ -d /dev/net ] || mkdir -p /dev/net
[ -c /dev/net/tun ] || mknod /dev/net/tun c 10 200
# Load the necessary kernel modules:
for module in tun ip_tables iptable_filter ip_conntrack_ftp ip_nat_ftp; do
modprobe ${module} &>/dev/null
done
# Enable IP forwarding
sysctl -w net.ipv4.ip_forward=1 >/dev/null
# Masquerade the hercules network.
iptables -t nat -A POSTROUTING -s ${HERCNET} -j MASQUERADE
iptables -A FORWARD -i eth0 -o tun0 -m state --state ESTABLISHED,RELATED -j ACCEPT
# Start hercules itself.
cd /etc/hercules
hercules