-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathzabbix-dashing.init
executable file
·83 lines (72 loc) · 1.79 KB
/
zabbix-dashing.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
### BEGIN INIT INFO
# Provides: zabbix-dashing
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
set -e
. /lib/lsb/init-functions
DEFAULT_CONFIG="/etc/default/zabbix-dashing-init.conf"
if [ ! -s "${DEFAULT_CONFIG}" ]; then
NAME=dashing
DASHING_DIR=/opt/zabbix-dashing
PIDFILE="$DASHING_DIR/$NAME.pid"
DAEMON=/usr/local/bin/$NAME
GEM_HOME=/var/lib/gems/1.9.1
DASHING_PORT=8080
DAEMON_OPTS="start -d -p $DASHING_PORT -P $PIDFILE --tag $NAME -D"
RUNUSER=root
RUNGROUP=root
else
. "${DEFAULT_CONFIG}"
fi
test -x $DAEMON || { log_failure_msg "$NAME not installed";exit 1; }
function checkuser() {
if [[ $UID != 0 ]]; then
if [[ `whoami` != "$RUNUSER" ]]; then
log_failure_msg "$1 must be run as root or $RUNUSER"
exit 1
fi
fi
}
function start_dashing() {
log_action_msg "Starting daemon: $NAME" || true
sleep 5
start-stop-daemon --verbose --quiet --start --chuid $RUNUSER:$RUNGROUP --chdir $DASHING_DIR --exec $DAEMON -- $DAEMON_OPTS
log_end_msg 0
}
function stop_dashing() {
log_action_msg "Stopping daemon: $NAME" || true
start-stop-daemon --quiet --stop --pidfile $PIDFILE --user $RUNUSER --retry 30 --oknodo
log_end_msg 0
}
case "$1" in
start)
checkuser start
start_dashing
;;
stop)
checkuser stop
stop_dashing
;;
restart)
checkuser restart
log_action_msg "Restarting daemon: $NAME"
stop_dashing
start_dashing
;;
status)
status_of_proc -p $DAEMON $NAME
;;
logs)
tail -F $DASHING_DIR/log/thin.log
;;
*)
echo "Usage: "$1" {start|stop|restart|status}"
exit 1
esac
exit 0