devd.conf revision 147088
1108983Simp# $FreeBSD: head/etc/devd.conf 147088 2005-06-07 04:49:12Z brooks $ 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# 35147088Sbrooks# For ethernet like devices start configuring the interface. 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 48147088Sbrooks# 49147088Sbrooks# Try to start dhclient on Ethernet like interfaces when the link comes 50147088Sbrooks# up. Only devices that are configured to support DHCP will actually 51147088Sbrooks# run it. No link down rule exists because dhclient automaticly exits 52147088Sbrooks# when the link goes down. 53147088Sbrooks# 54147088Sbrooksnotify 0 { 55147088Sbrooks match "system" "IFNET"; 56147088Sbrooks match "subsystem" "$ethernet-nic-regex"; 57147088Sbrooks match "type" "LINK_UP"; 58147088Sbrooks action "/etc/rc.d/dhclient start $subsystem"; 59147088Sbrooks}; 60147088Sbrooks 61108983Simp# An entry like this might be in a different file, but is included here 62108983Simp# as an example of how to override things. Normally 'ed50' would match 63108983Simp# the above attach/detach stuff, but the value of 100 makes it 64139281Sbrueffer# hard wired to 1.2.3.4. 65108983Simpattach 100 { 66108983Simp device-name "ed50"; 67108983Simp action "ifconfig $device-name inet 1.2.3.4 netmask 0xffff0000"; 68108983Simp}; 69108983Simpdetach 100 { 70108983Simp device-name "ed50"; 71108983Simp}; 72108983Simp 73139281Sbrueffer# When a USB keyboard arrives, attach it as the console keyboard. 74134584Sbrooksattach 100 { 75134584Sbrooks device-name "ukbd0"; 76146086Sbrian action "kbdcontrol -k /dev/ukbd0 < /dev/console && /etc/rc.d/syscons restart"; 77134584Sbrooks}; 78134584Sbrooksdetach 100 { 79134584Sbrooks device-name "ukbd0"; 80134584Sbrooks action "kbdcontrol -k /dev/kbd0 < /dev/console"; 81134584Sbrooks}; 82134584Sbrooks 83138175Siedowse# The entry below starts moused when a mouse is plugged in. Moused 84138175Siedowse# stops automatically (actually it bombs :) when the device disappears. 85138175Siedowseattach 100 { 86138175Siedowse device-name "ums[0-9]+"; 87138175Siedowse action "/etc/rc.d/moused start $device-name"; 88138175Siedowse}; 89138175Siedowse 90108983Simp# 91108983Simp# Rescan scsi device-names on attach, but not detach. 92108983Simp# 93108983Simpattach 0 { 94108983Simp device-name "$scsi-controller-regex"; 95131646Simp// action "camcontrol rescan all"; 96108983Simp}; 97108983Simp 98108983Simp# Don't even try to second guess what to do about drivers that don't 99114799Simp# match here. Instead, pass it off to syslog. Commented out for the 100139281Sbrueffer# moment, as pnpinfo isn't set in devd yet. 101119254Simpnomatch 0 { 102114852Simp# action "logger Unknown device: $pnpinfo $location $bus"; 103119254Simp}; 104108983Simp 105139281Sbrueffer# Switch power profiles when the AC line state changes. 106123626Snjlnotify 10 { 107123626Snjl match "system" "ACPI"; 108123626Snjl match "subsystem" "ACAD"; 109125366Snjl action "/etc/rc.d/power_profile $notify"; 110123626Snjl}; 111123626Snjl 112125366Snjl# Notify all users before beginning emergency shutdown when we get 113125366Snjl# a _CRT or _HOT thermal event and we're going to power down the system 114125366Snjl# very soon. 115125366Snjlnotify 10 { 116125366Snjl match "system" "ACPI"; 117125366Snjl match "subsystem" "Thermal"; 118125366Snjl match "notify" "0xcc"; 119125366Snjl action "logger -p kern.emerg 'WARNING: system temperature too high, shutting down soon!'"; 120125366Snjl}; 121125366Snjl 122108983Simp/* EXAMPLES TO END OF FILE 123108983Simp 124108983Simp# The following might be an example of something that a vendor might 125108983Simp# install if you were to add their device. This might reside in 126108983Simp# /usr/local/etc/devd/deqna.conf. A deqna is, in this hypothetical 127108983Simp# example, a pccard ethernet-like device. Students of history may 128108983Simp# know other devices by this name, and will get the in-jokes in this 129108983Simp# entry. 130108983Simpnomatch 10 { 131108983Simp match "bus" "pccard[0-9]+"; 132108983Simp match "manufacturer" "0x1234"; 133108983Simp match "product" "0x2323"; 134108983Simp action "kldload if_deqna"; 135108983Simp}; 136108983Simpattach 10 { 137108983Simp device-name "deqna[0-9]+"; 138108983Simp action "/etc/pccard_ether $device-name start"; 139108983Simp}; 140108983Simpdetach 10 { 141108983Simp device-name "deqna[0-9]+"; 142108983Simp action "/etc/pccard_ether $device-name stop"; 143108983Simp}; 144108983Simp 145121493Snjl# Examples of notify hooks. A notify is a generic way for a kernel 146121493Snjl# subsystem to send event notification to userland. 147121493Snjl# 148121493Snjl# Here are some examples of ACPI notify handlers. ACPI subsystems that 149121493Snjl# generate notifies include the AC adapter, power/sleep buttons, 150121493Snjl# control method batteries, lid switch, and thermal zones. 151121493Snjl# 152121493Snjl# Information returned is not always the same as the ACPI notify 153121493Snjl# events. See the ACPI specification for more information about 154121493Snjl# notifies. Here is the information returned for each subsystem: 155121493Snjl# 156121493Snjl# ACAD: AC line state (0 is offline, 1 is online) 157121493Snjl# Button: Button pressed (0 for power, 1 for sleep) 158121493Snjl# CMBAT: ACPI battery events 159121493Snjl# Lid: Lid state (0 is closed, 1 is open) 160121493Snjl# Thermal: ACPI thermal zone events 161121493Snjl# 162121493Snjl# This example calls a script when the AC state changes, passing the 163121493Snjl# notify value as the first argument. If the state is 0x00, it might 164121493Snjl# call some sysctls to implement economy mode. If 0x01, it might set 165121493Snjl# the mode to performance. 166121493Snjlnotify 10 { 167121493Snjl match "system" "ACPI"; 168121493Snjl match "subsystem" "ACAD"; 169121493Snjl action "/etc/acpi_ac $notify"; 170121493Snjl}; 171108983Simp*/ 172