#!/bin/sh # start supervising existense of FON hotspot and starting/killing dnsmasq echo "`uptime | awk -F" " '{print $1}'`: $0 tun0 dnsmasq supervisor: fork into background, checking hotspot status..." >>/tmp/.startup_log while :; do ifconfig tun0 >/dev/null 2>/dev/null if [ "$?" = "0" ]; then [ -z `cat /var/run/dnsmasq_tun0.pid` ] && { # if it is not running already dnsmasq -i tun0 -z -I lo,ath1 --no-dhcp-interface=tun0 -x /var/run/dnsmasq_tun0.pid && \ echo "`uptime | awk -F" " '{print $1}'`: tun0 dnsmasq supervisor: dnsmasq started" >>/tmp/.startup_log } else [ -n `cat /var/run/dnsmasq_tun0.pid` ] && { # if it is really running kill `cat /var/run/dnsmasq_tun0.pid` && \ echo "`uptime | awk -F" " '{print $1}'`: tun0 dnsmasq supervisor: dnsmasq stopped" >>/tmp/.startup_log } fi sleep 5 done