root/trunk/freewrt/package/broadcom-watchbutton/files/watchbutton.init

Revision 3512, 426 bytes (checked in by tg, 5 years ago)

fix the problem that a “/etc/init.d/ntpd restart” wouldn’t work
because it uses “killall ntpd” and nukes itself: on execution,
run mksh(1) with ourselves first, to make sure that killall/pkill
will see our process name as “mksh” instead of e.g. “…/ntpd”.

Line 
1 #!/bin/sh
2 test x"$1" = x"really" || exec /bin/mksh "$0" really "$@"
3 shift
4 #FWINIT 50
5 . /etc/rc.conf
6
7 case $1 in
8 autostop) ;;
9 autostart)
10         test x"$watchbutton" = x"NO" && exit 0
11         exec sh $0 start
12         ;;
13 start)
14         ps ax | grep -q [/]sbin/watchbutton && exit
15         /sbin/watchbutton >&- 2>&- &
16         ;;
17 stop)
18         killall watchbutton
19         ;;
20 restart)
21         sh $0 stop && sh $0 start
22         ;;
23 *)
24         echo "Usage: $0 {start | stop | restart}"
25         exit 1
26         ;;
27 esac
28 exit $?
Note: See TracBrowser for help on using the browser.