forked from Centreon-Community/centreon-newtest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcentreon_newtestd-init
116 lines (102 loc) · 2.57 KB
/
centreon_newtestd-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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#! /bin/bash
#
# centreon_newtestd Start/Stop the centreon_newtestd daemon.
#
# chkconfig: 2345 80 20
# description: centreon_newtestd is a Centreon program
# processname: centreon_newtestd
# config: /etc/centreon/centreon_newtestd.pm
# pidfile: /var/run/centreon_newtestd.pid
# Source function library.
. /etc/init.d/functions
binary=/usr/bin/centreon_newtestd
servicename=$(basename "$0")
OPTIONS=""
user=root
timeout=60
pidfile=/var/run/centreon_newtestd.pid
[ -e /etc/sysconfig/centreon_newtestd ] && . /etc/sysconfig/centreon_newtestd
# Check if we can find the binary.
if [ ! -x $binary ]; then
echo -n $"Starting $servicename.";
failure $"Executable file $binary not found. Exiting."
echo
exit 2
fi
start() {
echo -n $"Starting $servicename: "
if [ -e "$pidfile" ] && [ -n "$(cat $pidfile)" ] && [ -e "/proc/`cat $pidfile`" ]; then
echo -n $"cannot start $servicename: $servicename is already running.";
failure $"cannot start $servicename: $servicename already running.";
echo
return 1
fi
if [ ! -e "$pidfile" ] ; then
pid=$(pidofproc $binary)
if [ -n "$pid" ] ; then
echo -n $"cannot start $servicename: $servicename is already running.";
failure $"cannot start $servicename: $servicename already running.";
echo
return 1
fi
fi
if [ "$(id -u -n)" = "$user" ] ; then
daemon ''$binary' '$OPTIONS' > /dev/null 2>&1 &'
else
daemon --user $user ''$binary' '$OPTIONS' > /dev/null 2>&1 &'
fi
pid=$(pidofproc $binary)
RETVAL=$?
echo $pid > $pidfile
success $"service launched"
echo
return $RETVAL
}
stop() {
echo -n $"Stopping $servicename: "
if [ ! -e "$pidfile" ] || [ -z "$(cat $pidfile)" ] ; then
killproc -d $timeout "$binary"
else
killproc -p "$pidfile" -d $timeout "$binary"
fi
RETVAL=$?
echo
return $RETVAL
}
rhstatus() {
status -p "$pidfile" "$binary"
}
restart() {
stop
start
}
reload() {
echo -n $"Reloading $servicename daemon configuration: "
killproc -p "$pidfile" "$binary" -HUP
RETVAL=$?
echo
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
reload)
reload
;;
status)
rhstatus
;;
condrestart)
[ -f /var/lock/subsys/centreon_esxd ] && restart || :
;;
*)
echo $"Usage: $0 {start|stop|status|reload|restart|condrestart}"
exit 1
esac