2007-08-14 18:43:56 +02:00
|
|
|
{ifplugd, config, writeScript, bash}:
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
# The ifplugd action script, which is called whenever the link
|
|
|
|
# status changes (i.e., a cable is plugged in or unplugged). We do
|
|
|
|
# nothing when a cable is unplugged. When a cable is plugged in, we
|
|
|
|
# restart dhclient, which will hopefully give us a new IP address
|
|
|
|
# if appropriate.
|
|
|
|
plugScript = writeScript "ifplugd.action" "#! ${bash}/bin/sh
|
|
|
|
if test \"$2\" = up; then
|
|
|
|
initctl stop dhclient
|
2007-08-15 14:01:20 +02:00
|
|
|
sleep 1
|
2007-08-14 18:43:56 +02:00
|
|
|
initctl start dhclient
|
|
|
|
fi
|
|
|
|
";
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
name = "ifplugd";
|
|
|
|
|
|
|
|
extraPath = [ifplugd];
|
|
|
|
|
|
|
|
job = "
|
|
|
|
description \"Network interface connectivity monitor\"
|
|
|
|
|
|
|
|
start on network-interfaces/started
|
|
|
|
stop on network-interfaces/stop
|
|
|
|
|
|
|
|
respawn ${ifplugd}/sbin/ifplugd --no-daemon --no-startup --no-shutdown \\
|
2007-11-09 19:49:45 +01:00
|
|
|
${if config.networking.interfaceMonitor.beep then "" else "--no-beep"} \\
|
2007-08-14 18:43:56 +02:00
|
|
|
--run ${plugScript}";
|
|
|
|
|
|
|
|
}
|