/[livecd-tools]/trunk/autoconfig
Gentoo

Contents of /trunk/autoconfig

Parent Directory Parent Directory | Revision Log Revision Log


Revision 144 - (show annotations) (download)
Tue Feb 26 22:04:01 2008 UTC (6 years, 10 months ago) by wolf31o2
File size: 12503 byte(s)
Fix up some usages of single and double quotes.
1 #!/sbin/runscript
2
3 # This script is used by Gentoo release media to start certain services and to
4 # ensure a sane setup for a CD-based boot.
5
6 ACPI="yes"
7 ALSA="yes"
8 APM="no"
9 BRLTTY="no"
10 DETECT="yes"
11 DHCP="yes"
12 DMRAID="yes"
13 EVMS="no"
14 FIREWIRE="yes"
15 GPM="yes"
16 HALD="yes"
17 HOTPLUG="yes"
18 IDEDMA="yes"
19 LVM="no"
20 MDADM="yes"
21 NET="yes"
22 NFS="yes"
23 PASSWD="yes"
24 PATA="yes"
25 PCMCIA="yes"
26 SATA="yes"
27 SCSI="no"
28 SSHD="no"
29 USB="yes"
30 X11="yes"
31
32 get_config() {
33 CMDLINE="$(cat /proc/cmdline)"
34
35 for x in ${CMDLINE} ; do
36 case "${x}" in
37 # We put nodetect first, so we can override it with do* commands
38 nodetect)
39 ACPI="no"
40 ALSA="no"
41 APM="no"
42 DETECT="no"
43 DMRAID="no"
44 EVMS="no"
45 FIREWIRE="no"
46 GPM="no"
47 HALD="no"
48 HOTPLUG="no"
49 LVM="no"
50 MDADM="no"
51 NET="no"
52 NFS="no"
53 PCMCIA="no"
54 PATA="no"
55 SATA="no"
56 SCSI="no"
57 USB="no"
58 X11="no"
59 ;;
60 noapm)
61 APM="no"
62 ;;
63 nodhcp)
64 DHCP="no"
65 ;;
66 nodmraid)
67 DMRAID="no"
68 ;;
69 noevms|noevms2)
70 EVMS="no"
71 ;;
72 nofirewire)
73 FIREWIRE="no"
74 ;;
75 nogpm)
76 GPM="no"
77 ;;
78 nohotplug)
79 HOTPLUG="no"
80 ;;
81 noload=*)
82 NOLOAD="$*"
83 ;;
84 nolvm|nolvm2)
85 LVM="no"
86 ;;
87 nomdadm)
88 MDADM="no"
89 ;;
90 nonet)
91 NET="no"
92 ;;
93 nonfs)
94 NFS="no"
95 ;;
96 nopata)
97 PATA="no"
98 ;;
99 nopcmcia)
100 PCMCIA="no"
101 ;;
102 nosata)
103 SATA="no"
104 ;;
105 noscsi)
106 SCSI="no"
107 ;;
108 nosshd)
109 SSHD="no"
110 ;;
111 nosound)
112 ALSA="no"
113 ;;
114 nousb)
115 USB="no"
116 ;;
117 nox)
118 X11="no"
119 ;;
120 acpi\=on|acpi\=force)
121 ACPI="yes"
122 APM="no"
123 ;;
124 brltty=*)
125 BRLTTY="yes"
126 ;;
127 ide\=nodma)
128 IDEDMA="no"
129 ;;
130 doapm)
131 ACPI="no"
132 APM="yes"
133 ;;
134 dodhcp)
135 DHCP="yes"
136 ;;
137 dodmraid)
138 DMRAID="yes"
139 ;;
140 doevms|doevms2)
141 EVMS="yes"
142 ;;
143 dofirewire)
144 FIREWIRE="yes"
145 ;;
146 dogpm)
147 GPM="yes"
148 ;;
149 dohotplug)
150 HOTPLUG="yes"
151 ;;
152 dolvm|dolvm2)
153 LVM="yes"
154 ;;
155 domdadm)
156 MDADM="yes"
157 ;;
158 donet)
159 NET="yes"
160 ;;
161 dopata)
162 PATA="yes"
163 ;;
164 dopcmcia)
165 PCMCIA="yes"
166 ;;
167 dosata)
168 SATA="yes"
169 ;;
170 doscsi)
171 SCSI="yes"
172 ;;
173 dosshd)
174 SSHD="yes"
175 ;;
176 dosound)
177 SOUND="yes"
178 ;;
179 dousb)
180 USE="yes"
181 ;;
182 dox)
183 X11="yes"
184 ;;
185 passwd=*)
186 PASSWD="no"
187 PASSWORD="$*"
188 ;;
189 esac
190 done
191 }
192
193 depend() {
194 need modules
195 before net
196 }
197
198 # Checks whether a service will be started by autoconfig.
199 # Usage: check_svc var service [service_alternative]
200 check_svc() {
201 if [ "${1}" = "yes" ]
202 then
203 if [ -x "/etc/init.d/${2}" ]
204 then
205 echo "${2}"
206 elif [ -n "${3}" -a -x "/etc/init.d/${3}" ]
207 then
208 echo "${3}"
209 fi
210 fi
211 }
212
213 # Prints an ordered list of services that will be started by autoconfig.
214 list_services() {
215 get_config
216
217 local svcs="$(check_svc ${ACPI} acpid)"
218 svcs="${svcs} $(check_svc ${ALSA} alsasound)"
219 svcs="${svcs} $(check_svc ${APM} apmd)"
220 svcs="${svcs} $(check_svc ${GPM} gpm)"
221 svcs="${svcs} $(check_svc ${HALD} hald)"
222 svcs="${svcs} $(check_svc ${HOTPLUG} coldplug hotplug)"
223 svcs="${svcs} $(check_svc ${IDEDMA} hdparm)"
224 svcs="${svcs} $(check_svc ${NFS} nfsmount)"
225 svcs="${svcs} $(check_svc ${PASSWD} pwgen"
226 svcs="${svcs} $(check_svc ${PCMCIA} pcmcia)"
227 svcs="${svcs} $(check_svc ${SSH} sshd)"
228 svcs="${svcs} $(check_svc ${X11} mkxf86config x-setup)"
229
230 ### TODO: make this baselayout-2 compatible
231 ### TODO: make these checks accurate using service dependencies
232
233 echo ${svcs}
234 }
235
236 unpack_firmware() {
237 # This unpacks any firmware tarballs.
238 if [ -e /lib/firmware.tar.bz2 ]
239 then
240 ebegin "Unpacking hotplug firmware"
241 tar xjf /lib/firmware.tar.bz2 -C /lib/firmware
242 eend 0
243 fi
244 }
245
246 get_info() {
247 local tmp
248
249 if [ ! -z "${1}" -a ! -z "${2}" ]
250 then
251 tmp=$(grep "^$1[[:space:]]\+:" /proc/cpuinfo | head -n 1 | cut -d" " -f3-)
252 eval "${2}='${tmp}'"
253 fi
254 }
255
256 detect_mips() {
257 get_info "cpu model" cpuinfo
258 get_info "system type" machinfo
259 cpuinfo="${cpuinfo%% FPU*}"
260
261 case "${machinfo}" in
262 "SGI Indigo2")
263 case "${cpuinfo}" in
264 R4*)
265 machinfo="SGI Indigo2" # I2 R4x00
266 ;;
267 R8*)
268 machinfo="SGI Indigo2 Power" # I2 R8000
269 ;;
270 R10*)
271 machinfo="SGI Indigo2 Impact" # I2 R10000
272 ;;
273 esac
274 ;;
275 esac
276
277 PC="Detected an ${machinfo} w/ ${numcpu} ${cpuinfo} CPU(s)"
278 }
279
280 detect_x86_amd64_ia64() {
281 if [ "${1}" = "ia64" ]
282 then
283 get_info "family" cpuinfo
284 else
285 get_info "model name" cpuinfo
286 fi
287 get_info "cpu MHz" mhz
288 mhz="${mhz%%.*}MHz"
289
290 PC="Detected ${numcpu} ${cpuinfo} CPU(s) @ ${mhz}"
291 }
292
293 detect_alpha() {
294 get_info "platform string" machinfo
295 get_info "cpu" cpuinfo1
296 get_info "cpu model" cpuinfo2
297 get_info "cpus detected" numcpu
298
299 PC="Detected ${numcpu} ${cpuinfo1} ${cpuinfo2} CPU(s) in a ${machinfo} system"
300 }
301
302 detect_ppc() {
303 get_info "cpu" cpuinfo
304 get_info "clock" mhz
305 get_info "detected as" machinfo
306 machinfo="${machinfo##*\(}"
307 machinfo="${machinfo%%\)*}"
308
309 local machtype=""
310
311 case "${machinfo}" in
312 "CHRP Pegasos2")
313 machtype="Pegasos 2"
314 ;;
315 "CHRP IBM,9124-720")
316 machtype="IBM OP720"
317 ;;
318 "iBook 2 rev. 2")
319 machtype="Apple iBook G3"
320 ;;
321 "iMac G5"*)
322 machtype="Apple iMac G5"
323 ;;
324 "MPC8241")
325 machtype="Kurobox"
326 ;;
327 "PowerMac G5")
328 machtype="Apple PowerMac G5"
329 ;;
330 "PowerMac G5 Dual Core")
331 machtype="Apple PowerMac G5 Dual Core"
332 ;;
333 "PowerMac G4 AGP Graphics")
334 machtype="Apple PowerMac G4"
335 ;;
336 "PowerBook Titanium"|"PowerBook G4 15\"")
337 machtype="Apple Powerbook G4"
338 ;;
339 "Unknown Intrepid-based")
340 machtype="Apple Mac-Mini"
341 ;;
342 *)
343 machtype="Unknown PPC System"
344 ;;
345 esac
346
347 PC="Detected a(n) ${machtype} w/ ${numcpu} ${cpuinfo} CPU(s)"
348 }
349
350 detect_sparc() {
351 get_info "cpu" cpuinfo
352 get_info "ncpus active" numcpu
353 get_info "ncpus probed" numprobed
354
355 PC="Detected ${numcpu} active ${cpuinfo} CPU(s) of ${numprobed} total"
356 }
357
358 start() {
359 echo "0" > /proc/sys/kernel/printk
360 get_config
361
362 # First off, we want hotplug/coldplug enabled, so we re-enable it.
363 # We do this even if we are not starting up the hotplug/coldplug
364 # services for the installer.
365 sed -i 's/RC_COLDPLUG="no"/RC_COLDPLUG="yes"/' /etc/conf.d/rc
366
367 if [ "${BRLTTY}" = "yes" ]
368 then
369 [ -x /etc/init.d/brltty ] && start_service brltty
370 fi
371
372 if [ "${DETECT}" = "yes" ]
373 then
374 ebegin "Hardware detection started"
375 local numcpu="$(grep -c '^processor[[:space:]]\+:' /proc/cpuinfo)"
376 local arch="$(uname -m)"
377
378 case ${arch} in
379 mips*)
380 detect_mips
381 ACPI="no"
382 APM="no"
383 IDEDMA="no"
384 ;;
385 i?86|x86_64)
386 detect_x86_amd64_ia64
387 ;;
388 alpha)
389 detect_alpha
390 ACPI="no"
391 APM="no"
392 ;;
393 sparc*)
394 detect_sparc
395 ACPI="no"
396 APM="no"
397 ;;
398 powerpc*)
399 detect_ppc
400 ACPI="no"
401 APM="no"
402 ;;
403 ia64)
404 detect_x86_amd64_ia64 "ia64"
405 APM="no"
406 ;;
407 *)
408 PC=
409 ;;
410 esac
411 [ -n "${PC}" ] && einfo "${PC}"
412 eend
413 else
414 ewarn "Hardware detection disabled via cmdline ..."
415 fi
416
417 # Now, we check if we are supposed to run a coldplug script.
418 if [ "${HOTPLUG}" = "yes" ]
419 then
420 # Check whether we should be using hotplug/coldplug or whether we should
421 # just let udev do it all.
422 if [ -x /etc/init.d/coldplug ]
423 then
424 start_service coldplug
425 elif [ -x /etc/init.d/hotplug ]
426 then
427 start_service hotplug
428 else
429 unpack_firmware
430 [ -x /sbin/udevtrigger ] && /sbin/udevtrigger
431 fi
432 [ -x /usr/sbin/hwsetup ] && hwsetup
433 else
434 ewarn "Hotplug/Coldplug disabled via cmdline ..."
435 fi
436
437 if [ "${APM}" = "yes" ]
438 then
439 modprobe apm power_off=1 >/dev/null 2>&1 && \
440 einfo "APM BIOS found, power management functions enabled ..."
441 [ -x /etc/init.d/apmd ] && start_service apmd
442 else
443 einfo "Not Loading APM Bios support ..."
444 fi
445
446 if [ "${ACPI}" = "yes" ]
447 then
448 modprobe processor >/dev/null 2>&1 && \
449 ebegin "ACPI power management functions enabled" && \
450 modprobe thermal >/dev/null
451 modprobe fan >/dev/null 2>&1
452 modprobe button >/dev/null 2>&1
453 modprobe battery >/dev/null 2>&1
454 modprobe ac >/dev/null 2>&1
455 modprobe thermal >/dev/null 2>&1
456 modprobe video >/dev/null 2>&1
457 modprobe dock >/dev/null 2>&1
458 [ -x /etc/init.d/acpid ] && start_service acpid
459 eend
460 else
461 einfo "Not Loading ACPI support ..."
462 fi
463
464 if [ "${IDEDMA}" = "yes" ]
465 then
466 [ -x /etc/init.d/hdparm ] && start_service hdparm
467 else
468 ewarn "Disabling IDE DMA support ..."
469 fi
470
471 if [ "${PCMCIA}" = "yes" ]
472 then
473 [ -x /etc/init.d/pcmcia ] && start_service pcmcia
474 else
475 ewarn "PCMCIA disabled via cmdline ..."
476 fi
477
478 if [ "${DHCP}" = "no" ]
479 then
480 sed -i -e '/^ifconfig_eth.*dhcp.*/ s/^/#/' \
481 -e '/^iface_eth.*dhcp.*/ s/^/#/' \
482 -e '/^config_eth.*dhcp.*/ s/^/#/' \
483 /etc/conf.d/net
484 for i in `seq 0 4`
485 do
486 echo "config_eth${i}=( \"none\" )" >> /etc/conf.d/net
487 done
488 ewarn "Skipping DHCP broadcast ..."
489 fi
490
491 # Read in what hwsetup has found
492 [ -f /etc/sysconfig/gentoo ] && source /etc/sysconfig/gentoo
493
494 # Mouse
495 if [ -n "${MOUSE_DEVICE}" ]
496 then
497 einfo "Mouse is ${HILITE}${MOUSE_FULLNAME}${NORMAL} at ${HILITE}${MOUSE_DEVICE}${NORMAL} ..."
498 source /etc/sysconfig/mouse
499 if [ -x /usr/sbin/gpm ]
500 then
501 if [ $(grep "#MOUSE=${MOUSETYPE}" /etc/conf.d/gpm) ]
502 then
503 sed -i "\@MOUSE=${MOUSETYPE}@s@^#@@" /etc/conf.d/gpm
504 else
505 echo "MOUSE=${MOUSETYPE}" >>/etc/conf.d/gpm
506 fi
507
508 if [ $(grep "#MOUSEDEV=${DEVICE}" /etc/conf.d/gpm) ]
509 then
510 sed -i "\@MOUSEDEV=${DEVICE}@s@^#@@" /etc/conf.d/gpm
511 else
512 echo "MOUSEDEV=${DEVICE}" >>/etc/conf.d/gpm
513 fi
514
515 [ "${GPM}" = "yes" ] \
516 && [ -x /etc/init.d/gpm ] && start_service gpm
517 fi
518 fi
519
520 [ "${DETECT}" = "no" ] && DHCP="no"
521 [ "${DETECT}" = "yes" ] \
522 && NETDEVICES="$(awk -F: '/eth.:|tr.:|ath.:|wlan.:/{print $1}' /proc/net/dev 2>/dev/null)"
523
524 if [ -n "${NETDEVICES}" ]
525 then
526 for nics in ${NETDEVICES}
527 do
528 if [ "${DHCP}" = "yes" ]
529 then
530 einfo "Network device ${HILITE}${nics}${NORMAL} detected, DHCP broadcasting for IP ..."
531 if [ -f /var/run/dhcpcd-${nics}.pid ]
532 then
533 if [ -z "$(/sbin/ifconfig ${nics} | grep 'inet addr')" ]
534 then
535 kill $(cat /var/run/dhcpcd-${nics}.pid)
536 sleep 2
537 dhcpcd -n -h $(hostname) ${nics}
538 fi
539 fi
540 fi
541 done
542 [ "${NFS}" = "yes" ] \
543 && [ -x /etc/init.d/nfsmount ] && start_service nfsmount
544 if [ "${PASSWD}" = "no" ]
545 then
546 echo "root:${PASSWORD}" | chpasswd > /dev/null 2>&1
547 else
548 start_service pwgen
549 fi
550 if [ "${SSHD}" = "yes" ]
551 then
552 # If we have passwd= on the command line, we do not run pwgen and we
553 # set the root password to PASSWORD.
554 if [ "${PASSWD}" = "yes" ]
555 then
556 ewarn "WARNING: You are starting sshd with a scrambled root password!!!"
557 ewarn "WARNING: You need to set a root password to be able to login remotely."
558 fi
559 [ -x /etc/init.d/sshd ] && start_service sshd
560 fi
561 else
562 ewarn "No Network device auto detected ..."
563 fi
564
565 if [ "${ALSA}" = "yes" ]
566 then
567 if [ -n "${SOUND_FULLNAME}" -o -n "${SOUND_DRIVER}" ]
568 then
569 local sndmsg="Soundcard:\n"
570
571 [ -n "${SOUND_FULLNAME}" ] \
572 && sndmsg="${sndmsg} ${WARN}${SOUND_FULLNAME}\n"
573 [ -n "${SOUND_DRIVER}" ] \
574 && sndmsg="${sndmsg} driver = ${SOUND_DRIVER}\n"
575
576 einfo "${sndmsg}"
577
578 if [ -x /etc/init.d/alsasound ]
579 then
580 start_service alsasound
581 fi
582
583 if [ -e /proc/asound/cards ]
584 then
585 for i in $(cat /proc/asound/cards | awk '{print $1}' | grep ^[[:digit:]])
586 do
587 if [ -d /proc/asound/card$i ] && [ -x /usr/bin/amixer ]
588 then
589 amixer -c $i scontrols > /etc/amixer
590 [ -n "$(grep Master /etc/amixer)" ] \
591 && amixer -c $i -q set Master 95% unmute \
592 >/dev/null 2>&1
593 [ -n "$(grep PCM /etc/amixer)" ] \
594 && amixer -c $i -q set PCM 95% unmute \
595 >/dev/null 2>&1
596 [ -n "$(grep Mic /etc/amixer)" ] \
597 && amixer -c $i -q set Mic 95% mute cap \
598 >/dev/null 2>&1
599 [ -n "$(grep Wave /etc/amixer)" ] \
600 && amixer -c $i -q set Wave 95% unmute \
601 >/dev/null 2>&1
602 [ -n "$(grep Capture /etc/amixer)" ] \
603 && amixer -c $i -q set Capture 95% unmute cap \
604 >/dev/null 2>&1
605 fi
606 done
607 fi
608 fi
609 else
610 ewarn "Skipping ALSA detection as requested on command line ..."
611 fi
612
613 [ -n "${XDESC}" ] && einfo "VideoCard: ${HILITE}${XDESC}${NORMAL}"
614
615 if [ "${X11}" = "yes" ]
616 then
617 if [ -x /etc/init.d/mkxf86config ]
618 then
619 start_service mkxf86config
620 fi
621 if [ -x /etc/init.d/x-setup ]
622 then
623 start_service x-setup
624 fi
625 else
626 touch /etc/init.d/.noxdm
627 fi
628
629 killall hwsetup 2>/dev/null
630 echo "6" > /proc/sys/kernel/printk
631 }
632
633 # vim: ts=4

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20