fix error output
[mom.git] / swapmon.init
1 #!/bin/bash
2 #
3 # swapmon       Swap monitoring daemon
4 #
5 # chkconfig: 2345 98 2
6 #
7 # description:  Resets memory hogs when swap is running low
8 #
9 # $Id$
10 #
11
12 PATH=/sbin:/bin:/usr/bin:/usr/sbin
13
14 # Source function library.
15 . /etc/init.d/functions
16
17 # Source configuration
18 if [ -f /etc/sysconfig/swapmon ] ; then
19     . /etc/sysconfig/swapmon
20 fi
21
22 pidfile=/var/run/swapmon.pid
23 lockfile=/var/lock/subsys/swapmon
24 RETVAL=0
25
26 start ()
27 {
28     echo -n $"Starting swap monitor: "
29     daemon --check=swapmon /usr/share/pl_mom/swapmon.py $SWAPMON_OPTIONS
30     RETVAL=$?
31     echo
32     [ $RETVAL = 0 ] && touch ${lockfile}
33     return $RETVAL
34 }
35
36 stop ()
37 {
38     echo -n $"Stopping swap monitor: "
39     killproc swapmon
40     RETVAL=$?
41     echo
42     [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
43 }
44
45
46 case "$1" in
47     start)
48         start
49         ;;
50     stop)
51         stop
52         ;;
53     restart|reload)
54         stop
55         start
56         ;;
57     condrestart)
58         if [ -f ${lockfile} ] ; then
59             stop
60             start
61         fi
62         ;;
63     status)
64         status swapmon.py
65         ;;
66     *)
67         echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}"
68         RETVAL=1
69         ;;
70 esac
71
72 exit $RETVAL