From 6ec13b343f04dc9b1c30695fdf1db581c2c0088a Mon Sep 17 00:00:00 2001 From: ohrensessel Date: Wed, 1 Oct 2014 23:52:02 +0200 Subject: [PATCH] Extend check_gateway script ensure that dhcp server is stopped or started depending on gw mode --- files/usr/local/bin/check_gateway | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/files/usr/local/bin/check_gateway b/files/usr/local/bin/check_gateway index 43e4683..1e65f07 100644 --- a/files/usr/local/bin/check_gateway +++ b/files/usr/local/bin/check_gateway @@ -31,4 +31,21 @@ OLD_STATE="$(cat $MESH/gw_mode)" # Restart DHCP server /usr/sbin/service isc-dhcp-server start fi + exit 0 done + +if [ "$NEW_STATE" == "server" ]; then + /usr/sbin/service isc-dhcp-server status 2>&1> /dev/null + if [[ $? -ne 0 ]] + then + /usr/sbin/service isc-dhcp-server restart + fi +fi +if [ "$NEW_STATE" == "off" ]; then + /usr/sbin/service isc-dhcp-server status 2>&1> /dev/null + if [[ $? -eq 0 ]] + then + /usr/sbin/service isc-dhcp-server stop + fi +fi +