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