Home | History | Annotate | Line # | Download | only in scripts
      1  1.1  jmcneill #!/bin/sh -
      2  1.1  jmcneill #
      3  1.4    jruoho #	$NetBSD: acadapter,v 1.4 2010/12/31 09:29:43 jruoho Exp $
      4  1.1  jmcneill #
      5  1.1  jmcneill # Generic script for acadapter events.
      6  1.1  jmcneill #
      7  1.1  jmcneill # Arguments passed by powerd(8):
      8  1.1  jmcneill #
      9  1.1  jmcneill #	device event
     10  1.1  jmcneill 
     11  1.1  jmcneill case "${2}" in
     12  1.1  jmcneill pressed)
     13  1.1  jmcneill 	logger -p info "${0}: Full performance mode" >&1
     14  1.4    jruoho 
     15  1.4    jruoho 	# Disable power saving mode on all network interfaces.
     16  1.4    jruoho 	#
     17  1.3  pgoyette 	for intf in $(/sbin/ifconfig -l); do
     18  1.1  jmcneill 		/sbin/ifconfig $intf -powersave >/dev/null 2>&1
     19  1.1  jmcneill 	done
     20  1.1  jmcneill 
     21  1.4    jruoho 	# If you want to keep your hard disk idle while running
     22  1.4    jruoho 	# on battery, the following commands will help.
     23  1.1  jmcneill 	#
     24  1.4    jruoho 	# /sbin/atactl wd0 setidle 300
     25  1.4    jruoho 	# /sbin/atactl wd0 setstandby 600
     26  1.4    jruoho 
     27  1.4    jruoho 	# Make sure syslogd is running.
     28  1.1  jmcneill 	#
     29  1.4    jruoho 	# pkill syslogd
     30  1.4    jruoho 	# /etc/rc.d/syslogd start
     31  1.1  jmcneill 
     32  1.4    jruoho 	# Start cron daemon when running on power.
     33  1.4    jruoho 	#
     34  1.4    jruoho 	# /etc/rc.d/cron start
     35  1.1  jmcneill 
     36  1.1  jmcneill 	exit 0
     37  1.1  jmcneill 	;;
     38  1.1  jmcneill 
     39  1.1  jmcneill released)
     40  1.1  jmcneill 	logger -p info "${0}: Power saving mode" >&1
     41  1.1  jmcneill 
     42  1.4    jruoho 	# Enable power saving mode on all network interfaces.
     43  1.4    jruoho 	#
     44  1.3  pgoyette 	for intf in $(/sbin/ifconfig -l); do
     45  1.1  jmcneill 		/sbin/ifconfig $intf powersave >/dev/null 2>&1
     46  1.1  jmcneill 	done
     47  1.1  jmcneill 
     48  1.1  jmcneill 	# When running on battery, we want to keep the disk idle for as long
     49  1.1  jmcneill 	# as possible. Unfortunately, things like cron and syslog make this
     50  1.1  jmcneill 	# very difficult. If you can live without cron or persistent logging,
     51  1.1  jmcneill 	# you can use the commands below to disable cron and syslogd.
     52  1.1  jmcneill 	#
     53  1.1  jmcneill 	# If you still want to see syslog messages, you can create a custom
     54  1.1  jmcneill 	# /etc/syslog.conf.battery that writes messages to /dev/console or
     55  1.4    jruoho 	# possibly a free wsdisplay screen. Alternatively, /var/log could
     56  1.4    jruoho 	# be mounted as tmpfs.
     57  1.4    jruoho 
     58  1.4    jruoho 	# Disk idle timeouts.
     59  1.1  jmcneill 	#
     60  1.4    jruoho 	# /sbin/atactl wd0 setidle 30
     61  1.4    jruoho 	# /sbin/atactl wd0 setstandby 120
     62  1.1  jmcneill 
     63  1.4    jruoho 	# Stop the cron daemon.
     64  1.4    jruoho 	#
     65  1.4    jruoho 	# /etc/rc.d/cron stop
     66  1.1  jmcneill 
     67  1.4    jruoho 	# Restart syslogd using a diskless configuration.
     68  1.4    jruoho 	#
     69  1.4    jruoho 	# pkill syslogd
     70  1.4    jruoho 	# /usr/sbin/syslogd -s -f /etc/syslog.conf.battery
     71  1.1  jmcneill 
     72  1.1  jmcneill 	exit 0
     73  1.1  jmcneill 	;;
     74  1.1  jmcneill 
     75  1.1  jmcneill *)
     76  1.1  jmcneill 	logger -p warning "${0}: unsupported event ${2} on device ${1}" >&1
     77  1.1  jmcneill 	exit 1
     78  1.1  jmcneill 	;;
     79  1.1  jmcneill esac
     80