/[livecd-tools]/trunk/autoconfig
Gentoo

Contents of /trunk/autoconfig

Parent Directory Parent Directory | Revision Log Revision Log


Revision 122 - (show annotations) (download)
Wed Sep 20 22:08:04 2006 UTC (11 years, 9 months ago) by wolf31o2
File size: 9893 byte(s)
Escape = in cmdline checks.

1 #!/sbin/runscript
2 # Copyright 1999-2005 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4 # $Header: /var/cvsroot/gentoo/src/livecd-tools/autoconfig,v 1.69 2006/09/20 22:08:04 wolf31o2 Exp $
5
6 DHCP="yes"
7 DETECT="yes"
8 GPM="yes"
9 PCMCIA="no"
10 HOTPLUG="yes"
11 APM="no"
12 ACPI="no"
13 IDEDMA="yes"
14 ALSA="yes"
15 X11="yes"
16
17 get_config() {
18 CMDLINE="$(cat /proc/cmdline)"
19
20 for x in ${CMDLINE} ; do
21 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 done
62 }
63
64 depend() {
65 need modules
66 before net
67 # provide gpm pcmcia apmd acpid coldplug hdparm alsasound mkxf86config x-setup
68 }
69
70 # Checks whether a service will be started by autoconfig.
71 # Usage: check_svc var service [service_alternative]
72 check_svc() {
73 if [ "${1}" = "yes" ]
74 then
75 if [ -x "/etc/init.d/${2}" ]
76 then
77 echo "${2}"
78 elif [ -n "${3}" -a -x "/etc/init.d/${3}" ]
79 then
80 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 svcs="${svcs} $(check_svc ${X11} mkxf86config x-setup)"
97
98 echo ${svcs}
99 }
100
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 get_info() {
114 local tmp
115
116 if [ ! -z "${1}" -a ! -z "${2}" ]
117 then
118 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 eval "${2}='${tmp}'"
121 fi
122 }
123
124 detect_mips() {
125 get_info "cpu model" cpuinfo
126 get_info "system type" machinfo
127 cpuinfo="${cpuinfo%% FPU*}"
128
129 case "${machinfo}" in
130 "SGI Indigo2")
131 case "${cpuinfo}" in
132 R4*)
133 machinfo="SGI Indigo2" # I2 R4x00
134 ;;
135 R8*)
136 machinfo="SGI Indigo2 Power" # I2 R8000
137 ;;
138 R10*)
139 machinfo="SGI Indigo2 Impact" # I2 R10000
140 ;;
141 esac
142 ;;
143 esac
144
145 PC="Detected an ${machinfo} w/ ${numcpu} ${cpuinfo} CPU(s)"
146 }
147
148 detect_x86_amd64_ia64() {
149 if [ "${1}" = "ia64" ]
150 then
151 get_info "family" cpuinfo
152 else
153 get_info "model name" cpuinfo
154 fi
155 get_info "cpu MHz" mhz
156 mhz="${mhz%%.*}MHz"
157
158 PC="Detected ${numcpu} ${cpuinfo} CPU(s) @ ${mhz}"
159 }
160
161 detect_alpha() {
162 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 }
169
170 detect_ppc() {
171 get_info "cpu" cpuinfo
172 get_info "clock" mhz
173 get_info "detected as" machinfo
174 machinfo="${machinfo##*\(}"
175 machinfo="${machinfo%%\)*}"
176
177 local machtype=""
178
179 case "${machinfo}" in
180 "CHRP Pegasos2")
181 machtype="Pegasos 2"
182 ;;
183 "CHRP IBM,9124-720")
184 machtype="IBM OP720"
185 ;;
186 "iBook 2 rev. 2")
187 machtype="Apple iBook G3"
188 ;;
189 "iMac G5"*)
190 machtype="Apple iMac G5"
191 ;;
192 "MPC8241")
193 machtype="Kurobox"
194 ;;
195 "PowerMac G5")
196 machtype="Apple PowerMac G5"
197 ;;
198 "PowerMac G5 Dual Core")
199 machtype="Apple PowerMac G5 Dual Core"
200 ;;
201 "PowerMac G4 AGP Graphics")
202 machtype="Apple PowerMac G4"
203 ;;
204 "PowerBook Titanium"|'PowerBook G4 15"')
205 machtype="Apple Powerbook G4"
206 ;;
207 "Unknown Intrepid-based")
208 machtype="Apple Mac-Mini"
209 ;;
210 *)
211 machtype="Unknown PPC System"
212 ;;
213 esac
214
215 PC="Detected a(n) ${machtype} w/ ${numcpu} ${cpuinfo} CPU(s)"
216 }
217
218 detect_sparc() {
219 get_info "cpu" cpuinfo
220 get_info "ncpus active" numcpu
221 get_info "ncpus probed" numprobed
222
223 PC="Detected ${numcpu} active ${cpuinfo} CPU(s) of ${numprobed} total"
224 }
225
226 start() {
227 echo "0" > /proc/sys/kernel/printk
228 get_config
229 if [ "${DETECT}" = "yes" ]
230 then
231 ebegin "Hardware detection started"
232 local numcpu="$(grep -c '^processor[[:space:]]\+:' /proc/cpuinfo)"
233 # local numcpu=$([[ $'\n'$(</proc/cpuinfo) =~ $'\n''processor[[:space:]]\+:' ]] | wc -l)
234 local arch="$(uname -m)"
235
236 case ${arch} in
237 mips*)
238 detect_mips
239 ACPI="no"
240 APM="no"
241 IDEDMA="no"
242 ;;
243 i?86|x86_64)
244 detect_x86_amd64_ia64
245 ;;
246 alpha)
247 detect_alpha
248 ACPI="no"
249 APM="no"
250 ;;
251 sparc*)
252 detect_sparc
253 ACPI="no"
254 APM="no"
255 ;;
256 powerpc*)
257 detect_ppc
258 ACPI="no"
259 APM="no"
260 ;;
261 ia64)
262 detect_x86_amd64_ia64 "ia64"
263 APM="no"
264 ;;
265 *)
266 PC=
267 ;;
268 esac
269 [ -n "${PC}" ] && einfo "${PC}"
270 [ -x /usr/sbin/hwsetup ] && hwsetup -p >/dev/null
271 eend
272 else
273 ewarn "Hardware detection disabled via cmdline ..."
274 fi
275
276 if [ "${APM}" = "yes" ]
277 then
278 modprobe apm power_off=1 >/dev/null 2>&1 && \
279 einfo "APM BIOS found, power management functions enabled ..."
280 [ -x /etc/init.d/apmd ] && start_service apmd
281 else
282 einfo "Not Loading APM Bios support ..."
283 fi
284
285 if [ "${ACPI}" = "yes" ]
286 then
287 modprobe processor >/dev/null 2>&1 && \
288 ebegin "ACPI power management functions enabled" && \
289 modprobe thermal >/dev/null
290 modprobe fan >/dev/null 2>&1
291 modprobe button >/dev/null 2>&1
292 modprobe battery >/dev/null 2>&1
293 modprobe ac >/dev/null 2>&1
294 [ -x /etc/init.d/acpid ] && start_service acpid
295 eend
296 else
297 einfo "Not Loading ACPI support ..."
298 fi
299
300 if [ "${IDEDMA}" = "yes" ]
301 then
302 [ -x /etc/init.d/hdparm ] && start_service hdparm
303 fi
304
305 if [ "${PCMCIA}" = "yes" ]
306 then
307 einfo "PCMCIA enabled via cmdline ..."
308 [ -x /etc/init.d/pcmcia ] && start_service pcmcia
309 fi
310
311 if [ "${DHCP}" = "no" ]
312 then
313 sed -i -e '/^ifconfig_eth.*dhcp.*/ s/^/#/' \
314 -e '/^iface_eth.*dhcp.*/ s/^/#/' \
315 -e '/^config_eth.*dhcp.*/ s/^/#/' \
316 /etc/conf.d/net
317 for i in `seq 0 4`
318 do
319 echo "config_eth$i=( \"none\" )" >> /etc/conf.d/net
320 done
321 ewarn "Skipping DHCP broadcast detection as requested on boot commandline ..."
322 fi
323
324 # Read in what hwsetup has found
325 [ -f /etc/sysconfig/gentoo ] && . /etc/sysconfig/gentoo
326
327 # Mouse
328 if [ -n "${MOUSE_DEVICE}" ]
329 then
330 einfo "Mouse is ${HILITE}${MOUSE_FULLNAME}${NORMAL} at ${HILITE}${MOUSE_DEVICE}${NORMAL} ..."
331 source /etc/sysconfig/mouse
332 if [ -x /usr/sbin/gpm ]
333 then
334 if [ $(grep "#MOUSE=${MOUSETYPE}" /etc/conf.d/gpm) ]
335 # if [ $([[ $'\n'$(</etc/conf.d/gpm) =~ $'\n''#MOUSE=${MOUSETYPE}' ]]) ]
336 then
337 sed -i "\@MOUSE=${MOUSETYPE}@s@^#@@" /etc/conf.d/gpm
338 else
339 echo "MOUSE=${MOUSETYPE}" >>/etc/conf.d/gpm
340 fi
341
342 if [ $(grep "#MOUSEDEV=${DEVICE}" /etc/conf.d/gpm) ]
343 # if [ $([[ $'\n'$(</etc/conf.d/gpm) =~ $'\n''#MOUSEDEV=${DEVICE}' ]]) ]
344 then
345 sed -i "\@MOUSEDEV=${DEVICE}@s@^#@@" /etc/conf.d/gpm
346 else
347 echo "MOUSEDEV=${DEVICE}" >>/etc/conf.d/gpm
348 fi
349
350 [ "${GPM}" = "yes" ] \
351 && [ -x /etc/init.d/gpm ] && start_service gpm
352 fi
353 fi
354
355 if [ "${HOTPLUG}" = "yes" ]
356 then
357 # Check whether we should be using hotplug or coldplug
358 if [ -x /etc/init.d/coldplug ]
359 then
360 start_service coldplug
361 elif [ -x /etc/init.d/hotplug ]
362 then
363 start_service hotplug
364 else
365 unpack_firmware
366 fi
367 else
368 ewarn "Hotplug disabled via cmdline ..."
369 fi
370
371 [ "${DETECT}" = "no" ] && DHCP="no"
372 [ "${DETECT}" = "yes" ] \
373 && NETDEVICES="$(awk -F: '/eth.:|tr.:|ath.:|wlan.:/{print $1}' /proc/net/dev 2>/dev/null)"
374
375 if [ -n "${NETDEVICES}" ]
376 then
377 for nics in ${NETDEVICES}
378 do
379 if [ "${DHCP}" = "yes" ]
380 then
381 einfo "Network device ${HILITE}${nics}${NORMAL} detected, DHCP broadcasting for IP ..."
382 dhcpcd -n -h $(hostname) &
383 fi
384 done
385 else
386 ewarn "No Network device auto detected ..."
387 fi
388
389 if [ "${ALSA}" = "yes" ]
390 then
391 if [ -n "${SOUND_FULLNAME}" -o -n "${SOUND_DRIVER}" ]
392 then
393 local sndmsg="Soundcard:\n"
394
395 [ -n "${SOUND_FULLNAME}" ] \
396 && sndmsg="${sndmsg} ${WARN}${SOUND_FULLNAME}\n"
397 [ -n "${SOUND_DRIVER}" ] \
398 && sndmsg="${sndmsg} driver = ${SOUND_DRIVER}\n"
399
400 einfo "${sndmsg}"
401
402
403 if [ -x /etc/init.d/alsasound ]
404 then
405 start_service alsasound
406 fi
407
408 if [ -e /proc/asound/cards ]
409 then
410 for i in $(cat /proc/asound/cards | awk '{print $1}' | grep ^[[:digit:]])
411 do
412 if [ -d /proc/asound/card$i ] && [ -x /usr/bin/amixer ]
413 then
414 amixer -c $i scontrols > /etc/amixer
415 [ -n "$(grep Master /etc/amixer)" ] \
416 && amixer -c $i -q set Master 95% unmute \
417 >/dev/null 2>&1
418 [ -n "$(grep PCM /etc/amixer)" ] \
419 && amixer -c $i -q set PCM 95% unmute \
420 >/dev/null 2>&1
421 [ -n "$(grep Mic /etc/amixer)" ] \
422 && amixer -c $i -q set Mic 95% mute cap \
423 >/dev/null 2>&1
424 [ -n "$(grep Wave /etc/amixer)" ] \
425 && amixer -c $i -q set Wave 95% unmute \
426 >/dev/null 2>&1
427 [ -n "$(grep Capture /etc/amixer)" ] \
428 && amixer -c $i -q set Capture 95% unmute cap \
429 >/dev/null 2>&1
430 fi
431 done
432 fi
433 fi
434 else
435 ewarn "Skipping ALSA detection as requested on command line ..."
436 fi
437
438 [ -n "${XDESC}" ] && einfo "VideoCard: ${HILITE}${XDESC}${NORMAL}"
439
440 if [ "${X11}" = "yes" ]
441 then
442 if [ -x /etc/init.d/mkxf86config ]
443 then
444 start_service mkxf86config
445 fi
446 if [ -x /etc/init.d/x-setup ]
447 then
448 start_service x-setup
449 fi
450 else
451 touch /etc/init.d/.noxdm
452 fi
453
454 killall hwsetup 2>/dev/null
455 echo "6" > /proc/sys/kernel/printk
456 }
457
458 # vim: ts=4

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20