Sophie

Sophie

distrib > Fedora > 17 > i386 > media > updates-src > by-pkgid > 7d3ce03a027e3d03d8dbca7a117b4ee9 > files > 6

hercules-3.08.2-1.fc17.src.rpm

#!/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
ip_forward=`sysctl -n net.ipv4.ip_forward`
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 $@

# Remove the firewall rules
iptables -D FORWARD -i eth0 -o tun0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -D POSTROUTING -s ${HERCNET} -j MASQUERADE

# Set value of ip_forward back
sysctl -w net.ipv4.ip_forward=$ip_forward >/dev/null