summaryrefslogtreecommitdiffstats
path: root/main/apcupsd/apcupsd-alpine.patch
blob: fb4412604bb800234089a26500cd75aa6fb6bf3b (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
--- ./platforms/apccontrol.in.orig	2014-03-22 16:55:26.000000000 +0000
+++ ./platforms/apccontrol.in	2014-05-01 08:35:12.652406970 +0000
@@ -20,10 +20,19 @@
 
 APCPID=@PIDDIR@/apcupsd.pid
 APCUPSD=@sbindir@/apcupsd
-SHUTDOWN=@SHUTDOWN@
+POWEROFF=/sbin/poweroff
+REBOOT=/sbin/reboot
 SCRIPTSHELL=@SCRIPTSHELL@
 SCRIPTDIR=@sysconfdir@
-WALL=wall
+WALL=_wall
+
+_wall() {
+   local i
+   local msg=$(cat)
+   for i in /dev/pts/*; do
+       [ -c "$i" ] && echo "$msg" > $i
+   done
+}
 
 export SYSADMIN=root
 export APCUPSD_MAIL="@APCUPSD_MAIL@"
@@ -104,11 +113,13 @@
     ;;
     doreboot)
 	echo "UPS ${2} initiating Reboot Sequence" | ${WALL}
-	${SHUTDOWN} -r now "apcupsd UPS ${2} initiated reboot"
+	echo "apcupsd UPS ${2} initiated reboot" | ${WALL}
+	$REBOOT
     ;;
     doshutdown)
 	echo "UPS ${2} initiated Shutdown Sequence" | ${WALL}
-	${SHUTDOWN} -h now "apcupsd UPS ${2} initiated shutdown"
+	echo "apcupsd UPS ${2} initiated shutdown" | ${WALL}
+	$POWEROFF
     ;;
     annoyme)
 	echo "Power problems with UPS ${2}. Please logoff." | ${WALL}