2006-06-09 10:30:37 by steve
Added to the repository. These are almost straight copies of the previous hook scripts except they are now Debian-specific. They also each log their start and finish and optional information via the use of the ../common.sh file. No major changes anticipated.
This commit is contained in:
132
hooks/debian/40-setup-networking
Executable file
132
hooks/debian/40-setup-networking
Executable file
@@ -0,0 +1,132 @@
|
||||
#!/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/network directory.
|
||||
#
|
||||
mkdir -p ${prefix}/etc/network
|
||||
|
||||
|
||||
#
|
||||
# A function to setup DHCP for our new image.
|
||||
#
|
||||
function setupDynamicNetworking
|
||||
{
|
||||
#
|
||||
# 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
|
||||
}
|
||||
|
||||
|
||||
|
||||
#
|
||||
# A function to setup static IP addresses for our new image.
|
||||
#
|
||||
function setupStaticNetworking
|
||||
{
|
||||
#
|
||||
# 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
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Call the relevant function
|
||||
#
|
||||
if [[ -z "${dhcp}" ]]; then
|
||||
logMessage "Setting up static networking"
|
||||
setupStaticNetworking
|
||||
|
||||
else
|
||||
logMessage "Setting up DHCP networking"
|
||||
setupDynamicNetworking
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# Log our finish
|
||||
#
|
||||
logMessage Script $0 finished
|
||||
Reference in New Issue
Block a user