UPS: apcupsd clean sources
[tomato.git] / release / src / router / apcupsd / examples / offbattery.cpufreq
blob85c3194206679c7c57550f514384ba3c6b2c36d8
1 #!/bin/sh
3 # This shell script if placed in /etc/apcupsd will be
4 # called by /etc/apcupsd/apccontrol when the UPS goes
5 # back on to the mains after a power failure.
7 # We scale the CPU clock frequency to maximum and
8 # send an email message to root to notify him.
10 # NOTE: Assumes Linux-2.6.x kernel with CPUFREQ
11 # support for your chipset.
12 SYSADMIN=root
13 APCUPSD_MAIL="/bin/mail"
15 # Iterate over all CPUs, enabling the userspace governor
16 # and programming the current clock speed to the maximum.
17 # This is redundant on hyperthread siblings, but it
18 # doesn't hurt anything and it keeps the code simple.
19 for CPU in /sys/devices/system/cpu/cpu*/cpufreq ; do
20 echo -n userspace > $CPU/scaling_governor
21 cat $CPU/scaling_max_freq > $CPU/scaling_setspeed
22 done
24 # Send an email to root
25 HOSTNAME=`hostname`
26 MSG="$HOSTNAME Power has returned"
29 echo "Subject: $MSG"
30 echo " "
31 echo "$MSG"
32 echo " "
33 for CPU in `ls -1 /sys/devices/system/cpu` ; do
34 echo -n "$CPU freq scaled to "
35 cat /sys/devices/system/cpu/$CPU/cpufreq/scaling_setspeed | tr -d '\n'
36 echo " MHz"
37 done
38 echo " "
39 /sbin/apcaccess status
40 ) | $APCUPSD_MAIL -s "$MSG" $SYSADMIN
41 exit 0