/[livecd-tools]/trunk/autoconfig
Gentoo

Contents of /trunk/autoconfig

Parent Directory Parent Directory | Revision Log Revision Log


Revision 114 - (hide annotations) (download)
Sun Jul 16 13:45:42 2006 UTC (11 years, 3 months ago) by wolf31o2
File size: 9725 byte(s)
Some more cleanup of the autodetection sections.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20