-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit.portcheck
70 lines (59 loc) · 1.43 KB
/
init.portcheck
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
70
#!/bin/bash
# /etc/init.d/portcheck
#
### BEGIN INIT INFO
# Provides: portcheck
# Required-Start: $remote_fs $syslog $network
# Required-Stop: $remote_fs $syslog $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start portcheck at boot time
# Description: Controls the portcheck daemon.
### END INIT INFO
PATH=/bin:/usr/bin:/sbin:/usr/sbin
DESC="Portcheck daemon"
NAME=portcheck
SCRIPTNAME=/etc/init.d/$NAME
PORTCHECK_BIN=/portcheck/portcheck/portcheck
PORTCHECK_ARGS="8082"
PORTCHECK_USER=portcheck
PIDFILE=/var/run/portcheck/portcheck.pid
DAEMON=/usr/bin/daemon
DAEMON_ARGS="--name=$NAME --pidfile=$PIDFILE --user=$PORTCHECK_USER --respawn"
SU=/bin/su
. /lib/init/vars.sh
. /lib/lsb/init-functions
# Make sure we run as root
if [ `id -u` -ne 0 ]; then
echo "The $NAME init script can only be run as root"
exit 1
fi
setup_folders() {
mkdir -p $(dirname $PIDFILE)
chown -R $PORTCHECK_USER $(dirname $PIDFILE)
}
case "$1" in
start)
setup_folders
echo -n "Starting $DESC... "
if $DAEMON $DAEMON_ARGS -- $PORTCHECK_BIN $PORTCHECK_ARGS; then
echo "OK"
fi
;;
stop)
setup_folders
echo -n "Stopping $DESC... "
if $DAEMON $DAEMON_ARGS --stop; then
echo "OK"
fi
;;
restart|force-reload)
$0 stop
$0 start
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
exit 3
;;
esac
exit 0