ap51-flash.init (1521B)
1 #!/bin/sh /etc/rc.common 2 # Copyright (C) 2010 OpenWrt.org 3 4 START=20 5 6 NAME=ap51-flash 7 8 start_daemon() { 9 local cfg="$1" 10 11 config_get_bool loop "$cfg" loop 12 config_get ifname "$cfg" ifname 13 config_get rootfs "$cfg" rootfs 14 config_get kernel "$cfg" kernel 15 config_get ubnt "$cfg" ubnt 16 [ "$loop" != "1" ] && loop=0 17 if [ -n "$ifname" -a -n "$rootfs" -a -n "$kernel" ] || \ 18 [ -n "$ifname" -a -n "$ubnt" ]; then 19 PID="`cat /var/run/$NAME.sh-$ifname.pid 2> /dev/null`" 20 [ -z "`ps | grep "^.[ ]*$PID "`" ] && \ 21 rm /var/run/$NAME.sh-$ifname.pid 22 [ -n "`ls /var/run/$NAME.sh-$ifname.pid 2> /dev/null`" ] && { 23 echo "Can't start more than one ap51-flash for interface $ifname!" 24 return 0 25 } 26 start-stop-daemon -S -b -m -p /var/run/$NAME.sh-$ifname.pid -n $NAME.sh \ 27 -x /usr/lib/ap51-flash/$NAME.sh -- "$loop" "$ifname" "$rootfs" "$kernel" "$ubnt" 28 fi 29 } 30 31 start() { 32 config_load ap51-flash 33 config_foreach start_daemon flash 34 } 35 36 stop() { 37 # Terminating all ap51-flash processes 38 echo "WARNING: Going to teminate all ap51-flash processes! (hope you made sure that they're not flashing right now)" 39 echo "OR you can stop this with Ctrl+c within 10 seconds" 40 sleep 10 41 local pidfile 42 for pidfile in `ls /var/run/${NAME}.sh-*.pid 2> /dev/null`; do 43 start-stop-daemon -K -s TERM -p "${pidfile}" -n "${NAME}.sh" >/dev/null 44 rm -f "${pidfile}" 45 done 46 for pidfile in `ls /var/run/${NAME}-*.pid 2> /dev/null`; do 47 start-stop-daemon -K -s TERM -p "${pidfile}" -n "${NAME}" >/dev/null 48 rm -f "${pidfile}" 49 done 50 }