forked from fidlej/sd-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsd-agent-pkg.init
85 lines (75 loc) · 2.04 KB
/
sd-agent-pkg.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
83
84
85
#!/bin/sh
#
###############################################################################
# sd-agent
#
# Written by Boxed Ice <hello@boxedice.com>
# A server monitoring daemon for www.serverdensity.com
#
# Licensed under Simplified BSD License (see LICENSE)
#
###############################################################################
#
# chkconfig: 345 85 15
# description: Server Density Monitoring Agent
### BEGIN INIT INFO
# Provides: sd-agent
# Short-Description: Start and start sd-agent
# Description: sd-agent is the monitoring agent component for Server Density
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO
AGENTPATH="/usr/bin/sd-agent/agent.py"
AGENTUSER="sd-agent"
PIDPATH="/var/run/sd-agent/"
[ -f $AGENTPATH ] || echo "/usr/bin/sd-agent not found"
# Source function library.
if [ -f /etc/init.d/functions ]; then
. /etc/init.d/functions
fi
if [ -f /etc/SuSE-release ]; then
. /etc/rc.status
rc_reset
fi
# Action to take
case "$1" in
start)
if [ ! -d $PIDPATH ]; then
mkdir -p $PIDPATH
chown sd-agent:sd-agent $PIDPATH
fi
su $AGENTUSER -c "python $AGENTPATH stop init"
su $AGENTUSER -c "python $AGENTPATH start init --clean"
if [ -f /etc/SuSE-release ]; then
rc_status -v
elif [ -f /etc/debian_version ] || [ -f /etc/lsb-release ] || [ -f /etc/gentoo-release ]; then
echo " Started"
else
success
echo
fi
echo
;;
stop)
su $AGENTUSER -c "python $AGENTPATH stop init"
if [ -f /etc/SuSE-release ]; then
rc_status -v
elif [ -f /etc/debian_version ] || [ -f /etc/lsb-release ] || [ -f /etc/gentoo-release ]; then
echo " Stopped"
else
success
echo
fi
echo
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: /etc/init.d/sd-agent start|stop|restart"
exit 1
esac
exit 0