2 # Awk program to insert the necessary apcupsd script in
5 # Suff left over from a previous apcupsd, remove it
6 /^# See if this is a powerfail situation\./ {
9 } while (length($0) != 0)
11 # We insert our code just before this line
12 /^# Init single-user state if shutdown/ {
13 print "# See if this is a powerfail situation. # ###apcupsd###"
14 print "if [ -f @PWRFAILDIR@/powerfail ]; then # ###apcupsd###"
15 print " echo # ###apcupsd###"
16 print " echo \"APCUPSD will now power off the UPS\" # ###apcupsd###"
17 print " echo # ###apcupsd###"
18 print " @sysconfdir@/apccontrol killpower # ###apcupsd###"
19 print " echo # ###apcupsd###"
20 print " echo \"Please ensure that the UPS has powered off before rebooting\" # ###apcupsd###"
21 print " echo \"Otherwise, the UPS may cut the power during the reboot!!!\" # ###apcupsd###"
22 print " echo # ###apcupsd###"
23 print "fi # ###apcupsd###"
26 # everything else is duplicated