/[smeserver]/rpms/nut/sme7/ups.init
ViewVC logotype

Contents of /rpms/nut/sme7/ups.init

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download)
Sun Oct 14 18:46:07 2007 UTC (17 years, 1 month ago) by slords
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +0 -0 lines
FILE REMOVED
Remove unneeded packages

1 #! /bin/bash
2 #
3 # chkconfig: - 26 74
4 # description: Network UPS Tools is a collection of programs which provide a common \
5 # interface for monitoring and administering UPS hardware.
6
7 # processname: upsd
8 # config: /etc/ups/
9
10 # Source function library.
11 if [ -f /etc/init.d/functions ]; then
12 . /etc/init.d/functions
13 elif [ -f /etc/rc.d/init.d/functions ]; then
14 . /etc/rc.d/init.d/functions
15 else
16 exit 0
17 fi
18
19 # Get config.
20 if [ -f /etc/sysconfig/ups ]; then
21 . /etc/sysconfig/ups
22 else
23 SERVER="no"
24 fi
25
26 start() {
27 if [ "$SERVER" = "yes" ]; then
28 echo -n $"Starting UPS driver controller: "
29 daemon /sbin/upsdrvctl start
30 RETVAL=$?
31 echo
32
33 prog="upsd"
34 echo -n $"Starting $prog: "
35 daemon /usr/sbin/upsd $UPSD_OPTIONS
36 if [ "$RETVAL" = 0 ]; then
37 RETVAL=$?
38 fi
39 echo
40
41 echo -n $"Starting UPS monitor (master): "
42 daemon /usr/sbin/upsmon
43 if [ "$RETVAL" = 0 ]; then
44 RETVAL=$?
45 fi
46 echo
47 else
48 echo -n $"Starting UPS monitor (slave): "
49 daemon /usr/sbin/upsmon
50 echo
51 fi
52
53 [ "$RETVAL" = 0 ] && touch /var/lock/subsys/ups
54 }
55
56 stop() {
57 echo -n $"Stopping UPS monitor: "
58 killproc upsmon
59 echo
60
61 if [ "$SERVER" = "yes" ]; then
62 prog="upsd"
63 echo -n $"Stopping $prog: "
64 killproc upsd
65 RETVAL=$?
66 echo
67
68 echo -n $"Shutting down $MODEL: "
69 if [ "$MODEL" = "upsdrvctl" ]; then
70 /sbin/upsdrvctl stop
71 else
72 killproc $MODEL
73 fi
74 echo
75 fi
76 [ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/ups
77 }
78
79 restart() {
80 stop
81 start
82 }
83
84 reload() {
85 # FIXME: upsd and upsmon always return 0
86 # => can't tell if reload was successful
87 if [ "$SERVER" = "yes" ]; then
88 action "Reloading upsd:" /usr/sbin/upsd -c reload
89 RETVAL=$?
90 fi
91 action "Reloading upsmon:" /usr/sbin/upsmon -c reload
92 if [ "$RETVAL" = 0 ]; then
93 RETVAL=$?
94 fi
95 }
96
97 # See how we are called.
98 case "$1" in
99 start)
100 start ;;
101
102 stop)
103 stop ;;
104
105 restart)
106 restart ;;
107
108 try-restart)
109 [ -f /var/lock/subsys/ups ] && restart || :
110 ;;
111
112 reload)
113 reload ;;
114
115 force-reload)
116 restart ;;
117
118 status)
119 if [ "$SERVER" = "yes" ]; then
120 if [ "$MODEL" = "upsdrvctl" ]; then
121 # show status of each configured driver
122 for MYMODEL in $(egrep '^[[:space:]]*driver' /etc/ups/ups.conf \
123 | sed 's/.*=[[:space:]]*//'); do
124 status $MYMODEL
125 done
126 else
127 status $MODEL
128 fi
129 status upsd
130 fi
131 status upsmon
132 ;;
133
134 *)
135 echo $"Usage: $0 {start|stop|restart|try-restart|reload|force-reload|status}"
136 RETVAL=3
137 esac
138
139 exit $RETVAL

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed