| #!/bin/sh |
| # |
| # Run dhclient, the system DHCP client, with the appropriate parameters for |
| # SpaceCast. |
| iface=$1 |
| |
| lock=/var/run/dhclient.$iface.lock |
| lockfile-create --use-pid $lock |
| |
| run_dhclient() { |
| local suffix="$1" xargs="$2" |
| local pidfile="/var/run/dhclient$suffix.$iface.pid" |
| local leasefile="/var/run/dhclient$suffix.$iface.lease" |
| local conffile="/etc/dhclient$suffix.conf" |
| |
| if [ -e "$pidfile" ]; then |
| # kill sends TERM which should make the babysitter exit gracefully. |
| kill $(cat "$pidfile") >/dev/null 2>&1 |
| rm -f "$pidfile" |
| fi |
| babysit 60 dhclient "$iface" $xargs \ |
| -d \ |
| -pf "$pidfile" \ |
| -lf "$leasefile" \ |
| -cf "$conffile" \ |
| 2>&1 | logos "dhclient$suffix.$iface" & |
| } |
| |
| run_dhclient "" "" |
| |
| # -N -P means to request a delegated prefix AND get a address. |
| # -S means runs stateless config, requests only the extra information. |
| # On the network box we only run the stateful version, running both |
| # interfere with each other. |
| run_dhclient "6" "-N -P -6 --never-gonna-give-you-up 900" |
| |
| lockfile-remove $lock |