Remove lfs-uefi.txt symlink
[linux_from_scratch_hints.git] / PREVIOUS_FORMAT / acpid.txt
blob54fd19bd00ca2444ca80d1f3256d35619d58502b
1 TITLE:          ACPID hint
2 LFS VERSION:    3.3 - 4
3 Author:         Paul Warren <u3292467@student.anu.edu.au>
5 SYNOPSIS:
6         How to get your shiny LFS box to shutdown when you press the
7         power button.
10 HINT:
12 ACPI [1] is the advanced Configuration and Power interface.  It
13 basically is an upgrade of the old Advanced Power Management
14 interface, and allows for much more flexibility in configuring actions
15 to certain events.
17 The ACPI Daemon is a user space daemon that reacts to these events
18 through the /proc interface.
20 To get the package fire this link up in your browser and choose your
21 favourite sourceforge mirror.
23 http://prdownloads.sourceforge.net/acpid/acpid-1.0.1.tar.gz?download
25 Or use wget on :
27 http://umn.dl.sourceforge.net/sourceforge/acpid/acpid-1.0.1.tar.gz
30 First of all you need to ensure your motherboard and power supply
31 supports the ACPI standard.  Most models post 2000 should be Ok, as
32 well as a few before that, check your manufacturers documentation though.
34 ACPID should be used in conjunction with kernels greater than 2.4.8,
35 but versions before that can be patched with the latest ACPI drivers.
36 This shouldn't be a concern for LFS people, with linux-2.4.19 as
37 standard.
39 Next step is to ensure that your kernel has the drivers loaded, either
40 in the kernel proper or as modules. 
41 [*] Power Management support
42 [*]   ACPI support (NEW)
43 [ ]     ACPI Debug Statements (NEW)
44 <M>     ACPI Bus Manager (NEW)
45 <M>       System
46 <M>       Processor
47 <M>       Button
48 < >       AC Adapter
49 < >       Embedded Controller              
51 If  you're on a laptop you can add in AC Adaptor and Embedded
52 Controller. 
54 The usual procedures apply for installing your new kernel and
55 modules.  The modules are called:
56 ospm_busmgr
57 ospm_system
58 ospm_processor
59 ospm_button
61 I'm not sure about the AC adaptor and Embedded Controller, because
62 I don't have a laptop to test it on.
64 So do something like the following if you are using BSD style init. 
66 cat >> /etc/rc.d/rc.modules << "EOF"
67 modprobe ospm_busmgr
68 modprobe ospm_system
69 modprobe ospm_processor
70 modprobe ospm_button
71 EOF
73 and this for sysvinit.  Thanks to DĂȘnis Volpato Martins
75 cat > $rc_base/init.d/acpid << "EOF"
76 #!/bin/bash
77 # Begin $rc_base/init.d/acpid
79 # Based on sysklogd script from LFS-3.1 and earlier.
80 # Rewritten by DĂȘnis Volpato Martins  - dvm@linux-sc.org
81 # based on acpid hint
83 source /etc/sysconfig/rc
84 source $rc_functions
86 case "$1" in
87         start)
88                 echo "Starting acpid..."
89                 modprobe ospm_busmgr
90                 modprobe ospm_system
91                 modprobe ospm_processor
92                 modprobe ospm_button
94                 loadproc acpid
95                 ;;
97         stop)
98                 echo "Stopping acpid..."
99                 killproc acpid
100                 ;;
102         reload)
103                 echo "Reloading acpid..."
104                 reloadproc acpid 1
105                 ;;
107         restart)
108                 $0 stop
109                 sleep 1
110                 $0 start
111                 ;;
113         status)
114                 statusproc acpid
115                 ;;
117         *)
118                 echo "Usage: $0 {start|stop|reload|restart|status}"
119                 exit 1
120                 ;;
121 esac
123 # End $rc_base/init.d/acpid
126 there is some symlinking to do here, but I'm not sure how that works
127 either. Will research it one day.
130 Next, on to the ACPI Daemon.  The source requires no ./configure, as
131 it only depends on the kernel, so do a 
133 make &&  make install
135 as root.
137 Now for the configuring.
139 We need to make an acpi directory under /etc, and an events directory
140 under that.
142 mkdir -p /etc/acpi/events
144 First of all is the event Handler.
146 cat > /etc/acpi/acpi_handler.sh << "EOF"
147 #!/bin/sh
148 # Default acpi script that takes an entry for all actions
150 set $*
152 case "$1" in
153   button)
154     case "$2" in
155    power)  /sbin/init 0
156         ;;
157        *)      logger "ACPI action $2 is not defined"
158         ;;
159     esac
160         ;;
161        *)      logger "ACPI group $1 / action $2 is not defined"
162         ;;
163 esac
165 chmod 755 /etc/acpi/event_handler.sh
168 next, an events file
170 cat > /etc/acpi/events/default << "EOF"
171 # This is the ACPID default configuration, it takes all
172 # events and passes them to /etc/acpi/default.sh for further
173 # processing.
175 # event keeps a regular expression matching the event. To get
176 # power events only, just use something like "event=button power.*"
177 # to catch it.
178 # action keeps the command to be executed after an event occurs
179 #This halts the computer when the Power button is pressed.
181 event=button power.*
182 action=/sbin/shutdown -h now
184 # Optionally you can specify the placeholder %e. It will pass
185 # through the whole kernel event message to the program you've
186 # specified.
188 event=.*
189 action=/etc/acpi/acpi_handler.sh %e
191 chmod 755 /etc/acpi/events/default
194 you can add actions for other events.
196 And now you can run, as root
197 # acpid
199 To get acpid to run on boot, add /usr/sbin/acpid into your rc.local
200 file. Or use the above rc.acpid for sysvinit.
202 Test if it works by pressing your power button.  I've never
203 experienced any problems with doing this. But email me if you get into
204 trouble.
208 [1] http://www.acpi.info/index.html