From 6420b41d8eaf9f1f2dd0053b398897eefd99fdc8 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Fri, 8 May 2020 15:57:14 +0200 Subject: [PATCH] interafces: make rtsold_script easier to work on This will be refactored into a script or template soon enough, but for now we need to allow easier edits to bring it to the next level. --- src/etc/inc/interfaces.inc | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc index cd1f92236..fcbedcf47 100644 --- a/src/etc/inc/interfaces.inc +++ b/src/etc/inc/interfaces.inc @@ -3018,19 +3018,26 @@ function interface_dhcpv6_prepare($interface = 'wan', $wancfg) ) ); - $rtsoldscript = "#!/bin/sh\n"; - $rtsoldscript .= "# this file was auto-generated, do not edit\n"; - $rtsoldscript .= "if [ -n \"\${1}\" -a -n \"\${2}\" ]; then\n"; - $rtsoldscript .= "\techo \${2} > /tmp/\${1}_routerv6\n"; - $rtsoldscript .= "\techo \${2} > /tmp/\${1}_defaultgwv6\n"; - $rtsoldscript .= "fi\n"; - $rtsoldscript .= "if [ -f \"/var/run/dhcp6c_\${1}.pid\" ]; then\n"; - $rtsoldscript .= "\t/usr/bin/logger -t dhcp6c \"RTSOLD script - Sending SIGHUP to dhcp6c for interface \${1}\"\n"; - $rtsoldscript .= "\t/bin/pkill -HUP -F \"/var/run/dhcp6c_\${1}.pid\"\n"; - $rtsoldscript .= "else\n"; - $rtsoldscript .= "\t/usr/bin/logger -t dhcp6c \"RTSOLD script - Starting dhcp6 client for interface \${1}\"\n"; - $rtsoldscript .= "\t$dhcp6ccommand\n"; - $rtsoldscript .= "fi\n"; + $rtsoldscript = << /tmp/\${1}_routerv6 + echo \${2} > /tmp/\${1}_defaultgwv6 +fi +if [ -f "/var/run/dhcp6c_\${1}.pid" ]; then + /usr/bin/logger -t dhcp6c "RTSOLD script - Sending SIGHUP to dhcp6c for interface \${1}" + /bin/pkill -HUP -F "/var/run/dhcp6c_\${1}.pid" +else + /usr/bin/logger -t dhcp6c "RTSOLD script - Starting dhcp6 client for interface \${1}" + {$dhcp6ccommand} +fi + +EOD; @file_put_contents('/var/etc/rtsold_script.sh', $rtsoldscript); @chmod('/var/etc/rtsold_script.sh', 0755);