
34 5. Debian and other Software Packages
if [ −z "$DHCP" ]; then
ADDRESS=‘grep "address" ${IFACE} | awk ’{print $2}’‘
NETMASK=‘grep "netmask" ${IFACE} | awk ’{print $2}’‘
BROADCAST=‘grep "broadcast" ${IFACE} | awk ’{print $2}’‘
GATEWAY=‘grep "gateway" ${IFACE} | awk ’{print $2}’‘
ifconfig ${INTERFACE} ${ADDRESS} netmask ${NETMASK} broadcast ${BROADCAST} up
ping −r −c 1 ${GATEWAY} &> /dev/null
SUCCESS=$?
ifconfig "${INTERFACE}" down
if [ "${SUCCESS}" = 0 ]; then
echo $s
exit
fi
fi
done
#−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
#Try to bring up the interface using DHCP (somewhat ugly since the DHCLIENT
#does not exit on failures but brings up the interface anyway, blech . . .)
for s in ${SCHEME}; do
IFACE=${SCHEME_DIR}/$s
DHCP=‘grep "dhcp" $IFACE‘
if [ −n "$DHCP" ]; then
/sbin/dhclient−2.2.x −e ${INTERFACE} > /tmp/DHCLIENT.log
SUCCESS=‘grep "DHCPACK" /tmp/DHCLIENT.log‘
kill ‘pidof dhclient−2.2.x‘
ifconfig "${INTERFACE}" down
rm −f /tmp/DHCLIENT.log
if [ −n "${SUCCESS}" ]; then
echo $s
exit
fi
fi
done
echo "@NO−RESPONSES@"
exit 0
Note: Weredefine the layout of the IP-to-SCHEME map file /etc/laptop-net/ip-map. Each line in this file con-
tains nowtwo entries: first the name of the scheme, and second the expected IP number under this scheme. If the
network interface is configured via DHCP,only the name of the scheme is collected. In this case, the second en-
try with the IP number is not necessary.
Note also: Weonly need one single scheme for DHCP evenifweuse this for more than one network. That’s
what the different profiles are for.
/etc/laptop-net/ip-map:
#schemes for different static IP addresses
scheme1 www.xxx.yyy.zzz =our expected IP address under scheme1
scheme2 WWW.XXX.YYY.ZZZ =our expected IP address under scheme2
#one single scheme for DHCP
scheme3 no IP number necessary
We also want to transfer the “control” of all network related boot scripts from the boot process rcS to the Laptop-
Net daemon ifd — without confusing the Debian package management system, of course. Todoso, we have to
remove the symlinks from the /etc/rcN.d directories and install them in the /etc/laptop-net/profiles/XXXX/rc.d,
where XXXX is one of home, work or local. Since the Debian boot-script manager update-rc.d will reinstall
these links as long as it find the corresponding script in /etc/init.d, we have todiv ert these to a different location.
Diverting the boot script from init to ifd:
#!/bin/sh
mkdir /etc/laptop−net/init.d
PACKAGES="dns−clean fetchmail ippl lprng ntp ntpdate ppp scandetd ssh xinetd"
for p in $PACKAGES; do
dpkg−divert −−rename −−divert /etc/laptop−net/init.d/$p /etc/init.d/$p
update−rc.d $p remove
done
Commentaires sur ces manuels