root/resources/resmon_debian_rc

Revision 6bb597cd8c6974f8feb2e9393560e3182da46fe6, 1.6 kB (checked in by Mark Harrison <mark@omniti.com>, 4 years ago)

Debian/Ubuntu init script

Contributed by: Sam Minnée <sam@silverstripe.com>

git-svn-id: https://labs.omniti.com/resmon/trunk@256 8c0face9-b7db-6ec6-c4b3-d5f7145c7d55

  • Property mode set to 100755
Line 
1 #!/bin/bash
2 # Resmon init script for Debian/Ubuntu
3
4 ### BEGIN INIT INFO
5 # Provides: resmon
6 # Required-Start: $network $local_fs
7 # Required-Stop:  $network $local_fs
8 # Default-Start:     2 3 4 5
9 # Default-Stop:      0 1 6
10 # Short-Description: Resmon system monitor
11 ### END INIT INFO
12
13 # Source function library.
14 . /lib/lsb/init-functions
15
16 RESMON_DIR=/opt/resmon
17 RESMON_CONF=$RESMON_DIR/resmon.conf
18 RESMON_BIN=$RESMON_DIR/resmon
19 RESMON_LOCK=/var/lock/resmon
20
21 [ -x $RESMON_BIN ] || exit 0
22 [ -f $RESMON_CONF ] || exit 0
23
24 RETVAL=0
25
26 umask 077
27
28 start() {
29         echo -n $"Starting resmon: resmon"
30         start-stop-daemon --start --exec $RESMON_BIN
31         RETVAL=$?
32         echo "."
33         [ $RETVAL -eq 0 ] && touch $RESMON_LOCK
34         return $RETVAL
35 }
36 stop() {
37         echo -n "Shutting down resmon: resmon"
38         start-stop-daemon --stop --name resmon --exec /usr/bin/perl
39         echo "."
40         RETVAL=$?
41         [ $RETVAL -eq 0 ] && rm -f $RESMON_LOCK
42         return $RETVAL
43 }
44 status() {
45     pgrep -f $RESMON_BIN > /dev/null
46     if [ $? = 0 ]; then
47             echo "Resmon is running."
48     else
49             echo "Resmon is not running."
50     fi
51 }
52 restart() {
53         stop
54         start
55 }
56 reload() {
57         echo -n "Reloading resmon: resmon"
58         killproc resmon -HUP
59         echo "."
60         return $?
61 }
62
63 case "$1" in
64   start)
65         start
66         ;;
67   stop)
68         stop
69         ;;
70   status)
71         status
72         ;;
73   restart)
74         restart
75         ;;
76   reload)
77         reload
78         ;;
79   force-reload)
80         reload
81         ;;
82   *)
83         echo $"Usage: $0 {start|stop|status|restart|reload|force-reload}"
84         exit 1
85 esac
86
87 exit $?
88
Note: See TracBrowser for help on using the browser.