diff options
author | Richard Sent <richard@freakingpenguin.com> | 2024-06-17 20:49:12 -0400 |
---|---|---|
committer | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2024-06-24 08:50:45 -0400 |
commit | b539e5ae3995b554cd5557274a4d95ba0618a3fd (patch) | |
tree | c24e2207be4515857051c7e280cb20f59704f02a | |
parent | e92259e56f3230ccb5e9bae3419f5071f6e6c40a (diff) | |
download | guix-b539e5ae3995b554cd5557274a4d95ba0618a3fd.tar.gz guix-b539e5ae3995b554cd5557274a4d95ba0618a3fd.zip |
services: networking: Allow dhcp-client to use a config file.
* gnu/services/networking.scm (dhcp-client-configuration) [config-file]: New
field.
(dhcp-client-configuration-config-file): New accessor.
(dhcp-client-shepherd-service): Use the config file when invoking
dhclient if supplied.
* doc/guix.texi: Document it.
Change-Id: I286de4ddf59c5e606bf1fe0a7510570869e62b1a
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
-rw-r--r-- | doc/guix.texi | 3 | ||||
-rw-r--r-- | gnu/services/networking.scm | 15 |
2 files changed, 16 insertions, 2 deletions
diff --git a/doc/guix.texi b/doc/guix.texi index 9bbf85e32b..c35e10d877 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -21035,6 +21035,9 @@ When set to @code{'all}, the DHCP client listens on all the available non-loopback interfaces that can be activated. Otherwise the DHCP client listens only on the specified interfaces. +@item @code{config-file} (default: @code{#f}) +The configuration file for the DHCP client. + @item @code{shepherd-requirement} (default: @code{'()}) @itemx @code{shepherd-provision} (default: @code{'(networking)}) This option can be used to provide a list of symbols naming Shepherd services diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm index 378e117a86..12d8934e43 100644 --- a/gnu/services/networking.scm +++ b/gnu/services/networking.scm @@ -91,6 +91,7 @@ dhcp-client-configuration? dhcp-client-configuration-package dhcp-client-configuration-interfaces + dhcp-client-configuration-config-file dhcp-client-configuration-shepherd-provision dhcp-client-configuration-shepherd-requirement @@ -319,6 +320,8 @@ (default '())) (shepherd-provision dhcp-client-configuration-shepherd-provision (default '(networking))) + (config-file dhcp-client-configuration-config-file + (default #f)) (interfaces dhcp-client-configuration-interfaces (default 'all))) ;'all | list of strings @@ -329,6 +332,7 @@ (requirement (dhcp-client-configuration-shepherd-requirement config)) (provision (dhcp-client-configuration-shepherd-provision config)) (interfaces (dhcp-client-configuration-interfaces config)) + (config-file (dhcp-client-configuration-config-file config)) (pid-file "/var/run/dhclient.pid")) (list (shepherd-service (documentation "Set up networking via DHCP.") @@ -364,6 +368,11 @@ (_ #~'#$interfaces)))) + (define config-file-args + (if #$config-file + (list "-cf" #$config-file) + '())) + (false-if-exception (delete-file #$pid-file)) (let ((pid (fork+exec-command ;; By default dhclient uses a @@ -371,8 +380,10 @@ ;; DDNS, which is incompatable with ;; non-ISC DHCP servers; thus, pass '-I'. ;; <https://kb.isc.org/docs/aa-01091>. - (cons* dhclient "-nw" "-I" - "-pf" #$pid-file ifaces)))) + `(,dhclient "-nw" "-I" + "-pf" ,#$pid-file + ,@config-file-args + ,@ifaces)))) (and (zero? (cdr (waitpid pid))) (read-pid-file #$pid-file))))) (stop #~(make-kill-destructor)))))) |