summaryrefslogtreecommitdiff
path: root/sysutils/apcupsd/patches/patch-ai
blob: 30a38aa75c9e2f95294bb0b3219c9168df59e8b3 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
$NetBSD: patch-ai,v 1.1.1.1 2000/01/21 19:16:00 bouyer Exp $

--- installs/powersc.orig	Tue Jul 20 18:58:51 1999
+++ installs/powersc	Tue Jul 20 19:14:13 1999
@@ -4,25 +4,9 @@
 POWERPID=/var/run/power.pid
 APCPID=/var/run/apcupsd.pid
 
-if [ -x /sbin/shutdown ]; then
 	SHUTDOWN=/sbin/shutdown
-elif [ -x /sbin/shutdown.bsd ]; then
-	SHUTDOWN=/sbin/shutdown.bsd
-else
-	echo Command shutdown or shutdown.bsd not found!
-	exit 1
-fi
 
-if [ -x /usr/local/sbin/apcupsd ]; then
-	APCUPSD=/usr/local/sbin/apcupsd
-elif [ -x /usr/sbin/apcupsd ]; then
-	APCUPSD=/usr/sbin/apcupsd
-elif [ -x /sbin/apcupsd ]; then
-	APCUPSD=/sbin/apcupsd
-else
-	echo Command apcupsd not found!
-	exit 1
-fi
+	APCUPSD=@@PREFIX@@/sbin/apcupsd
 
 if test "$(whoami)" != "root"; then
 	printf "Sorry, you must be root to run this script." | wall
@@ -32,42 +16,52 @@
 case "$1" in
 	POWEROUT)
 		printf "Warning there are Power problems." | wall
+		/usr/bin/logger -p user.info -t apcupsd \
+			"Warning there are Power problems."
 		;;
 	ONBATTERY)
 		printf "Power Failure running on UPS." | wall
+		/usr/bin/logger -p user.info -t apcupsd \
+			"Power Failure running on UPS."
 		;;
 	FAILING)
 		printf "Battery Power Failed, Normal Shutdown.\n" | wall
+		/usr/bin/logger -p user.emerg -t apcupsd \
+			"UPS Battery Power Failed, Normal Shutdown."
 		;;
 	TIMEOUT)
 		printf "Online Battery timeout, Normal Shutdown.\n" | wall
+		/usr/bin/logger -p user.emerg -t apcupsd \
+			"UPS Online Battery timeout, Normal Shutdown."
 		;;
 	LOADLIMIT)
 		printf "Battery Load Limits Reached, Normal Shutdown.\n" | wall
+		/usr/bin/logger -p user.emerg -t apcupsd \
+			"UPS Battery Load Limits Reached, Normal Shutdown."
 		;;
 	RUNLIMIT)
 		printf "Battery RunTime Limits Reached, Normal Shutdown.\n" | wall
+		/usr/bin/logger -p user.emerg -t apcupsd \
+			"Battery RunTime Limits Reached, Normal Shutdown."
 		;;
 	DOSHUTDOWN)
 		printf "Beginning Shutdown Sequence!!!!!" | wall
-		ps x | gawk '{ if (($5 == "init") && ($1 == "1")) print $6 }' \
-			| cut -f2 -d[ | cut -f1 -d] \
-			> /tmp/run.level.power
 		if [ -f $POWERPID ]
 		then
 			exit 0
 		else
 			echo $$ > $POWERPID
-			$SHUTDOWN -h now
+			$SHUTDOWN -h now "UPS Powerfail"
 		fi
 		;;
 	MAINSBACK | WAITASEC)
 		printf "Power has returned..." | wall
+		/usr/bin/logger -p user.info -t apcupsd \
+			"Power has returned..."
 		if [ -f $POWERPID ]; then
 			printf "Attempting to cancel shutdown."
 			kill $(cat $POWERPID)
 			rm -f $POWERPID
-			init $(cat /tmp/run.level.power)
 		fi
 		;;
 	ANNOYME)
@@ -75,14 +69,20 @@
 		;;
 	EMERGENCY)
 		printf "Emergency Shutdown, Possible Battery Failure!!!!" | wall
-		$SHUTDOWN -h now
+		/usr/bin/logger -p user.emerg -t apcupsd \
+			"Emergency Shutdown, Possible Battery Failure!!!!"
+		$SHUTDOWN -h now "Emergency Shutdown"
 		;;
 	CHANGEME)
 		printf "Emergency, Batteries Have Failed!!!!\nChange Them NOW!!!!" | wall
+		/usr/bin/logger -p user.emerg -t apcupsd \
+		    "Emergency, Batteries Have Failed!!!! Change Them NOW!!!!"
 		;;
 	REMOTE)
 		printf "Remote Calls, Normal Shutdown.\nBeginning Shutdown Sequence!!!!!" | wall
-		$SHUTDOWN -h now
+		/usr/bin/logger -p user.emerg -t apcupsd \
+		    "Remote Calls, Normal Shutdown"
+		$SHUTDOWN -h now "Remote Calls, Normal Shutdown"
 		;;
 	KILL)	sleep 1
 		$APCUPSD killpower