From eff26fc78310e59c7fdb443bbdda7f256f5d63cd Mon Sep 17 00:00:00 2001 From: Rob White Date: Wed, 2 May 2018 16:13:50 +0100 Subject: [PATCH] nodogsplash: add startup checks and restart hook --- nodogsplash2/files/nodogsplash.init | 53 +++++++++++++++++------------ 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/nodogsplash2/files/nodogsplash.init b/nodogsplash2/files/nodogsplash.init index 168007f..824301d 100755 --- a/nodogsplash2/files/nodogsplash.init +++ b/nodogsplash2/files/nodogsplash.init @@ -248,30 +248,41 @@ create_instance() { procd_close_instance } +depends() { + if [ "$1" = "iptables" ] ; then + if [ $(uci get nodogsplash.@nodogsplash[0].fwhook_enabled) = "1" ] ; then + if $WD_DIR/ndsctl status > /dev/null; then + echo " * Restarting NodogSplash" + /etc/init.d/nodogsplash restart + fi + else echo " * NodogSplash fwhook is disabled" + fi + fi +} + start_service() { include /lib/functions - - if ! uci get firewall.nodogsplash2.path &> /dev/null ; then - if [ -f '/etc/nodogsplash/ndshook.sh' ] ; then - rm /etc/nodogsplash/ndshook.sh - fi - uci delete firewall.nodogsplash2 2> /dev/null - uci set firewall.nodogsplash2=include - uci set firewall.nodogsplash2.type=script - uci set firewall.nodogsplash2.path='/etc/nodogsplash/ndshook.sh' - uci commit firewall - /etc/init.d/firewall restart 2>&1 | logger - fi - - if [ ! -f '/etc/nodogsplash/ndshook.sh' ] ; then - printf "#NDS Restart Hook Created by Nodogsplash. Do not modify.\n" > /etc/nodogsplash/ndshook.sh - printf " if /usr/bin/ndsctl status > /dev/null; then\n" >> /etc/nodogsplash/ndshook.sh - printf " echo \" * Restarting NodogSplash \"\n" >> /etc/nodogsplash/ndshook.sh - printf " /etc/init.d/nodogsplash restart\n fi\n" >> /etc/nodogsplash/ndshook.sh - chmod +x /etc/nodogsplash/ndshook.sh - fi - mkdir -p /tmp/etc/ + + if [ $(uci get nodogsplash.@nodogsplash[0].fwhook_enabled) = "1" ] ; then + if ! uci get firewall.nodogsplash2.path &> /dev/null ; then + if [ -f '/tmp/etc/ndshook.include' ] ; then + rm /tmp/etc/ndshook.include + fi + uci delete firewall.nodogsplash2 2> /dev/null + uci set firewall.nodogsplash2=include + uci set firewall.nodogsplash2.type=script + uci set firewall.nodogsplash2.path='/tmp/etc/ndshook.include' + uci commit firewall + /etc/init.d/firewall restart 2>&1 | logger + fi + + if [ ! -f '/tmp/etc/ndshook.include' ] ; then + printf "if [ -f '/etc/init.d/nodogsplash' ] ; then /etc/init.d/nodogsplash depends iptables ; fi\n" > /tmp/etc/ndshook.include + chmod +x /tmp/etc/ndshook.include + fi + fi + config_load nodogsplash config_foreach create_instance nodogsplash