From 8452dd3cd0c32dee64f15088f8b0a37407f1277b Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 16 Mar 2007 16:41:38 +0000 Subject: [PATCH] * Upstart job for dhcpd. svn path=/nixos/trunk/; revision=8311 --- system/options.nix | 26 ++++++++++++++++++++++++++ system/upstart.nix | 8 ++++++++ upstart-jobs/dhcpd.nix | 17 +++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 upstart-jobs/dhcpd.nix diff --git a/system/options.nix b/system/options.nix index 5bc09612503..789a00f58a2 100644 --- a/system/options.nix +++ b/system/options.nix @@ -413,6 +413,32 @@ */ + { + name = ["services" "dhcpd" "enable"]; + default = false; + description = " + Whether to enable the DHCP server. + "; + } + + + { + name = ["services" "dhcpd" "configFile"]; + description = " + The path of the DHCP server configuration file. + "; + } + + + { + name = ["services" "dhcpd" "interfaces"]; + default = ["eth0"]; + description = " + The interfaces on which the DHCP server should listen. + "; + } + + { name = ["services" "sshd" "enable"]; default = false; diff --git a/system/upstart.nix b/system/upstart.nix index 0a00a1ba31f..09c82fae53f 100644 --- a/system/upstart.nix +++ b/system/upstart.nix @@ -103,6 +103,14 @@ import ../upstart-jobs/gather.nix { interfaces = config.get ["networking" "interfaces"]; }) + # DHCP server. + ++ optional ["services" "dhcpd" "enable"] + (import ../upstart-jobs/dhcpd.nix { + inherit (pkgs) dhcp; + configFile = config.get ["services" "dhcpd" "configFile"]; + interfaces = config.get ["services" "dhcpd" "interfaces"]; + }) + # SSH daemon. ++ optional ["services" "sshd" "enable"] (import ../upstart-jobs/sshd.nix { diff --git a/upstart-jobs/dhcpd.nix b/upstart-jobs/dhcpd.nix new file mode 100644 index 00000000000..aa09c200901 --- /dev/null +++ b/upstart-jobs/dhcpd.nix @@ -0,0 +1,17 @@ +{dhcp, configFile, interfaces}: + +{ + name = "dhcpd"; + + job = " +description \"DHCP server\" + +start on network-interfaces/started +stop on network-interfaces/stop + +script + exec ${dhcp}/sbin/dhcpd -f -cf ${configFile} ${toString interfaces} +end script + "; + +}