Make example s6 script handle empty leasefile properly.

Prior to this change, ndhc would fail to run with a malformed
command error if the leasefile was empty since the -r parameter
requires an argument.

Note that this script requires execline 2.9.1.0 for the
eltest program.  For earlier versions of s6, it should be
fine to use the POSIX test program instead.
This commit is contained in:
Nicholas J. Kain 2023-01-18 12:54:55 -05:00
parent 44511e6789
commit 841c8663e9
No known key found for this signature in database

View File

@ -1,6 +1,8 @@
#!/bin/execlineb -P #!/bin/execlineb -P
fdmove -c 2 1 fdmove -c 2 1
backtick OLDEXTIP { cat /etc/firewall/tmp/OLDEXTIP } backtick OLDEXTIP { cat /etc/ndhc/LEASE-wan0 }
importas OLDEXTIP OLDEXTIP importas OLDEXTIP OLDEXTIP
/sbin/ndhc -c /etc/ndhc/wan0.conf -r $OLDEXTIP ifelse { eltest -n $OLDEXTIP }
{ /sbin/ndhc -c /etc/ndhc/wan0.conf -r $OLDEXTIP }
/sbin/ndhc -c /etc/ndhc/wan0.conf