-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwatchdogsd
69 lines (69 loc) · 1.7 KB
/
watchdogsd
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
64
65
66
67
68
69
#!/bin/sh
#
### BEGIN INIT INFO
# Provides: watchdogsd
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Should-Start:
# Should-Stop:
# Short-Description: Daemonized watchdogsd service.
### END INIT INFO
# chkconfig: 2345 90 60
name="watchdogsd"
command="/home/user/watchdog.sh"
command_args="/home/user/watchdog.cfg"
daemon="/usr/local/bin/daemon"
[ -x "$daemon" ] || exit 0
# This can be customized as needed
daemon_start_args="--respawn"
pidfiles="/var/run"
user=""
chroot=""
chdir=""
umask=""
stdout="daemon.info"
stderr="daemon.err"
function start()
{
if "$daemon" --running --name "$name" --pidfiles "$pidfiles"
then
echo "$name is already running."
else
echo -n "Starting $name..."
"$daemon" $daemon_start_args --name "$name" --pidfiles "$pidfiles" ${user:+--user $user} ${chroot:+--chroot $chroot} ${chdir:+--chdir $chdir} ${umask:+--umask $umask} ${stdout:+--stdout $stdout} ${stderr:+--stderr $stderr} -- "$command" $command_args
echo done.
fi
}
function stop()
{
if "$daemon" --running --name "$name" --pidfiles "$pidfiles"
then
echo -n "Stopping $name..."
"$daemon" --stop --name "$name" --pidfiles "$pidfiles"
echo done.
else
echo "$name is not running."
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
stop
sleep 3
start
;;
status)
"$daemon" --running --name "$name" --pidfiles "$pidfiles" --verbose
;;
*)
echo "usage: $0 <start|stop|restart|reload|status>" >&2
exit 1
esac
exit 0