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