nodogsplash: add startup checks and restart hook

This commit is contained in:
Rob White 2018-05-02 16:13:50 +01:00 committed by GitHub
parent 9f09cdda6c
commit eff26fc783
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -248,30 +248,41 @@ create_instance() {
procd_close_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() { start_service() {
include /lib/functions include /lib/functions
mkdir -p /tmp/etc/
if [ $(uci get nodogsplash.@nodogsplash[0].fwhook_enabled) = "1" ] ; then
if ! uci get firewall.nodogsplash2.path &> /dev/null ; then if ! uci get firewall.nodogsplash2.path &> /dev/null ; then
if [ -f '/etc/nodogsplash/ndshook.sh' ] ; then if [ -f '/tmp/etc/ndshook.include' ] ; then
rm /etc/nodogsplash/ndshook.sh rm /tmp/etc/ndshook.include
fi fi
uci delete firewall.nodogsplash2 2> /dev/null uci delete firewall.nodogsplash2 2> /dev/null
uci set firewall.nodogsplash2=include uci set firewall.nodogsplash2=include
uci set firewall.nodogsplash2.type=script uci set firewall.nodogsplash2.type=script
uci set firewall.nodogsplash2.path='/etc/nodogsplash/ndshook.sh' uci set firewall.nodogsplash2.path='/tmp/etc/ndshook.include'
uci commit firewall uci commit firewall
/etc/init.d/firewall restart 2>&1 | logger /etc/init.d/firewall restart 2>&1 | logger
fi fi
if [ ! -f '/etc/nodogsplash/ndshook.sh' ] ; then if [ ! -f '/tmp/etc/ndshook.include' ] ; then
printf "#NDS Restart Hook Created by Nodogsplash. Do not modify.\n" > /etc/nodogsplash/ndshook.sh printf "if [ -f '/etc/init.d/nodogsplash' ] ; then /etc/init.d/nodogsplash depends iptables ; fi\n" > /tmp/etc/ndshook.include
printf " if /usr/bin/ndsctl status > /dev/null; then\n" >> /etc/nodogsplash/ndshook.sh chmod +x /tmp/etc/ndshook.include
printf " echo \" * Restarting NodogSplash \"\n" >> /etc/nodogsplash/ndshook.sh fi
printf " /etc/init.d/nodogsplash restart\n fi\n" >> /etc/nodogsplash/ndshook.sh
chmod +x /etc/nodogsplash/ndshook.sh
fi fi
mkdir -p /tmp/etc/
config_load nodogsplash config_load nodogsplash
config_foreach create_instance nodogsplash config_foreach create_instance nodogsplash