1 |
#!/bin/sh |
2 |
# |
3 |
# chkconfig: - 85 15 |
4 |
# description: Zabbix server daemon |
5 |
# config: /etc/zabbix/zabbix_server.conf |
6 |
# |
7 |
|
8 |
### BEGIN INIT INFO |
9 |
# Provides: zabbix |
10 |
# Required-Start: $local_fs $network |
11 |
# Required-Stop: $local_fs $network |
12 |
# Default-Start: |
13 |
# Default-Stop: 0 1 2 3 4 5 6 |
14 |
# Short-Description: Start and stop Zabbix server |
15 |
# Description: Zabbix server |
16 |
### END INIT INFO |
17 |
|
18 |
# Source function library. |
19 |
. /etc/rc.d/init.d/functions |
20 |
|
21 |
if [ -x /usr/sbin/zabbix_server ]; then |
22 |
exec=/usr/sbin/zabbix_server |
23 |
else |
24 |
exit 5 |
25 |
fi |
26 |
|
27 |
prog=${exec##*/} |
28 |
conf=/etc/zabbix/zabbix_server.conf |
29 |
pidfile=$(grep -e "^PidFile=.*$" $conf | cut -d= -f2 | tr -d '\r') |
30 |
timeout=10 |
31 |
|
32 |
if [ -f /etc/sysconfig/zabbix-server ]; then |
33 |
. /etc/sysconfig/zabbix-server |
34 |
fi |
35 |
|
36 |
lockfile=/var/lock/subsys/zabbix-server |
37 |
|
38 |
start() |
39 |
{ |
40 |
echo -n $"Starting Zabbix server: " |
41 |
daemon $exec -c $conf |
42 |
rv=$? |
43 |
echo |
44 |
[ $rv -eq 0 ] && touch $lockfile |
45 |
return $rv |
46 |
} |
47 |
|
48 |
stop() |
49 |
{ |
50 |
echo -n $"Shutting down Zabbix server: " |
51 |
killproc -p $pidfile -d $timeout $prog |
52 |
rv=$? |
53 |
echo |
54 |
[ $rv -eq 0 ] && rm -f $lockfile |
55 |
return $rv |
56 |
} |
57 |
|
58 |
restart() |
59 |
{ |
60 |
stop |
61 |
start |
62 |
} |
63 |
|
64 |
case "$1" in |
65 |
start|stop|restart) |
66 |
$1 |
67 |
;; |
68 |
force-reload) |
69 |
restart |
70 |
;; |
71 |
status) |
72 |
status -p $pidfile $prog |
73 |
;; |
74 |
try-restart|condrestart) |
75 |
if status $prog >/dev/null ; then |
76 |
restart |
77 |
fi |
78 |
;; |
79 |
reload) |
80 |
action $"Service ${0##*/} does not support the reload action: " /bin/false |
81 |
exit 3 |
82 |
;; |
83 |
*) |
84 |
echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}" |
85 |
exit 2 |
86 |
;; |
87 |
esac |
88 |
|