-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathinit
63 lines (58 loc) · 1.69 KB
/
init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/sh
### BEGIN INIT INFO
# Provides: watchdog
# Required-Start: $syslog
# Required-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: watchdog
# Description: watchdog
### END INIT INFO
conf=/etc/watchdog.conf
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/watchdog
NAME=watchdog
DESC="watchdog"
OPTS="-c $conf"
case "$1" in
start)
echo "Starting $DESC"
# if the watchdog service rebooted the device the error code is stored
if [ -e /data/watchdog.reset ]; then
code=$(head -n1 /data/watchdog.reset)
(( code += 30000 ))
echo $code > /tmp/last_boot_type
rm /data/watchdog.reset
else
# save reboot reason, since it can't be read after the dev is in use.
get_boot_type > /tmp/last_boot_type
fi
# the value will be changed after it is uploaded, so keep the original value
cp /tmp/last_boot_type /tmp/last_boot_type.orig
mkdir -p /run/watchdog
start-stop-daemon --start -x "$DAEMON" -- $OPTS
;;
stop)
# note: this forcefully kill the watchdog process, keeping the hw watchdog active
echo "Stopping $DESC (keeping hw watchdog alive)"
logger "Stopping $DESC (keeping hw watchdog alive)"
killall -9 watchdog
;;
disable)
echo "Disabling $DESC"
start-stop-daemon --stop -x "$DAEMON"
;;
restart|force-reload)
echo -n "Restarting $DESC: "
start-stop-daemon --retry 10 --stop -x "$DAEMON"
sleep 1
start-stop-daemon --start -x "$DAEMON" -- $OPTS
echo "$NAME."
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload|disable}" >&2
exit 1
;;
esac
exit 0