/[livecd-tools]/trunk/autoconfig
Gentoo

Contents of /trunk/autoconfig

Parent Directory Parent Directory | Revision Log Revision Log


Revision 101 - (hide annotations) (download)
Fri May 19 23:52:00 2006 UTC (11 years, 6 months ago) by wolf31o2
File size: 10177 byte(s)
Add an unpack_firmware function in case we don't have either the hotplug or coldplug init scripts for udev >=089 compatibility.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20