/[livecd-tools]/trunk/autoconfig
Gentoo

Contents of /trunk/autoconfig

Parent Directory Parent Directory | Revision Log Revision Log


Revision 102 - (hide annotations) (download)
Tue May 23 12:57:39 2006 UTC (12 years, 1 month ago) by wolf31o2
File size: 10225 byte(s)
Fixed x-setup being called when we used either nox or nodetect.  Fixed sound card detection.

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 102 # $Header: /var/cvsroot/gentoo/src/livecd-tools/autoconfig,v 1.59 2006/05/23 12:57:39 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 78 if [ "$1" = "yes" ]
74     then
75     if [ -x "/etc/init.d/$2" ]
76     then
77 wolf31o2 69 echo "$2"
78 wolf31o2 78 elif [ -n "$3" -a -x "/etc/init.d/$3" ]
79     then
80 wolf31o2 69 echo "$3"
81     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 79 # Only used on SGI CDs, this determines:
114 wolf31o2 80 # A) CPU Type
115     # B) System
116 wolf31o2 81 detect_mips() {
117 wolf31o2 80 local cpuinfo="$(awk -F: '/^cpu model/{printf $2};/^$/{print ""}' /proc/cpuinfo 2>/dev/null | head -n 1 | cut -d" " -f2,3)"
118     local machinfo="$(awk -F: '/^system type/{printf $2};/^$/{print ""}' /proc/cpuinfo 2>/dev/null | cut -d" " -f2-)"
119 wolf31o2 79 local machtype=""
120    
121     case "${machinfo}" in
122     "SGI Indy")
123     machtype="SGI Indy" # Indy R4x00/R5000
124     ;;
125     "SGI Indigo2")
126     case "${cpuinfo}" in
127     R4*)
128     machtype="SGI Indigo2" # I2 R4x00
129     ;;
130     R8*)
131     machtype="SGI Indigo2 Power" # I2 R8000
132     ;;
133     R10*)
134     machtype="SGI Indigo2 Impact" # I2 R10000
135     ;;
136     esac
137     ;;
138     "SGI O2"|"SGI IP32")
139     machtype="SGI O2" # O2 R5K/RM5K2/RM7K/R10K/R12K
140     ;;
141     "SGI Octane"|"SGI IP30")
142     machtype="SGI Octane" # Octane R10K/R12K/R14K
143     ;;
144     "SGI Origin"|"SGI IP27")
145     machtype="SGI Origin" # Origin R10K/R12K
146     ;;
147     *)
148     machtype="Unknown SGI MIPS" # ???
149     ;;
150     esac
151    
152     PC="Detected an ${machtype} w/ ${numcpu} ${cpuinfo} ${bit}"
153     }
154    
155 wolf31o2 81 detect_x86_amd64() {
156     local cpuinfo="$(awk -F: '/^model name/{printf $2};/^$/{print ""}' /proc/cpuinfo 2>/dev/null | head -n 1)"
157     local mhz="$(awk -F: '/^cpu MHz/{printf " %dMHz",int($2)};/^$/{print ""}' /proc/cpuinfo 2>/dev/null | head -n 1)"
158 wolf31o2 79
159 wolf31o2 81 PC="Detected ${numcpu} ${cpuinfo} ${mhz} ${bit}"
160     }
161    
162 wolf31o2 98 detect_alpha() {
163     local cpuinfo="$(awk -F: '/^platform string/{printf $2};/^$/{print ""}' /proc/cpuinfo 2>/dev/null | head -n 1)"
164     local numcpu="$(awk -F: '/^cpus active/{printf $2};/^$/{print ""}' /proc/cpuinfo 2>/dev/null | head -n 1)"
165     if [ "${numcpu}" -gt '1' ]
166     then
167     bit="CPUs"
168     else
169     bit="CPU"
170     fi
171     PC="Detected ${numcpu} ${cpuinfo} ${bit}"
172     }
173    
174 wolf31o2 89 detect_ppc() {
175     local cpuinfo="$(awk -F: '/^cpu/{printf $2};/^$/{print ""}' /proc/cpuinfo 2>/dev/null | head -n 1)"
176     local mhz="$(awk -F: '/^clock/{printf " %dMHz",int($2)};/^$/{print ""}' /proc/cpuinfo 2>/dev/null | head -n 1)"
177     local machinfo="$(awk -F: '/^detected as/{printf $2}' /proc/cpuinfo | cut -d'(' -f2 | cut -d')' -f1)"
178     local machtype=""
179 wolf31o2 91 # if [ -z "machinfo" ]
180     # then
181     # machinfo=$(awk -F: '/^machine/{printf $2}' /proc/cpuinfo)"
182     # fi
183 wolf31o2 89
184     case "${machinfo}" in
185     "PowerMac G4 AGP Graphics")
186     machtype="Apple PowerMac G4"
187     ;;
188 wolf31o2 92 "PowerBook Titanium"|'PowerBook G4 15"')
189 wolf31o2 90 machtype="Apple Powerbook G4"
190     ;;
191     "iBook 2 rev. 2")
192     machtype="Apple iBook G3"
193     ;;
194 wolf31o2 92 "PowerMac G5")
195     machtype="Apple PowerMac G5"
196     ;;
197 wolf31o2 90 "PowerMac G5 Dual Core")
198     machtype="Apple PowerMac G5 Dual Core"
199     ;;
200     "Unknown Intrepid-based")
201     machtype="Apple Mac-Mini"
202     ;;
203 wolf31o2 91 "MPC8241")
204     machtype="Kurobox"
205     ;;
206     "CHRP Pegasos2")
207     machtype="Pegasos 2"
208     ;;
209 wolf31o2 97 "CHRP IBM,9124-720")
210 wolf31o2 93 machtype="IBM OP720"
211     ;;
212 wolf31o2 89 *)
213     machtype="Unknown PPC System"
214     ;;
215     esac
216    
217     PC="Detected an ${machtype} w/ ${numcpu} ${cpuinfo} ${bit}"
218     }
219    
220 zhen 2 start() {
221 wolf31o2 69 echo "0" > /proc/sys/kernel/printk
222 wolf31o2 68 get_config
223 wolf31o2 51 if [ "${DETECT}" = "yes" ]
224     then
225 wolf31o2 78 ebegin "Hardware detection started"
226 wolf31o2 80 local numcpu="$(awk -F: '/^processor/{printf $2};/^$/{print ""}' /proc/cpuinfo 2>/dev/null | wc -l)"
227     local arch="$(uname -m)"
228 wolf31o2 79 local ismips="no"
229 wolf31o2 98 if [ "${numcpu}" -gt '1' ]
230     then
231     bit="CPUs"
232     else
233     bit="CPU"
234     fi
235 wolf31o2 81 case ${arch} in
236     mips|mips64)
237     detect_mips
238     ismips="yes"
239     ;;
240 wolf31o2 83 i?86|x86_64)
241 wolf31o2 81 detect_x86_amd64
242     ;;
243 wolf31o2 98 alpha)
244     detect_alpha
245     ;;
246     powerpc*)
247     detect_ppc
248     ;;
249 wolf31o2 81 *)
250     PC="$(awk -F: '/^processor/{printf "Processor"$2" is"};/^model name/{printf $2};/^vendor_id/{printf vendor};/^cpu MHz/{printf " %dMHz",int($2)};/^cache size/{printf ","$2" Cache"};/^$/{print ""}' /proc/cpuinfo 2>/dev/null)"
251     ;;
252     esac
253 wolf31o2 78 einfo "${PC}"
254     [ -x /usr/sbin/hwsetup ] && hwsetup -p >/dev/null
255 zhen 2 eend
256 wolf31o2 6 else
257 wolf31o2 78 ewarn "Hardware detection disabled via cmdline ..."
258 wolf31o2 6 fi
259 zhen 2
260 wolf31o2 51 if [ "${APM}" = "yes" ]
261     then
262 wolf31o2 78 modprobe apm power_off=1 >/dev/null 2>&1 && \
263     einfo "APM BIOS found, power management functions enabled ..."
264 wolf31o2 77 [ -x /etc/init.d/apmd ] && start_service apmd
265 zhen 2 else
266 wolf31o2 79 [ "${ismips}" = "no" ] && ewarn "Not Loading APM Bios support ..."
267 wolf31o2 6 fi
268 zhen 2
269 wolf31o2 51 if [ "${ACPI}" = "yes" ]
270     then
271 wolf31o2 78 modprobe processor >/dev/null 2>&1 && \
272     ebegin "ACPI power management functions enabled" && \
273     modprobe thermal >/dev/null
274 wolf31o2 29 modprobe fan >/dev/null 2>&1
275     modprobe button >/dev/null 2>&1
276     modprobe battery >/dev/null 2>&1
277     modprobe ac >/dev/null 2>&1
278 wolf31o2 77 [ -x /etc/init.d/acpid ] && start_service acpid
279 wolf31o2 6 eend
280 wolf31o2 78 else
281 wolf31o2 79 [ "${ismips}" = "no" ] && ewarn "Not Loading ACPI support ..."
282 wolf31o2 6 fi
283 zhen 2
284 wolf31o2 51 if [ "${IDEDMA}" = "yes" ]
285     then
286 wolf31o2 79 if [ "${ismips}" = "no" ]; then
287     [ -x /etc/init.d/hdparm ] && start_service hdparm
288     fi
289 wolf31o2 49 fi
290    
291 wolf31o2 51 if [ "${PCMCIA}" = "yes" ]
292     then
293 wolf31o2 78 einfo "PCMCIA enabled via cmdline ..."
294 wolf31o2 77 [ -x /etc/init.d/pcmcia ] && start_service pcmcia
295 wolf31o2 6 fi
296 zhen 2
297 wolf31o2 51 if [ "${DHCP}" = "no" ]
298     then
299 wolf31o2 48 sed -i -e '/^ifconfig_eth.*dhcp.*/ s/^/#/' \
300     -e '/^iface_eth.*dhcp.*/ s/^/#/' \
301 wolf31o2 55 -e '/^config_eth.*dhcp.*/ s/^/#/' \
302 wolf31o2 25 /etc/conf.d/net
303 wolf31o2 78 ewarn "Skipping DHCP broadcast detection as requested on boot commandline ..."
304 wolf31o2 6 fi
305 zhen 2
306 wolf31o2 78 # Read in what hwsetup has found
307 wolf31o2 6 [ -f /etc/sysconfig/knoppix ] && . /etc/sysconfig/knoppix
308 wolf31o2 64 [ -f /etc/sysconfig/gentoo ] && . /etc/sysconfig/gentoo
309 zhen 2
310 wolf31o2 6 # Mouse
311 wolf31o2 51 if [ -n "${MOUSE_DEVICE}" ]
312     then
313 wolf31o2 78 einfo "Mouse is ${HILITE}${MOUSE_FULLNAME}${NORMAL} at ${HILITE}${MOUSE_DEVICE}${NORMAL} ..."
314 wolf31o2 6 source /etc/sysconfig/mouse
315 wolf31o2 51 if [ -x /usr/sbin/gpm ]
316     then
317 wolf31o2 78 [ $(grep "#MOUSE=${MOUSETYPE}" /etc/conf.d/gpm) ] \
318     && sed -i "\@MOUSE=${MOUSETYPE}@s@^#@@" /etc/conf.d/gpm \
319     || echo "MOUSE=${MOUSETYPE}" >>/etc/conf.d/gpm
320    
321     [ $(grep "#MOUSEDEV=${DEVICE}" /etc/conf.d/gpm) ] \
322     && sed -i "\@MOUSEDEV=${DEVICE}@s@^#@@" /etc/conf.d/gpm \
323     || echo "MOUSEDEV=${DEVICE}" >>/etc/conf.d/gpm
324    
325     [ "${GPM}" = "yes" ] \
326     && [ -x /etc/init.d/gpm ] && start_service gpm
327 wolf31o2 29 fi
328 wolf31o2 6 fi
329 zhen 2
330 wolf31o2 51 if [ "${HOTPLUG}" = "yes" ]
331     then
332 wolf31o2 78 # Check whether we should be using hotplug or coldplug
333 wolf31o2 51 if [ -x /etc/init.d/coldplug ]
334     then
335 wolf31o2 77 start_service coldplug
336 wolf31o2 67 elif [ -x /etc/init.d/hotplug ]
337     then
338 wolf31o2 77 start_service hotplug
339 wolf31o2 101 else
340     unpack_firmware
341 wolf31o2 17 fi
342 zhen 2 else
343 wolf31o2 78 ewarn "Hotplug disabled via cmdline ..."
344 wolf31o2 6 fi
345 zhen 2
346 wolf31o2 78 [ "${DETECT}" = "no" ] && DHCP="no"
347     [ "${DETECT}" = "yes" ] \
348     && NETDEVICES="$(awk -F: '/eth.:|tr.:|ath.:|wlan.:/{print $1}' /proc/net/dev 2>/dev/null)"
349 zhen 2
350 wolf31o2 51 if [ -n "${NETDEVICES}" ]
351     then
352 wolf31o2 74 for nics in ${NETDEVICES}
353     do
354     if [ "${DHCP}" = "yes" ]
355     then
356 wolf31o2 78 einfo "Network device ${HILITE}${nics}${NORMAL} detected, DHCP broadcasting for IP ..."
357 wolf31o2 74 dhcpcd -n -h $(hostname) &
358     fi
359     done
360 zhen 2 else
361 wolf31o2 78 ewarn "No Network device auto detected ..."
362 wolf31o2 6 fi
363 zhen 2
364 wolf31o2 68 if [ "${ALSA}" = "yes" ]
365 wolf31o2 51 then
366 wolf31o2 68 if [ -n "${SOUND_FULLNAME}" -o -n "${SOUND_DRIVER}" ]
367 wolf31o2 51 then
368 wolf31o2 78 local sndmsg="Soundcard:\n"
369    
370     [ -n "${SOUND_FULLNAME}" ] \
371     && sndmsg="${sndmsg} ${WARN}${SOUND_FULLNAME}\n"
372     [ -n "${SOUND_DRIVER}" ] \
373     && sndmsg="${sndmsg} driver = ${SOUND_DRIVER}\n"
374    
375     einfo "${sndmsg}"
376    
377    
378 wolf31o2 70 if [ -x /etc/init.d/alsasound ]
379     then
380 wolf31o2 77 start_service alsasound
381 wolf31o2 70 fi
382 wolf31o2 78
383 wolf31o2 82 if [ -e /proc/asound/cards ]
384     then
385 wolf31o2 102 for i in $(cat /proc/asound/cards | awk '{print $1}' | grep ^[[:digit:]])
386 wolf31o2 82 do
387     if [ -d /proc/asound/card$i ] && [ -x /usr/bin/amixer ]
388     then
389     amixer -c $i scontrols > /etc/amixer
390     [ -n "$(grep Master /etc/amixer)" ] \
391     && amixer -c $i -q set Master 95% unmute \
392     >/dev/null 2>&1
393     [ -n "$(grep PCM /etc/amixer)" ] \
394     && amixer -c $i -q set PCM 95% unmute \
395     >/dev/null 2>&1
396     [ -n "$(grep Mic /etc/amixer)" ] \
397     && amixer -c $i -q set Mic 95% mute cap \
398     >/dev/null 2>&1
399     [ -n "$(grep Wave /etc/amixer)" ] \
400     && amixer -c $i -q set Wave 95% unmute \
401     >/dev/null 2>&1
402     [ -n "$(grep Capture /etc/amixer)" ] \
403     && amixer -c $i -q set Capture 95% unmute cap \
404     >/dev/null 2>&1
405     fi
406     done
407     fi
408 wolf31o2 15 fi
409 wolf31o2 68 else
410 wolf31o2 86 ewarn "Skipping ALSA detection as requested on command line ..."
411 wolf31o2 6 fi
412 zhen 2
413 wolf31o2 102 if [ "${X11}" = "yes" ]
414 wolf31o2 76 then
415 wolf31o2 87 [ -x /etc/init.d/x-setup ] && start_service x-setup
416 wolf31o2 102 else
417     touch /etc/init.d/.noxdm
418 wolf31o2 76 fi
419    
420 wolf31o2 78 [ -n "${XDESC}" ] && einfo "VideoCard: ${HILITE}${XDESC}${NORMAL}"
421 wolf31o2 76
422 wolf31o2 6 killall hwsetup 2>/dev/null
423     echo "6" > /proc/sys/kernel/printk
424 zhen 2 }
425 wolf31o2 6
426     # vim: ts=4

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20