diff --git a/configuration/etc.nix b/configuration/etc.nix index be3bcf7b980b..cddae796a9b1 100644 --- a/configuration/etc.nix +++ b/configuration/etc.nix @@ -52,6 +52,13 @@ import ../helpers/make-etc.nix { target = "default/passwd"; } + { # Dhclient hooks for emitting ip-up/ip-down events. + source = pkgs.substituteAll { + src = ./etc/dhclient-exit-hooks; + inherit (pkgs) upstart; + }; + target = "dhclient-exit-hooks"; + } ] # A bunch of PAM configuration files for various programs. diff --git a/configuration/etc/dhclient-exit-hooks b/configuration/etc/dhclient-exit-hooks new file mode 100644 index 000000000000..50463edb4c94 --- /dev/null +++ b/configuration/etc/dhclient-exit-hooks @@ -0,0 +1,10 @@ +echo "$reason" >> /tmp/dhcp-exit +echo "$exit_status" >> /tmp/dhcp-exit + +if test "$reason" = BOUND -o "$reason" = REBOOT; then + @upstart@/sbin/initctl emit ip-up +fi + +if test "$reason" = EXPIRE -o "$reason" = RELEASE; then + @upstart@/sbin/initctl emit ip-down +fi diff --git a/upstart-jobs/ntpd.nix b/upstart-jobs/ntpd.nix index a8c90c31fd09..3f1d12b3c044 100644 --- a/upstart-jobs/ntpd.nix +++ b/upstart-jobs/ntpd.nix @@ -20,8 +20,9 @@ in job = " description \"NTP daemon\" -start on network-interfaces/started -stop on network-interfaces/stop +start on ip-up +stop on ip-down +stop on shutdown start script @@ -34,12 +35,12 @@ start script chown ${ntpUser} ${stateDir} date - ${ntp}/bin/ntpd -ddd -c ${config} -q -g + ${ntp}/bin/ntpd -c ${config} -q -g date end script -respawn ${ntp}/bin/ntpd -ddd -n -c ${config} +respawn ${ntp}/bin/ntpd -n -c ${config} "; }