1
0
mirror of synced 2026-02-10 09:39:57 +00:00
Files
xen-tools.xen-tools/etc/hook.d/40-setup-networking
steve ac56e57798 2006-06-07 09:09:30 by steve
Allow multiple IP addresses to be specified.  The first is the default IP.
2006-06-07 09:09:31 +00:00

185 lines
3.2 KiB
Bash
Executable File

#!/bin/sh
#
# This script sets up the /etc/network/interface file for the new
# image.
#
# Steve
# --
# http://www.steve.org.uk/
prefix=$1
dist=$2
#
# Sets up the networking installation for Debian GNU/Linux.
#
function setupDebian
{
if [[ -z "${dhcp}" ]]; then
#
# We have a static IP address
#
cat <<E_O_STATIC >${prefix}/etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address ${ip1}
gateway ${gateway}
netmask ${netmask}
# post-up ethtool -K eth0 tx off
#
# The commented out line above will disable TCP checksumming which
# might resolve problems for some users. It is disabled by default
#
E_O_STATIC
interface=1
count=2
while [ "${count}" -le "${ip_count}" ]; do
value=\$ip${count}
value=`eval echo $value`
cat <<E_O_STATIC >>${prefix}/etc/network/interfaces
auto eth0:${interface}
iface eth0:${interface} inet static
address ${value}
netmask ${netmask}
# post-up ethtool -K eth0 tx off
E_O_STATIC
count=`expr $count + 1`
interface=`expr $interface + 1`
done
else
#
# The host is using DHCP.
#
cat <<E_O_DHCP > ${prefix}/etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet dhcp
# post-up ethtool -K eth0 tx off
#
# The commented out line above will disable TCP checksumming which
# might resolve problems for some users. It is disabled by default
#
E_O_DHCP
fi
}
#
# Setup networking for CentOS4
#
function setupCentOS4
{
#
# Test for static vs. DHCP
#
if [[ -z "${dhcp}" ]]; then
#
# Setup the initial interface
#
cat <<E_O_STATIC >${prefix}/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=${ip1}
NETMASK=${netmask}
GATEWAY=${gateway}
E_O_STATIC
#
# Now setup any other ones.
#
interface=1
count=2
while [ "${count}" -le "${ip_count}" ]; do
value=\$ip${count}
value=`eval echo $value`
cat <<E_O_STATIC >${prefix}/etc/sysconfig/network-scripts/ifcfg-eth0:${interface}
DEVICE=eth0:${interface}
ONBOOT=yes
BOOTPROTO=static
IPADDR=${value}
NETMASK=${netmask}
E_O_STATIC
count=`expr $count + 1`
interface=`expr $interface + 1`
done
else
cat <<E_O_DHCP >${prefix}/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
E_O_DHCP
fi
#
# Don't forget to setup the default route.
#
cat <<EOF >${prefix}/etc/sysconfig/network
NETWORKING=yes
GATEWAY=${gateway}
HOSTNAME=${hostname}
EOF
}
#
# Entry point to the script.
#
case "${dist}" in
sarge|etch|sid)
mkdir -p ${prefix}/etc/network
setupDebian
;;
centos4)
mkdir -p ${prefix}/etc/sysconfig/network-scripts/
setupCentOS4
;;
*)
echo "Unknown distribution '${dist}'. Fixme";
exit;
;;
esac