Convert "ifplugd" (interfaceMonitor)
svn path=/nixos/branches/fix-style/; revision=14408
This commit is contained in:
parent
8cad533a76
commit
321763dd84
@ -245,29 +245,6 @@ in
|
|||||||
";
|
";
|
||||||
};
|
};
|
||||||
|
|
||||||
interfaceMonitor = {
|
|
||||||
|
|
||||||
enable = mkOption {
|
|
||||||
default = false;
|
|
||||||
description = "
|
|
||||||
If <literal>true</literal>, monitor Ethernet interfaces for
|
|
||||||
cables being plugged in or unplugged. When this occurs, the
|
|
||||||
<command>dhclient</command> service is restarted to
|
|
||||||
automatically obtain a new IP address. This is useful for
|
|
||||||
roaming users (laptops).
|
|
||||||
";
|
|
||||||
};
|
|
||||||
|
|
||||||
beep = mkOption {
|
|
||||||
default = false;
|
|
||||||
description = "
|
|
||||||
If <literal>true</literal>, beep when an Ethernet cable is
|
|
||||||
plugged in or unplugged.
|
|
||||||
";
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
defaultMailServer = {
|
defaultMailServer = {
|
||||||
|
|
||||||
directDelivery = mkOption {
|
directDelivery = mkOption {
|
||||||
@ -428,6 +405,7 @@ in
|
|||||||
(import ../upstart-jobs/maintenance-shell.nix) # Handles the maintenance/stalled event (single-user shell).
|
(import ../upstart-jobs/maintenance-shell.nix) # Handles the maintenance/stalled event (single-user shell).
|
||||||
(import ../upstart-jobs/ctrl-alt-delete.nix) # Ctrl-alt-delete action.
|
(import ../upstart-jobs/ctrl-alt-delete.nix) # Ctrl-alt-delete action.
|
||||||
(import ../upstart-jobs/halt.nix) # FIXME (assertion) # Handles the reboot/halt events.
|
(import ../upstart-jobs/halt.nix) # FIXME (assertion) # Handles the reboot/halt events.
|
||||||
|
(import ../upstart-jobs/ifplugd.nix) # ifplugd daemon for monitoring Ethernet cables.
|
||||||
|
|
||||||
|
|
||||||
# security
|
# security
|
||||||
|
@ -70,13 +70,6 @@ let
|
|||||||
|
|
||||||
jobs = map makeJob []
|
jobs = map makeJob []
|
||||||
|
|
||||||
# ifplugd daemon for monitoring Ethernet cables.
|
|
||||||
++ optional config.networking.interfaceMonitor.enable
|
|
||||||
(import ../upstart-jobs/ifplugd.nix {
|
|
||||||
inherit (pkgs) ifplugd writeScript bash;
|
|
||||||
inherit config;
|
|
||||||
})
|
|
||||||
|
|
||||||
# User-defined events.
|
# User-defined events.
|
||||||
++ (map makeJob (config.services.extraJobs));
|
++ (map makeJob (config.services.extraJobs));
|
||||||
|
|
||||||
|
@ -1,7 +1,42 @@
|
|||||||
{ifplugd, config, writeScript, bash}:
|
{pkgs, config, ...}:
|
||||||
|
|
||||||
|
###### interface
|
||||||
|
let
|
||||||
|
inherit (pkgs.lib) mkOption mkIf;
|
||||||
|
|
||||||
|
options = {
|
||||||
|
networking = {
|
||||||
|
interfaceMonitor = {
|
||||||
|
|
||||||
|
enable = mkOption {
|
||||||
|
default = false;
|
||||||
|
description = "
|
||||||
|
If <literal>true</literal>, monitor Ethernet interfaces for
|
||||||
|
cables being plugged in or unplugged. When this occurs, the
|
||||||
|
<command>dhclient</command> service is restarted to
|
||||||
|
automatically obtain a new IP address. This is useful for
|
||||||
|
roaming users (laptops).
|
||||||
|
";
|
||||||
|
};
|
||||||
|
|
||||||
|
beep = mkOption {
|
||||||
|
default = false;
|
||||||
|
description = "
|
||||||
|
If <literal>true</literal>, beep when an Ethernet cable is
|
||||||
|
plugged in or unplugged.
|
||||||
|
";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in
|
||||||
|
|
||||||
|
###### implementation
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
|
inherit (pkgs) ifplugd writeScript bash;
|
||||||
|
|
||||||
# The ifplugd action script, which is called whenever the link
|
# The ifplugd action script, which is called whenever the link
|
||||||
# status changes (i.e., a cable is plugged in or unplugged). We do
|
# 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
|
# nothing when a cable is unplugged. When a cable is plugged in, we
|
||||||
@ -17,19 +52,27 @@ let
|
|||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
mkIf config.networking.interfaceMonitor.enable {
|
||||||
name = "ifplugd";
|
require = [
|
||||||
|
options
|
||||||
|
];
|
||||||
|
|
||||||
extraPath = [ifplugd];
|
services = {
|
||||||
|
extraJobs = [{
|
||||||
job = "
|
name = "ifplugd";
|
||||||
description \"Network interface connectivity monitor\"
|
|
||||||
|
|
||||||
start on network-interfaces/started
|
extraPath = [ifplugd];
|
||||||
stop on network-interfaces/stop
|
|
||||||
|
job = ''
|
||||||
|
description "Network interface connectivity monitor"
|
||||||
|
|
||||||
respawn ${ifplugd}/sbin/ifplugd --no-daemon --no-startup --no-shutdown \\
|
start on network-interfaces/started
|
||||||
${if config.networking.interfaceMonitor.beep then "" else "--no-beep"} \\
|
stop on network-interfaces/stop
|
||||||
--run ${plugScript}";
|
|
||||||
|
respawn ${ifplugd}/sbin/ifplugd --no-daemon --no-startup --no-shutdown \
|
||||||
|
${if config.networking.interfaceMonitor.beep then "" else "--no-beep"} \
|
||||||
|
--run ${plugScript}
|
||||||
|
'';
|
||||||
|
}];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user