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