rotuer: use writeFennelScript for odhcpc update script

This commit is contained in:
Daniel Barlow 2023-05-30 18:20:14 +01:00
parent fdffdbb22a
commit cb30ce52eb
2 changed files with 5 additions and 8 deletions

View file

@ -1,4 +1,5 @@
(os.chdir (os.getenv "SERVICE_STATE"))
(fn write-value [name value] (fn write-value [name value]
(with-open [fout (io.open name :w)] (with-open [fout (io.open name :w)]

View file

@ -21,6 +21,7 @@ let
dropbear dropbear
ifwait ifwait
writeText writeText
writeFennelScript
serviceFns; serviceFns;
in rec { in rec {
boot = { boot = {
@ -235,18 +236,13 @@ in rec {
services.dhcp6 = services.dhcp6 =
let let
name = "dhcp6c.wan"; name = "dhcp6c.wan";
luafile = pkgs.runCommand "udhcpc-script" {} '' luafile = writeFennelScript "odhcpc-script" [] ./odhcp6-script.fnl;
${pkgs.luaSmall.pkgs.fennel}/bin/fennel --compile ${./udhcp6-script.fnl} > $out
'';
script = pkgs.writeAshScript "dhcp6-notify" {} ''
. ${serviceFns}
(in_outputs ${name}; ${pkgs.luaSmall}/bin/lua ${luafile} "$@")
'';
in longrun { in longrun {
inherit name; inherit name;
notification-fd = 10; notification-fd = 10;
run = '' run = ''
${pkgs.odhcp6c}/bin/odhcp6c -s ${script} -e -v -p /run/${name}.pid -P 48 $(output ${services.wan} ifname) export SERVICE_STATE=/run/service-state/${name}
${pkgs.odhcp6c}/bin/odhcp6c -s ${luafile} -e -v -p /run/${name}.pid -P 48 $(output ${services.wan} ifname)
) )
''; '';
dependencies = [ services.wan ]; dependencies = [ services.wan ];