Debian Codegraph @

connectors/vmware/packaging/debian/centreon_vmware-init

raw
1 #!/bin/sh
2 ### BEGIN INIT INFO
3 # Provides: centreon_vmware.pl
4 # Required-Start: $local_fs $network
5 # Required-Stop: $local_fs $network
6 # Default-Start: 2 3 4 5
7 # Default-Stop: 0 1 6
8 # Should-Start:
9 # Should-Stop:
10 # Short-Description: Start daemon centreon_vmware.pl at boot
11 # Description:
12 ### END INIT INFO
13
14 PKGNAME=centreon_vmware
15 DESC="centreon-vmware"
16 DAEMON=/usr/bin/centreon_vmware.pl
17 PIDFILE=/var/run/centreon/centreon_vmware.pid
18 FOLDER=/var/run/centreon/
19 if [ ! -d "$FOLDER" ]; then # Control will enter here if $DIRECTORY doesn't exist.
20 mkdir $FOLDER
21 fi
22
23 if [ ! -x "${DAEMON}" ]; then
24 echo "The program ${DAEMON} does not exists or is not executable"
25 exit 3
26 fi
27
28 # Include the default user configuration if exists
29 [ -r /etc/default/${PKGNAME} ] && . /etc/default/${PKGNAME}
30
31 # Load the VERBOSE setting and other rcS variables
32 [ -f /etc/init/vars.sh ] && . /etc/init/vars.sh
33
34 # Define LSB log_* functions.
35 # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
36 . /lib/lsb/init-functions
37
38 if [ -z "${RUN_AT_STARTUP}" -o "${RUN_AT_STARTUP}" != "YES" ]; then
39 log_warning_msg "Not starting $PKGNAME, edit /etc/default/$PKGNAME to start it."
40 exit 0
41 fi
42
43 if [ -z "${CENTREON_USER}" ]; then
44 log_warning_msg "Not starting $PKGNAME, CENTREON_USER not set in /etc/default/$PKGNAME."
45 exit 0
46 fi
47
48 do_start()
49 {
50 start-stop-daemon --start --background --quiet --pidfile ${PIDFILE} --exec ${DAEMON} \
51 --chuid ${CENTREON_USER} --user ${CENTREON_USER} --test -- $OPTIONS
52 [ "$?" = "0" ] || return 1
53 start-stop-daemon --start --background --quiet --pidfile ${PIDFILE} --exec ${DAEMON} \
54 --make-pidfile --chuid ${CENTREON_USER} --user ${CENTREON_USER} -- $OPTIONS
55 [ "$?" = "0" ] || return 2
56 return 0
57 }
58
59 do_stop()
60 {
61 start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --user ${CENTREON_USER} --pidfile ${PIDFILE}
62 [ "$?" = "2" ] && return 2
63 rm -rf ${PIDFILE}
64 [ "$?" = 0 ] && return 0 || return 1
65 }
66
67 case "$1" in
68 start)
69 [ "${VERBOSE}" != "no" ] && log_daemon_msg "Starting ${DESC}" "${PKGNAME}"
70 do_start
71 case "$?" in
72 0|1) [ "${VERBOSE}" != "no" ] && log_end_msg 0 ;;
73 2) [ "${VERBOSE}" != "no" ] && log_end_msg 1 ;;
74 esac
75 ;;
76 stop)
77 [ "${VERBOSE}" != no ] && log_daemon_msg "Stopping ${DESC}" "${PKGNAME}"
78 do_stop
79 case "$?" in
80 0|1) [ "${VERBOSE}" != no ] && log_end_msg 0 ;;
81 2) [ "${VERBOSE}" != no ] && log_end_msg 1 ;;
82 esac
83 ;;
84 status)
85 status_of_proc ${DAEMON} ${PKGNAME} -p ${PIDFILE}
86 ;;
87 restart|force-reload)
88 [ "${VERBOSE}" != no ] && log_daemon_msg "Restarting ${DESC}" "${PKGNAME}"
89 do_stop
90 case "$?" in
91 0|1)
92 do_start
93 case "$?" in
94 0) log_end_msg 0 ;;
95 1) log_end_msg 1 ;;
96 *) log_end_msg 1 ;;
97 esac
98 ;;
99 *) log_end_msg 1 ;;
100 esac
101 ;;
102 *)
103 echo "Usage: ${SCRIPTNAME} (start|stop|status|restart|force-reload)" >&2
104 exit 3
105 esac