devd.conf revision 152326
1108983Simp# $FreeBSD: head/etc/devd.conf 152326 2005-11-12 03:42:56Z emax $
2108983Simp#
3108983Simp# Refer to devd.conf(5) and devd(8) man pages for the details on how to
4108983Simp# run and configure devd.
5108983Simp#
6108983Simp
7108983Simp# NB: All regular expressions have an implicit ^$ around them.
8108983Simp# NB: device-name is shorthand for 'match device-name'
9108983Simp
10108983Simpoptions {
11108983Simp	# Each directory directive adds a directory the list of directories
12108983Simp	# that we scan for files.  Files are read-in in the order that they
13108983Simp	# are returned from readdir(3).  The rule-sets are combined to
14108983Simp	# create a DFA that's used to match events to actions.
15108983Simp	directory "/etc/devd";
16108983Simp	directory "/usr/local/etc/devd";
17108983Simp	pid-file "/var/run/devd.pid";
18108983Simp
19108983Simp	# Setup some shorthand for regex that we use later in the file.
20148471Simp	#XXX Yes, these are gross -- imp
21108983Simp	set scsi-controller-regex
22139027Sbrueffer		"(aac|adv|adw|aha|ahb|ahc|ahd|aic|amd|amr|asr|bt|ciss|ct|dpt|\
23146969Smarius		esp|ida|iir|ips|isp|mlx|mly|mpt|ncr|ncv|nsp|stg|sym|trm|wds)\
24139027Sbrueffer		[0-9]+";
25108983Simp};
26108983Simp
27108983Simp# Note that the attach/detach with the highest value wins, so that one can
28108983Simp# override these general rules.
29108983Simp
30108983Simp#
31147088Sbrooks# For ethernet like devices start configuring the interface.  Due to
32126905Scperciva# a historical accident, this script is called pccard_ether.
33108983Simp#
34108983Simpattach 0 {
35148642Ssam	media-type "ethernet";
36108983Simp	action "/etc/pccard_ether $device-name start";
37108983Simp};
38108983Simp
39108983Simpdetach 0 {
40148642Ssam	media-type "ethernet";
41108983Simp	action "/etc/pccard_ether $device-name stop";
42108983Simp};
43108983Simp
44147088Sbrooks#
45147088Sbrooks# Try to start dhclient on Ethernet like interfaces when the link comes
46147088Sbrooks# up.  Only devices that are configured to support DHCP will actually
47147088Sbrooks# run it.  No link down rule exists because dhclient automaticly exits
48147088Sbrooks# when the link goes down.
49147088Sbrooks#
50147088Sbrooksnotify 0 {
51147088Sbrooks	match "system"		"IFNET";
52147088Sbrooks	match "type"		"LINK_UP";
53148642Ssam	media-type		"ethernet";
54147088Sbrooks	action "/etc/rc.d/dhclient start $subsystem";
55147088Sbrooks};
56147088Sbrooks
57148642Ssam#
58148642Ssam# Like Ethernet devices, but separate because
59148642Ssam# they have a different media type.  We may want
60148642Ssam# to exploit this later.
61148642Ssam#
62148642Ssamdetach 0 {
63148642Ssam	media-type "802.11";
64148642Ssam	action "/etc/pccard_ether $device-name stop";
65148642Ssam};
66148642Ssamattach 0 {
67148642Ssam	media-type "802.11";
68148642Ssam	action "/etc/pccard_ether $device-name start";
69148642Ssam};
70148642Ssamnotify 0 {
71148642Ssam	match "system"		"IFNET";
72148642Ssam	match "type"		"LINK_UP";
73148642Ssam	media-type		"802.11";
74148642Ssam	action "/etc/rc.d/dhclient start $subsystem";
75148642Ssam};
76148642Ssam
77108983Simp# An entry like this might be in a different file, but is included here
78108983Simp# as an example of how to override things.  Normally 'ed50' would match
79108983Simp# the above attach/detach stuff, but the value of 100 makes it
80139281Sbrueffer# hard wired to 1.2.3.4.
81108983Simpattach 100 {
82108983Simp	device-name "ed50";
83108983Simp	action "ifconfig $device-name inet 1.2.3.4 netmask 0xffff0000";
84108983Simp};
85108983Simpdetach 100 {
86108983Simp	device-name "ed50";
87108983Simp};
88108983Simp
89152326Semax# When a USB Bluetooth dongle appears activate it
90152326Semaxattach 100 {
91152326Semax	device-name "ubt[0-9]+";
92152326Semax	action "/etc/rc.d/bluetooth start $device-name";
93152326Semax};
94152326Semaxdetach 100 {
95152326Semax	device-name "ubt[0-9]+";
96152326Semax	action "/etc/rc.d/bluetooth stop $device-name";
97152326Semax};
98152326Semax
99139281Sbrueffer# When a USB keyboard arrives, attach it as the console keyboard.
100134584Sbrooksattach 100 {
101134584Sbrooks	device-name "ukbd0";
102146086Sbrian	action "kbdcontrol -k /dev/ukbd0 < /dev/console && /etc/rc.d/syscons restart";
103134584Sbrooks};
104134584Sbrooksdetach 100 {
105134584Sbrooks	device-name "ukbd0";
106134584Sbrooks	action "kbdcontrol -k /dev/kbd0 < /dev/console";
107134584Sbrooks};
108134584Sbrooks
109138175Siedowse# The entry below starts moused when a mouse is plugged in. Moused
110138175Siedowse# stops automatically (actually it bombs :) when the device disappears.
111138175Siedowseattach 100 {
112138175Siedowse	device-name "ums[0-9]+";
113138175Siedowse	action "/etc/rc.d/moused start $device-name";
114138175Siedowse};
115138175Siedowse
116108983Simp#
117148471Simp# Rescan scsi device-names on attach, but not detach.  However, it is
118148471Simp# disabled by default due to reports of problems.
119108983Simp#
120108983Simpattach 0 {
121108983Simp	device-name "$scsi-controller-regex";
122131646Simp//	action "camcontrol rescan all";
123108983Simp};
124108983Simp
125108983Simp# Don't even try to second guess what to do about drivers that don't
126114799Simp# match here.  Instead, pass it off to syslog.  Commented out for the
127139281Sbrueffer# moment, as pnpinfo isn't set in devd yet.
128119254Simpnomatch 0 {
129114852Simp#	action "logger Unknown device: $pnpinfo $location $bus";
130119254Simp};
131108983Simp
132139281Sbrueffer# Switch power profiles when the AC line state changes.
133123626Snjlnotify 10 {
134123626Snjl	match "system"		"ACPI";
135123626Snjl	match "subsystem"	"ACAD";
136125366Snjl	action "/etc/rc.d/power_profile $notify";
137123626Snjl};
138123626Snjl
139125366Snjl# Notify all users before beginning emergency shutdown when we get
140125366Snjl# a _CRT or _HOT thermal event and we're going to power down the system
141125366Snjl# very soon.
142125366Snjlnotify 10 {
143125366Snjl	match "system"		"ACPI";
144125366Snjl	match "subsystem"	"Thermal";
145125366Snjl	match "notify"		"0xcc";
146125366Snjl	action "logger -p kern.emerg 'WARNING: system temperature too high, shutting down soon!'";
147125366Snjl};
148125366Snjl
149108983Simp/* EXAMPLES TO END OF FILE
150108983Simp
151108983Simp# The following might be an example of something that a vendor might
152108983Simp# install if you were to add their device.  This might reside in
153108983Simp# /usr/local/etc/devd/deqna.conf.  A deqna is, in this hypothetical
154108983Simp# example, a pccard ethernet-like device.  Students of history may
155108983Simp# know other devices by this name, and will get the in-jokes in this
156108983Simp# entry.
157108983Simpnomatch 10 {
158108983Simp	match "bus" "pccard[0-9]+";
159108983Simp	match "manufacturer" "0x1234";
160108983Simp	match "product" "0x2323";
161108983Simp	action "kldload if_deqna";
162108983Simp};
163108983Simpattach 10 {
164108983Simp	device-name "deqna[0-9]+";
165108983Simp	action "/etc/pccard_ether $device-name start";
166108983Simp};
167108983Simpdetach 10 {
168108983Simp	device-name "deqna[0-9]+";
169108983Simp	action "/etc/pccard_ether $device-name stop";
170108983Simp};
171108983Simp
172121493Snjl# Examples of notify hooks.  A notify is a generic way for a kernel
173121493Snjl# subsystem to send event notification to userland.
174121493Snjl#
175121493Snjl# Here are some examples of ACPI notify handlers.  ACPI subsystems that
176121493Snjl# generate notifies include the AC adapter, power/sleep buttons,
177121493Snjl# control method batteries, lid switch, and thermal zones.
178121493Snjl#
179121493Snjl# Information returned is not always the same as the ACPI notify
180121493Snjl# events.  See the ACPI specification for more information about
181121493Snjl# notifies.  Here is the information returned for each subsystem:
182121493Snjl#
183121493Snjl# ACAD:		AC line state (0 is offline, 1 is online)
184121493Snjl# Button:	Button pressed (0 for power, 1 for sleep)
185121493Snjl# CMBAT:	ACPI battery events
186121493Snjl# Lid:		Lid state (0 is closed, 1 is open)
187121493Snjl# Thermal:	ACPI thermal zone events
188121493Snjl#
189121493Snjl# This example calls a script when the AC state changes, passing the
190121493Snjl# notify value as the first argument.  If the state is 0x00, it might
191121493Snjl# call some sysctls to implement economy mode.  If 0x01, it might set
192121493Snjl# the mode to performance.
193121493Snjlnotify 10 {
194121493Snjl	match "system"		"ACPI";
195121493Snjl	match "subsystem"	"ACAD";
196121493Snjl	action			"/etc/acpi_ac $notify";
197121493Snjl};
198108983Simp*/
199