devd.conf revision 146969
1108983Simp# $FreeBSD: head/etc/devd.conf 146969 2005-06-04 21:05:37Z marius $
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.
20130151Sschweikh	set ethernet-nic-regex
21146548Ssobomax		"(an|ar|ath|aue|awi|axe|bfe|bge|cdce|cm|cnw|cs|cue|dc|de|ed|el|em|\
22139027Sbrueffer		ep|ex|fe|fxp|gem|hme|ie|kue|lge|lnc|my|nge|pcn|ray|re|rl|rue|\
23139027Sbrueffer		sf|sis|sk|sn|snc|ste|ti|tl|tx|txp|udav|vge|vr|vx|wb|wi|xe|xl)\
24139027Sbrueffer		[0-9]+";
25108983Simp	set scsi-controller-regex
26139027Sbrueffer		"(aac|adv|adw|aha|ahb|ahc|ahd|aic|amd|amr|asr|bt|ciss|ct|dpt|\
27146969Smarius		esp|ida|iir|ips|isp|mlx|mly|mpt|ncr|ncv|nsp|stg|sym|trm|wds)\
28139027Sbrueffer		[0-9]+";
29108983Simp};
30108983Simp
31108983Simp# Note that the attach/detach with the highest value wins, so that one can
32108983Simp# override these general rules.
33108983Simp
34108983Simp#
35108983Simp# For ethernet like devices, the default is to run dhclient.  Due to
36126905Scperciva# a historical accident, this script is called pccard_ether.
37108983Simp#
38108983Simpattach 0 {
39108983Simp	device-name "$ethernet-nic-regex";
40108983Simp	action "/etc/pccard_ether $device-name start";
41108983Simp};
42108983Simp
43108983Simpdetach 0 {
44108983Simp	device-name "$ethernet-nic-regex";
45108983Simp	action "/etc/pccard_ether $device-name stop";
46108983Simp};
47108983Simp
48108983Simp# An entry like this might be in a different file, but is included here
49108983Simp# as an example of how to override things.  Normally 'ed50' would match
50108983Simp# the above attach/detach stuff, but the value of 100 makes it
51139281Sbrueffer# hard wired to 1.2.3.4.
52108983Simpattach 100 {
53108983Simp	device-name "ed50";
54108983Simp	action "ifconfig $device-name inet 1.2.3.4 netmask 0xffff0000";
55108983Simp};
56108983Simpdetach 100 {
57108983Simp	device-name "ed50";
58108983Simp};
59108983Simp
60139281Sbrueffer# When a USB keyboard arrives, attach it as the console keyboard.
61134584Sbrooksattach 100 {
62134584Sbrooks	device-name "ukbd0";
63146086Sbrian	action "kbdcontrol -k /dev/ukbd0 < /dev/console && /etc/rc.d/syscons restart";
64134584Sbrooks};
65134584Sbrooksdetach 100 {
66134584Sbrooks	device-name "ukbd0";
67134584Sbrooks	action "kbdcontrol -k /dev/kbd0 < /dev/console";
68134584Sbrooks};
69134584Sbrooks
70138175Siedowse# The entry below starts moused when a mouse is plugged in. Moused
71138175Siedowse# stops automatically (actually it bombs :) when the device disappears.
72138175Siedowseattach 100 {
73138175Siedowse	device-name "ums[0-9]+";
74138175Siedowse	action "/etc/rc.d/moused start $device-name";
75138175Siedowse};
76138175Siedowse
77108983Simp#
78108983Simp# Rescan scsi device-names on attach, but not detach.
79108983Simp#
80108983Simpattach 0 {
81108983Simp	device-name "$scsi-controller-regex";
82131646Simp//	action "camcontrol rescan all";
83108983Simp};
84108983Simp
85108983Simp# Don't even try to second guess what to do about drivers that don't
86114799Simp# match here.  Instead, pass it off to syslog.  Commented out for the
87139281Sbrueffer# moment, as pnpinfo isn't set in devd yet.
88119254Simpnomatch 0 {
89114852Simp#	action "logger Unknown device: $pnpinfo $location $bus";
90119254Simp};
91108983Simp
92139281Sbrueffer# Switch power profiles when the AC line state changes.
93123626Snjlnotify 10 {
94123626Snjl	match "system"		"ACPI";
95123626Snjl	match "subsystem"	"ACAD";
96125366Snjl	action "/etc/rc.d/power_profile $notify";
97123626Snjl};
98123626Snjl
99125366Snjl# Notify all users before beginning emergency shutdown when we get
100125366Snjl# a _CRT or _HOT thermal event and we're going to power down the system
101125366Snjl# very soon.
102125366Snjlnotify 10 {
103125366Snjl	match "system"		"ACPI";
104125366Snjl	match "subsystem"	"Thermal";
105125366Snjl	match "notify"		"0xcc";
106125366Snjl	action "logger -p kern.emerg 'WARNING: system temperature too high, shutting down soon!'";
107125366Snjl};
108125366Snjl
109108983Simp/* EXAMPLES TO END OF FILE
110108983Simp
111108983Simp# The following might be an example of something that a vendor might
112108983Simp# install if you were to add their device.  This might reside in
113108983Simp# /usr/local/etc/devd/deqna.conf.  A deqna is, in this hypothetical
114108983Simp# example, a pccard ethernet-like device.  Students of history may
115108983Simp# know other devices by this name, and will get the in-jokes in this
116108983Simp# entry.
117108983Simpnomatch 10 {
118108983Simp	match "bus" "pccard[0-9]+";
119108983Simp	match "manufacturer" "0x1234";
120108983Simp	match "product" "0x2323";
121108983Simp	action "kldload if_deqna";
122108983Simp};
123108983Simpattach 10 {
124108983Simp	device-name "deqna[0-9]+";
125108983Simp	action "/etc/pccard_ether $device-name start";
126108983Simp};
127108983Simpdetach 10 {
128108983Simp	device-name "deqna[0-9]+";
129108983Simp	action "/etc/pccard_ether $device-name stop";
130108983Simp};
131108983Simp
132121493Snjl# Examples of notify hooks.  A notify is a generic way for a kernel
133121493Snjl# subsystem to send event notification to userland.
134121493Snjl#
135121493Snjl# Here are some examples of ACPI notify handlers.  ACPI subsystems that
136121493Snjl# generate notifies include the AC adapter, power/sleep buttons,
137121493Snjl# control method batteries, lid switch, and thermal zones.
138121493Snjl#
139121493Snjl# Information returned is not always the same as the ACPI notify
140121493Snjl# events.  See the ACPI specification for more information about
141121493Snjl# notifies.  Here is the information returned for each subsystem:
142121493Snjl#
143121493Snjl# ACAD:		AC line state (0 is offline, 1 is online)
144121493Snjl# Button:	Button pressed (0 for power, 1 for sleep)
145121493Snjl# CMBAT:	ACPI battery events
146121493Snjl# Lid:		Lid state (0 is closed, 1 is open)
147121493Snjl# Thermal:	ACPI thermal zone events
148121493Snjl#
149121493Snjl# This example calls a script when the AC state changes, passing the
150121493Snjl# notify value as the first argument.  If the state is 0x00, it might
151121493Snjl# call some sysctls to implement economy mode.  If 0x01, it might set
152121493Snjl# the mode to performance.
153121493Snjlnotify 10 {
154121493Snjl	match "system"		"ACPI";
155121493Snjl	match "subsystem"	"ACAD";
156121493Snjl	action			"/etc/acpi_ac $notify";
157121493Snjl};
158108983Simp*/
159