/[livecd-tools]/trunk/autoconfig
Gentoo

Contents of /trunk/autoconfig

Parent Directory Parent Directory | Revision Log Revision Log


Revision 98 - (hide annotations) (download)
Sun Apr 23 17:06:38 2006 UTC (11 years, 7 months ago) by wolf31o2
File size: 9824 byte(s)
Added alpha CPU information to CPU detection output.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20