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