blob: b51e120849708b1fc065359df5a0ded48ac9fc51 (
plain)
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
|
#!/bin/sh
#
# $NetBSD: upsd,v 1.3 2001/11/21 03:22:05 simonb Exp $
#
# PROVIDE: upsd
# REQUIRE: NETWORK syslogd mountcritremote
# You need to set some parameters for this script in /etc/rc.conf,
# examples are:
#upsd=YES upsd_flags=""
# upsd_dev="/dev/tty01"
# upsd_driver="apcsmart"
#upsmon=YES upsmon_host="localhost"
. /etc/rc.conf
if [ -z "$1" -o "x$1" = xstart ]; then
if [ "x${upsd}" = xYES ]; then
%%PREFIX%%/sbin/ups-drivers/${upsd_driver} ${upsd_flags} ${upsd_dev}
%%PREFIX%%/sbin/upsd
fi
if [ "x${upsmon}" = xYES ]; then
%%PREFIX%%/sbin/upsmon ${upsmon_host}
fi
elif [ "x$1" = xstop ]; then
echo "Stopping upsd - caveat, this may not work if multiple instances are running"
dpid=`ps ax | fgrep %%PREFIX%%/sbin/ups-drivers/${upsd_driver} | fgrep -v fgrep | awk '{print $1}'`
upid=`ps ax | fgrep %%PREFIX%%/sbin/upsd | fgrep -v fgrep | awk '{print $1}'`
if [ ! -z "${upid}" ]; then
kill ${upid}
fi
if [ ! -z "${dpid}" ]; then
kill ${dpid}
fi
if [ -r /var/run/upsmon.pid ]; then
mpid=`/bin/cat /var/run/upsmon.pid`
kill ${mpid}
fi
fi
|