View | Details | Raw Unified
Collapse All | Expand All

(-)/home/yuk/RPM.nut-2.2.2/SOURCES/upsmon.init (-23 / +45 lines)
 Lines 1-5    Link Here 
1
#!/bin/sh
1
#!/bin/sh
2
#
2
#
3
# chkconfig: 2345 87 13
3
# chkconfig: 2345 51 89
4
# description: The UPS drivers
4
# description: The UPS drivers
5
# config: /etc/ups/
5
# config: /etc/ups/
 Lines 12-15    Link Here 
12
# Source service configuration.
12
# Source service configuration.
13
SourceIfNotEmpty /etc/sysconfig/upsd
13
SourceIfNotEmpty /etc/sysconfig/upsd
14
SourceIfNotEmpty /etc/sysconfig/nut
14
15
15
LOCKFILE=/var/lock/subsys/upsdrv
16
LOCKFILE=/var/lock/subsys/upsdrv
 Lines 19-24    Link Here 
19
get_drvlist()
20
get_drvlist()
20
{
21
{
21
	DRVLIST="$((find $CHROOTDIR/ -maxdepth 1 -name '*-*.pid' -type f |
22
	DRVLIST="$((find $PIDDIR/ -maxdepth 1 -name '*-*.pid' -type f |
22
			sed -ne 's,'$CHROOTDIR'/\([^/-]\+\)-[^/-]\+\.pid$,/lib/nut/\1,p';
23
			sed -ne 's,'$PIDDIR'/\([^/-]\+\)-[^/-]\+\.pid$,/lib/nut/\1,p';
23
		    upsdrvctl list 2>/dev/null |grep ^/
24
		    upsdrvctl list 2>/dev/null |grep ^/
24
		   ) |sort -u)"
25
		   ) |sort -u)"
 Lines 37-50    Link Here 
37
stop()
38
stop()
38
{
39
{
39
	local f list rc=0
40
	upsd_configured || return 0
40
	get_drvlist
41
	act="stop"
41
	[ -n "$DRVLIST" ] || rc=3
42
	if [ -f /etc/killpower ]; then
42
	for f in $DRVLIST; do
43
                UPS_SHUTDOWN=${UPS_SHUTDOWN:=9}
43
		msg_stopping $"${f##*/} UPS driver"
44
                if [ $UPS_SHUTDOWN -eq 1 ]; then
44
		stop_daemon --expect-user upsdrv --no-announce -- "$f"
45
                   act="shutdown"
45
		RETVAL=$?
46
                fi
46
		[ "$RETVAL" = 0 ] || rc="$RETVAL"
47
	fi
47
	done
48
48
	RETVAL="$rc"
49
	action "Stopping UPS drivers:" upsdrvctl $UPSDRV_OPTIONS $act
50
	RETVAL=$?
49
	[ $RETVAL -eq 0 ] && rm -f "$LOCKFILE"
51
	[ $RETVAL -eq 0 ] && rm -f "$LOCKFILE"
50
	return $RETVAL
52
	return $RETVAL
 Lines 1-5    Link Here 
1
#!/bin/sh
1
#!/bin/sh
2
#
2
#
3
# chkconfig: 2345 88 12
3
# chkconfig: 2345 52 88
4
# description: The UPS information server
4
# description: The UPS information server
5
# processname: upsd
5
# processname: upsd
 Lines 19-22    Link Here 
19
LOCKFILE=/var/lock/subsys/upsd
19
LOCKFILE=/var/lock/subsys/upsd
20
RETVAL=0
20
RETVAL=0
21
LABEL=upsd
21
22
22
start()
23
start()
 Lines 24-35    Link Here 
24
	upsd_configured || return 0
25
	upsd_configured || return 0
25
26
26
	msg_starting $"UPS information"
27
	#msg_starting $"UPS information"
27
	if ! service upsdrv status >/dev/null 2>&1; then
28
	#if ! service upsdrv status >/dev/null 2>&1; then
28
		msg_not_running $"UPS driver"
29
	#	msg_not_running $"UPS driver"
29
		failure "upsd startup"
30
	#	failure "upsd startup"
30
		RETVAL=$?
31
	#	RETVAL=$?
31
		echo
32
	#	echo
32
		return $RETVAL
33
	#	return $RETVAL
33
	fi
34
	#fi
34
	start_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user upsd --no-announce -- upsd $UPSD_OPTIONS
35
	start_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user upsd --no-announce -- upsd $UPSD_OPTIONS
35
	RETVAL=$?
36
	RETVAL=$?
 Lines 39-43    Link Here 
39
stop()
40
stop()
40
{
41
{
42
43
        LABEL=upsd
41
	msg_stopping $"UPS information"
44
	msg_stopping $"UPS information"
45
	if [ -f /etc/killpower ]; then
46
47
           CONF=/etc/sysconfig/nut
48
           test -f $CONF && . $CONF
49
           UPS_SHUTDOWN=${UPS_SHUTDOWN:=9}
50
           
51
           if [ $UPS_SHUTDOWN -eq 2 ]; then
52
		   logger -t "$LABEL" "Initiated shutdown UPS as $DELAY_MODE."
53
                   UPSNAME=${UPSNAME:=ups}
54
                   UNAME=${UNAME:=upsmon}
55
                   PASSWORD=${PASSWORD:=mypass}
56
                   #logger -t "$LABEL" "upscmd -u $UNAME -p $PASSWORD ${UPS}@localhost shutdown.return"
57
                   upscmd -u $UNAME -p $PASSWORD ${UPSNAME}@localhost shutdown.return
58
                   logger -t "$LABEL" "upscmd shutdown.return exit status: $?"
59
                   sleep 1
60
           fi
61
	fi
42
	stop_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user upsd --no-announce -- upsd
62
	stop_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user upsd --no-announce -- upsd
43
	RETVAL=$?
63
	RETVAL=$?
 Lines 1-5    Link Here 
1
#!/bin/sh
1
#!/bin/sh
2
#
2
#
3
# chkconfig: 2345 89 11
3
# chkconfig: 2345 53 87
4
# description: The UPS monitor and shutdown controller
4
# description: The UPS monitor and shutdown controller
5
# processname: upsmon
5
# processname: upsmon