/[livecd-tools]/trunk/autoconfig
Gentoo

Contents of /trunk/autoconfig

Parent Directory Parent Directory | Revision Log Revision Log


Revision 130 - (hide annotations) (download)
Tue Sep 4 21:26:15 2007 UTC (10 years, 7 months ago) by wolf31o2
File size: 10002 byte(s)
Move coldplugging/hotplugging/firmware unpacking before any other hardware detection.  This should fix the problems with firmware not being available prior to the modules being loaded.  This is for bug #191087.
1 zhen 2 #!/sbin/runscript
2 zhen 4
3 zhen 2 DHCP="yes"
4     DETECT="yes"
5 wolf31o2 24 GPM="yes"
6 zhen 2 PCMCIA="no"
7     HOTPLUG="yes"
8     APM="no"
9     ACPI="no"
10 wolf31o2 49 IDEDMA="yes"
11 wolf31o2 68 ALSA="yes"
12 wolf31o2 76 X11="yes"
13 wolf31o2 51
14 wolf31o2 68 get_config() {
15     CMDLINE="$(cat /proc/cmdline)"
16 wolf31o2 51
17 wolf31o2 68 for x in ${CMDLINE} ; do
18 wolf31o2 78 case "${x}" in
19     nodetect)
20     DETECT="no"
21     GPM="no"
22     HOTPLUG="no"
23     APM="no"
24     ACPI="no"
25     ALSA="no"
26     X11="no"
27     ;;
28     nodhcp)
29     DHCP="no"
30     ;;
31     nogpm)
32     GPM="no"
33     ;;
34     dopcmcia)
35     PCMCIA="yes"
36     ;;
37     doapm)
38     APM="yes"
39     ACPI="no"
40     ;;
41 wolf31o2 122 acpi\=on|acpi\=force)
42 wolf31o2 78 APM="no"
43     ACPI="yes"
44     ;;
45 wolf31o2 122 ide\=nodma)
46 wolf31o2 78 IDEDMA="no"
47     ;;
48     nohotplug)
49     HOTPLUG="no"
50     ;;
51     nosound)
52     ALSA="no"
53     ;;
54     nox)
55     X11="no"
56     ;;
57     esac
58 wolf31o2 68 done
59     }
60    
61 zhen 2 depend() {
62     need modules
63 wolf31o2 50 before net
64 wolf31o2 115 # provide gpm pcmcia apmd acpid coldplug hdparm alsasound mkxf86config x-setup
65 zhen 2 }
66    
67 wolf31o2 69 # Checks whether a service will be started by autoconfig.
68     # Usage: check_svc var service [service_alternative]
69     check_svc() {
70 wolf31o2 113 if [ "${1}" = "yes" ]
71 wolf31o2 78 then
72 wolf31o2 114 if [ -x "/etc/init.d/${2}" ]
73 wolf31o2 78 then
74 wolf31o2 113 echo "${2}"
75     elif [ -n "${3}" -a -x "/etc/init.d/${3}" ]
76 wolf31o2 78 then
77 wolf31o2 113 echo "${3}"
78 wolf31o2 69 fi
79     fi
80     }
81    
82     # Prints an ordered list of services that will be started by autoconfig.
83     list_services() {
84     get_config
85    
86     local svcs="$(check_svc ${APM} apmd)"
87     svcs="${svcs} $(check_svc ${ACPI} acpid)"
88     svcs="${svcs} $(check_svc ${IDEDMA} hdparm)"
89     svcs="${svcs} $(check_svc ${PCMCIA} pcmcia)"
90     svcs="${svcs} $(check_svc ${GPM} gpm)"
91     svcs="${svcs} $(check_svc ${HOTPLUG} coldplug hotplug)"
92     svcs="${svcs} $(check_svc ${ALSA} alsasound)"
93 wolf31o2 115 svcs="${svcs} $(check_svc ${X11} mkxf86config x-setup)"
94 wolf31o2 69
95     echo ${svcs}
96     }
97    
98 wolf31o2 101 unpack_firmware() {
99     # This unpacks any firmware tarballs.
100     # This has been moved here from coldplug, but might not be very effective
101     # since udev does coldplugging in 089 and higher.
102     if [ -e /lib/firmware.tar.bz2 ]
103     then
104     ebegin "Unpacking hotplug firmware"
105     tar xjf /lib/firmware.tar.bz2 -C /lib/firmware
106     eend 0
107     fi
108     }
109    
110 wolf31o2 109 get_info() {
111     local tmp
112    
113     if [ ! -z "${1}" -a ! -z "${2}" ]
114     then
115 wolf31o2 112 tmp=$(grep "^$1[[:space:]]\+:" /proc/cpuinfo | head -n 1 | cut -d" " -f3-)
116     # tmp=$([[ $'\n'$(</proc/cpuinfo) =~ $'\n''$1[[:space:]]\+:' ]] | head -n 1 | cut -d" " -f3-)
117 wolf31o2 114 eval "${2}='${tmp}'"
118 wolf31o2 109 fi
119     }
120    
121 wolf31o2 81 detect_mips() {
122 wolf31o2 109 get_info "cpu model" cpuinfo
123     get_info "system type" machinfo
124     cpuinfo="${cpuinfo%% FPU*}"
125 wolf31o2 79
126     case "${machinfo}" in
127     "SGI Indigo2")
128     case "${cpuinfo}" in
129     R4*)
130 wolf31o2 109 machinfo="SGI Indigo2" # I2 R4x00
131 wolf31o2 79 ;;
132     R8*)
133 wolf31o2 109 machinfo="SGI Indigo2 Power" # I2 R8000
134 wolf31o2 79 ;;
135     R10*)
136 wolf31o2 109 machinfo="SGI Indigo2 Impact" # I2 R10000
137 wolf31o2 79 ;;
138     esac
139     ;;
140     esac
141    
142 wolf31o2 109 PC="Detected an ${machinfo} w/ ${numcpu} ${cpuinfo} CPU(s)"
143 wolf31o2 79 }
144    
145 wolf31o2 109 detect_x86_amd64_ia64() {
146 wolf31o2 112 if [ "${1}" = "ia64" ]
147     then
148     get_info "family" cpuinfo
149     else
150     get_info "model name" cpuinfo
151     fi
152 wolf31o2 109 get_info "cpu MHz" mhz
153 wolf31o2 112 mhz="${mhz%%.*}MHz"
154 wolf31o2 79
155 wolf31o2 114 PC="Detected ${numcpu} ${cpuinfo} CPU(s) @ ${mhz}"
156 wolf31o2 81 }
157    
158 wolf31o2 98 detect_alpha() {
159 wolf31o2 109 get_info "platform string" machinfo
160     get_info "cpu" cpuinfo1
161     get_info "cpu model" cpuinfo2
162     get_info "cpus detected" numcpu
163    
164     PC="Detected ${numcpu} ${cpuinfo1} ${cpuinfo2} CPU(s) in a ${machinfo} system"
165 wolf31o2 98 }
166    
167 wolf31o2 89 detect_ppc() {
168 wolf31o2 109 get_info "cpu" cpuinfo
169     get_info "clock" mhz
170     get_info "detected as" machinfo
171     machinfo="${machinfo##*\(}"
172     machinfo="${machinfo%%\)*}"
173    
174 wolf31o2 89 local machtype=""
175    
176     case "${machinfo}" in
177 wolf31o2 120 "CHRP Pegasos2")
178     machtype="Pegasos 2"
179 wolf31o2 89 ;;
180 wolf31o2 120 "CHRP IBM,9124-720")
181     machtype="IBM OP720"
182 wolf31o2 90 ;;
183     "iBook 2 rev. 2")
184     machtype="Apple iBook G3"
185     ;;
186 wolf31o2 120 "iMac G5"*)
187     machtype="Apple iMac G5"
188     ;;
189     "MPC8241")
190     machtype="Kurobox"
191     ;;
192 wolf31o2 92 "PowerMac G5")
193     machtype="Apple PowerMac G5"
194     ;;
195 wolf31o2 90 "PowerMac G5 Dual Core")
196     machtype="Apple PowerMac G5 Dual Core"
197     ;;
198 wolf31o2 120 "PowerMac G4 AGP Graphics")
199     machtype="Apple PowerMac G4"
200     ;;
201     "PowerBook Titanium"|'PowerBook G4 15"')
202     machtype="Apple Powerbook G4"
203     ;;
204 wolf31o2 90 "Unknown Intrepid-based")
205     machtype="Apple Mac-Mini"
206     ;;
207 wolf31o2 89 *)
208     machtype="Unknown PPC System"
209     ;;
210     esac
211    
212 wolf31o2 109 PC="Detected a(n) ${machtype} w/ ${numcpu} ${cpuinfo} CPU(s)"
213 wolf31o2 89 }
214    
215 wolf31o2 109 detect_sparc() {
216     get_info "cpu" cpuinfo
217     get_info "ncpus active" numcpu
218     get_info "ncpus probed" numprobed
219    
220     PC="Detected ${numcpu} active ${cpuinfo} CPU(s) of ${numprobed} total"
221     }
222    
223 zhen 2 start() {
224 wolf31o2 69 echo "0" > /proc/sys/kernel/printk
225 wolf31o2 68 get_config
226 wolf31o2 130
227     # First off, we want hotplug/coldplug enabled, so let's re-enable it.
228     # We do this even if we aren't startup up the hotplug/coldplug
229     # services for the installer.
230     sed -i 's/RC_COLDPLUG="no"/RC_COLDPLUG="yes"/' /etc/conf.d/rc
231     # Now, we check if we're supposed to run a coldplug script.
232     if [ "${HOTPLUG}" = "yes" ]
233     then
234     # Check whether we should be using hotplug or coldplug
235     if [ -x /etc/init.d/coldplug ]
236     then
237     start_service coldplug
238     elif [ -x /etc/init.d/hotplug ]
239     then
240     start_service hotplug
241     else
242     unpack_firmware
243     [ -x /sbin/udevtrigger ] && /sbin/udevtrigger
244     fi
245     else
246     ewarn "Hotplug/Coldplug disabled via cmdline ..."
247     fi
248    
249 wolf31o2 51 if [ "${DETECT}" = "yes" ]
250     then
251 wolf31o2 78 ebegin "Hardware detection started"
252 wolf31o2 112 local numcpu="$(grep -c '^processor[[:space:]]\+:' /proc/cpuinfo)"
253     # local numcpu=$([[ $'\n'$(</proc/cpuinfo) =~ $'\n''processor[[:space:]]\+:' ]] | wc -l)
254 wolf31o2 80 local arch="$(uname -m)"
255 wolf31o2 109
256 wolf31o2 81 case ${arch} in
257 wolf31o2 109 mips*)
258 wolf31o2 81 detect_mips
259 wolf31o2 109 ACPI="no"
260     APM="no"
261     IDEDMA="no"
262 wolf31o2 81 ;;
263 wolf31o2 113 i?86|x86_64)
264 wolf31o2 109 detect_x86_amd64_ia64
265 wolf31o2 81 ;;
266 wolf31o2 98 alpha)
267     detect_alpha
268 wolf31o2 109 ACPI="no"
269     APM="no"
270 wolf31o2 98 ;;
271 wolf31o2 109 sparc*)
272     detect_sparc
273     ACPI="no"
274     APM="no"
275     ;;
276 wolf31o2 98 powerpc*)
277     detect_ppc
278 wolf31o2 109 ACPI="no"
279     APM="no"
280 wolf31o2 98 ;;
281 wolf31o2 109 ia64)
282     detect_x86_amd64_ia64 "ia64"
283     APM="no"
284     ;;
285 wolf31o2 81 *)
286 wolf31o2 109 PC=
287 wolf31o2 81 ;;
288     esac
289 wolf31o2 109 [ -n "${PC}" ] && einfo "${PC}"
290 wolf31o2 78 [ -x /usr/sbin/hwsetup ] && hwsetup -p >/dev/null
291 zhen 2 eend
292 wolf31o2 6 else
293 wolf31o2 78 ewarn "Hardware detection disabled via cmdline ..."
294 wolf31o2 6 fi
295 zhen 2
296 wolf31o2 51 if [ "${APM}" = "yes" ]
297     then
298 wolf31o2 78 modprobe apm power_off=1 >/dev/null 2>&1 && \
299     einfo "APM BIOS found, power management functions enabled ..."
300 wolf31o2 77 [ -x /etc/init.d/apmd ] && start_service apmd
301 zhen 2 else
302 wolf31o2 109 einfo "Not Loading APM Bios support ..."
303 wolf31o2 6 fi
304 zhen 2
305 wolf31o2 51 if [ "${ACPI}" = "yes" ]
306     then
307 wolf31o2 78 modprobe processor >/dev/null 2>&1 && \
308     ebegin "ACPI power management functions enabled" && \
309     modprobe thermal >/dev/null
310 wolf31o2 29 modprobe fan >/dev/null 2>&1
311     modprobe button >/dev/null 2>&1
312     modprobe battery >/dev/null 2>&1
313     modprobe ac >/dev/null 2>&1
314 wolf31o2 77 [ -x /etc/init.d/acpid ] && start_service acpid
315 wolf31o2 6 eend
316 wolf31o2 78 else
317 wolf31o2 109 einfo "Not Loading ACPI support ..."
318 wolf31o2 6 fi
319 zhen 2
320 wolf31o2 51 if [ "${IDEDMA}" = "yes" ]
321     then
322 wolf31o2 109 [ -x /etc/init.d/hdparm ] && start_service hdparm
323 wolf31o2 49 fi
324    
325 wolf31o2 51 if [ "${PCMCIA}" = "yes" ]
326     then
327 wolf31o2 78 einfo "PCMCIA enabled via cmdline ..."
328 wolf31o2 77 [ -x /etc/init.d/pcmcia ] && start_service pcmcia
329 wolf31o2 6 fi
330 zhen 2
331 wolf31o2 51 if [ "${DHCP}" = "no" ]
332     then
333 wolf31o2 48 sed -i -e '/^ifconfig_eth.*dhcp.*/ s/^/#/' \
334     -e '/^iface_eth.*dhcp.*/ s/^/#/' \
335 wolf31o2 55 -e '/^config_eth.*dhcp.*/ s/^/#/' \
336 wolf31o2 25 /etc/conf.d/net
337 wolf31o2 118 for i in `seq 0 4`
338     do
339     echo "config_eth$i=( \"none\" )" >> /etc/conf.d/net
340     done
341 wolf31o2 78 ewarn "Skipping DHCP broadcast detection as requested on boot commandline ..."
342 wolf31o2 6 fi
343 zhen 2
344 wolf31o2 78 # Read in what hwsetup has found
345 wolf31o2 64 [ -f /etc/sysconfig/gentoo ] && . /etc/sysconfig/gentoo
346 zhen 2
347 wolf31o2 6 # Mouse
348 wolf31o2 51 if [ -n "${MOUSE_DEVICE}" ]
349     then
350 wolf31o2 78 einfo "Mouse is ${HILITE}${MOUSE_FULLNAME}${NORMAL} at ${HILITE}${MOUSE_DEVICE}${NORMAL} ..."
351 wolf31o2 6 source /etc/sysconfig/mouse
352 wolf31o2 51 if [ -x /usr/sbin/gpm ]
353     then
354 wolf31o2 114 if [ $(grep "#MOUSE=${MOUSETYPE}" /etc/conf.d/gpm) ]
355     # if [ $([[ $'\n'$(</etc/conf.d/gpm) =~ $'\n''#MOUSE=${MOUSETYPE}' ]]) ]
356 wolf31o2 110 then
357     sed -i "\@MOUSE=${MOUSETYPE}@s@^#@@" /etc/conf.d/gpm
358     else
359     echo "MOUSE=${MOUSETYPE}" >>/etc/conf.d/gpm
360     fi
361 wolf31o2 78
362 wolf31o2 114 if [ $(grep "#MOUSEDEV=${DEVICE}" /etc/conf.d/gpm) ]
363     # if [ $([[ $'\n'$(</etc/conf.d/gpm) =~ $'\n''#MOUSEDEV=${DEVICE}' ]]) ]
364 wolf31o2 110 then
365     sed -i "\@MOUSEDEV=${DEVICE}@s@^#@@" /etc/conf.d/gpm
366     else
367     echo "MOUSEDEV=${DEVICE}" >>/etc/conf.d/gpm
368     fi
369 wolf31o2 78
370     [ "${GPM}" = "yes" ] \
371     && [ -x /etc/init.d/gpm ] && start_service gpm
372 wolf31o2 29 fi
373 wolf31o2 6 fi
374 zhen 2
375 wolf31o2 78 [ "${DETECT}" = "no" ] && DHCP="no"
376     [ "${DETECT}" = "yes" ] \
377     && NETDEVICES="$(awk -F: '/eth.:|tr.:|ath.:|wlan.:/{print $1}' /proc/net/dev 2>/dev/null)"
378 zhen 2
379 wolf31o2 51 if [ -n "${NETDEVICES}" ]
380     then
381 wolf31o2 74 for nics in ${NETDEVICES}
382     do
383     if [ "${DHCP}" = "yes" ]
384     then
385 wolf31o2 78 einfo "Network device ${HILITE}${nics}${NORMAL} detected, DHCP broadcasting for IP ..."
386 wolf31o2 74 fi
387     done
388 zhen 2 else
389 wolf31o2 78 ewarn "No Network device auto detected ..."
390 wolf31o2 6 fi
391 zhen 2
392 wolf31o2 68 if [ "${ALSA}" = "yes" ]
393 wolf31o2 51 then
394 wolf31o2 68 if [ -n "${SOUND_FULLNAME}" -o -n "${SOUND_DRIVER}" ]
395 wolf31o2 51 then
396 wolf31o2 78 local sndmsg="Soundcard:\n"
397    
398     [ -n "${SOUND_FULLNAME}" ] \
399     && sndmsg="${sndmsg} ${WARN}${SOUND_FULLNAME}\n"
400     [ -n "${SOUND_DRIVER}" ] \
401     && sndmsg="${sndmsg} driver = ${SOUND_DRIVER}\n"
402    
403     einfo "${sndmsg}"
404    
405 wolf31o2 70 if [ -x /etc/init.d/alsasound ]
406     then
407 wolf31o2 77 start_service alsasound
408 wolf31o2 70 fi
409 wolf31o2 78
410 wolf31o2 82 if [ -e /proc/asound/cards ]
411     then
412 wolf31o2 102 for i in $(cat /proc/asound/cards | awk '{print $1}' | grep ^[[:digit:]])
413 wolf31o2 82 do
414     if [ -d /proc/asound/card$i ] && [ -x /usr/bin/amixer ]
415     then
416     amixer -c $i scontrols > /etc/amixer
417     [ -n "$(grep Master /etc/amixer)" ] \
418     && amixer -c $i -q set Master 95% unmute \
419     >/dev/null 2>&1
420     [ -n "$(grep PCM /etc/amixer)" ] \
421     && amixer -c $i -q set PCM 95% unmute \
422     >/dev/null 2>&1
423     [ -n "$(grep Mic /etc/amixer)" ] \
424     && amixer -c $i -q set Mic 95% mute cap \
425     >/dev/null 2>&1
426     [ -n "$(grep Wave /etc/amixer)" ] \
427     && amixer -c $i -q set Wave 95% unmute \
428     >/dev/null 2>&1
429     [ -n "$(grep Capture /etc/amixer)" ] \
430     && amixer -c $i -q set Capture 95% unmute cap \
431     >/dev/null 2>&1
432     fi
433     done
434     fi
435 wolf31o2 15 fi
436 wolf31o2 68 else
437 wolf31o2 86 ewarn "Skipping ALSA detection as requested on command line ..."
438 wolf31o2 6 fi
439 zhen 2
440 wolf31o2 114 [ -n "${XDESC}" ] && einfo "VideoCard: ${HILITE}${XDESC}${NORMAL}"
441    
442 wolf31o2 102 if [ "${X11}" = "yes" ]
443 wolf31o2 76 then
444 wolf31o2 115 if [ -x /etc/init.d/mkxf86config ]
445     then
446     start_service mkxf86config
447     fi
448 wolf31o2 109 if [ -x /etc/init.d/x-setup ]
449     then
450     start_service x-setup
451     fi
452 wolf31o2 102 else
453     touch /etc/init.d/.noxdm
454 wolf31o2 76 fi
455    
456 wolf31o2 6 killall hwsetup 2>/dev/null
457     echo "6" > /proc/sys/kernel/printk
458 zhen 2 }
459 wolf31o2 6
460     # vim: ts=4

Properties

Name Value
svn:eol-style native
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20