2006-06-09 10:55:24 by steve
Added.
This commit is contained in:
parent
ea58622fea
commit
2ca809eba4
98
hooks/centos4/40-setup-networking
Executable file
98
hooks/centos4/40-setup-networking
Executable file
@ -0,0 +1,98 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# This script sets up the /etc/network/interface file for the new
|
||||
# image.
|
||||
#
|
||||
# Steve
|
||||
# --
|
||||
# http://www.steve.org.uk/
|
||||
|
||||
|
||||
prefix=$1
|
||||
|
||||
|
||||
#
|
||||
# Source our common functions
|
||||
#
|
||||
if [ -e ../common.sh ]; then
|
||||
. ../common.sh
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# Log our start
|
||||
#
|
||||
logMessage Script $0 starting
|
||||
|
||||
|
||||
#
|
||||
# Make sure we have an /etc/sysconfig/network-scripts directory.
|
||||
#
|
||||
mkdir -p ${prefix}/etc/sysconfig/network-scripts/
|
||||
|
||||
|
||||
#
|
||||
# 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`
|
||||
|
||||
logMessage Adding etho:${interface}
|
||||
|
||||
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
|
||||
|
||||
|
||||
#
|
||||
# Log our finish
|
||||
#
|
||||
logMessage Script $0 finished
|
||||
@ -98,6 +98,8 @@ E_O_STATIC
|
||||
value=\$ip${count}
|
||||
value=`eval echo $value`
|
||||
|
||||
logMessage Adding etho:${interface}
|
||||
|
||||
cat <<E_O_STATIC >>${prefix}/etc/network/interfaces
|
||||
auto eth0:${interface}
|
||||
iface eth0:${interface} inet static
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user