/[livecd-tools]/trunk/autoconfig
Gentoo

Contents of /trunk/autoconfig

Parent Directory Parent Directory | Revision Log Revision Log


Revision 150 - (show annotations) (download)
Sat May 17 01:43:40 2008 UTC (6 years, 2 months ago) by wolf31o2
File size: 12411 byte(s)
Change nohotplug/dohotplug to nocoldplug/docoldplug to match udev-start.sh's checks.
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 COLDPLUG="yes"
11 DETECT="yes"
12 DHCP="yes"
13 DMRAID="yes"
14 EVMS="no"
15 FIREWIRE="yes"
16 GPM="yes"
17 HALD="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 COLDPLUG="no"
43 DETECT="no"
44 DMRAID="no"
45 EVMS="no"
46 FIREWIRE="no"
47 GPM="no"
48 HALD="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 nocoldplug|nohotplug)
64 COLDPLUG="no"
65 ;;
66 nodhcp)
67 DHCP="no"
68 ;;
69 nodmraid)
70 DMRAID="no"
71 ;;
72 noevms|noevms2)
73 EVMS="no"
74 ;;
75 nofirewire)
76 FIREWIRE="no"
77 ;;
78 nogpm)
79 GPM="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 docoldplug|dohotplug)
135 COLDPLUG="yes"
136 ;;
137 dodhcp)
138 DHCP="yes"
139 ;;
140 dodmraid)
141 DMRAID="yes"
142 ;;
143 doevms|doevms2)
144 EVMS="yes"
145 ;;
146 dofirewire)
147 FIREWIRE="yes"
148 ;;
149 dogpm)
150 GPM="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 ${COLDPLUG} coldplug hotplug)"
221 svcs="${svcs} $(check_svc ${GPM} gpm)"
222 svcs="${svcs} $(check_svc ${HALD} hald)"
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 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 if [ "${BRLTTY}" = "yes" ]
363 then
364 [ -x /etc/init.d/brltty ] && start_service brltty
365 fi
366
367 if [ "${DETECT}" = "yes" ]
368 then
369 ebegin "Hardware detection started"
370 local numcpu="$(grep -c '^processor[[:space:]]\+:' /proc/cpuinfo)"
371 local arch="$(uname -m)"
372
373 case ${arch} in
374 mips*)
375 detect_mips
376 ACPI="no"
377 APM="no"
378 IDEDMA="no"
379 ;;
380 i?86|x86_64)
381 detect_x86_amd64_ia64
382 ;;
383 alpha)
384 detect_alpha
385 ACPI="no"
386 APM="no"
387 ;;
388 sparc*)
389 detect_sparc
390 ACPI="no"
391 APM="no"
392 ;;
393 powerpc*)
394 detect_ppc
395 ACPI="no"
396 APM="no"
397 ;;
398 ia64)
399 detect_x86_amd64_ia64 "ia64"
400 APM="no"
401 ;;
402 *)
403 PC=
404 ;;
405 esac
406 [ -n "${PC}" ] && einfo "${PC}"
407 eend
408 else
409 ewarn "Hardware detection disabled via cmdline ..."
410 fi
411
412 # Now, we check if we are supposed to run a coldplug script.
413 if [ "${COLDPLUG}" = "yes" ]
414 then
415 # Check whether we should be using hotplug/coldplug or whether we should
416 # just let udev do it all.
417 if [ -x /etc/init.d/coldplug ]
418 then
419 start_service coldplug
420 elif [ -x /etc/init.d/hotplug ]
421 then
422 start_service hotplug
423 else
424 unpack_firmware
425 [ -x /sbin/udevtrigger ] && /sbin/udevtrigger
426 fi
427 [ -e /etc/sysconfig ] || mkdir -p /etc/sysconfig
428 [ -x /usr/sbin/hwsetup ] && hwsetup
429 else
430 ewarn "Hotplug/Coldplug disabled via cmdline ..."
431 fi
432
433 if [ "${APM}" = "yes" ]
434 then
435 modprobe apm power_off=1 >/dev/null 2>&1 && \
436 einfo "APM BIOS found, power management functions enabled ..."
437 [ -x /etc/init.d/apmd ] && start_service apmd
438 else
439 einfo "Not Loading APM Bios support ..."
440 fi
441
442 if [ "${ACPI}" = "yes" ]
443 then
444 modprobe processor >/dev/null 2>&1 && \
445 ebegin "ACPI power management functions enabled" && \
446 modprobe thermal >/dev/null
447 modprobe fan >/dev/null 2>&1
448 modprobe button >/dev/null 2>&1
449 modprobe battery >/dev/null 2>&1
450 modprobe ac >/dev/null 2>&1
451 modprobe thermal >/dev/null 2>&1
452 modprobe video >/dev/null 2>&1
453 modprobe dock >/dev/null 2>&1
454 [ -x /etc/init.d/acpid ] && start_service acpid
455 eend
456 else
457 einfo "Not Loading ACPI support ..."
458 fi
459
460 if [ "${IDEDMA}" = "yes" ]
461 then
462 [ -x /etc/init.d/hdparm ] && start_service hdparm
463 else
464 ewarn "Disabling IDE DMA support ..."
465 fi
466
467 if [ "${PCMCIA}" = "yes" ]
468 then
469 [ -x /etc/init.d/pcmcia ] && start_service pcmcia
470 else
471 ewarn "PCMCIA disabled via cmdline ..."
472 fi
473
474 if [ "${DHCP}" = "no" ]
475 then
476 sed -i -e '/^ifconfig_eth.*dhcp.*/ s/^/#/' \
477 -e '/^iface_eth.*dhcp.*/ s/^/#/' \
478 -e '/^config_eth.*dhcp.*/ s/^/#/' \
479 /etc/conf.d/net
480 for i in `seq 0 4`
481 do
482 echo "config_eth${i}=( \"none\" )" >> /etc/conf.d/net
483 done
484 ewarn "Skipping DHCP broadcast ..."
485 fi
486
487 # Read in what hwsetup has found
488 [ -f /etc/sysconfig/gentoo ] && source /etc/sysconfig/gentoo
489
490 # Mouse
491 if [ -n "${MOUSE_DEVICE}" ]
492 then
493 einfo "Mouse is ${HILITE}${MOUSE_FULLNAME}${NORMAL} at ${HILITE}${MOUSE_DEVICE}${NORMAL} ..."
494 source /etc/sysconfig/mouse
495 if [ -x /usr/sbin/gpm ]
496 then
497 if [ $(grep "#MOUSE=${MOUSETYPE}" /etc/conf.d/gpm) ]
498 then
499 sed -i "\@MOUSE=${MOUSETYPE}@s@^#@@" /etc/conf.d/gpm
500 else
501 echo "MOUSE=${MOUSETYPE}" >>/etc/conf.d/gpm
502 fi
503
504 if [ $(grep "#MOUSEDEV=${DEVICE}" /etc/conf.d/gpm) ]
505 then
506 sed -i "\@MOUSEDEV=${DEVICE}@s@^#@@" /etc/conf.d/gpm
507 else
508 echo "MOUSEDEV=${DEVICE}" >>/etc/conf.d/gpm
509 fi
510
511 [ "${GPM}" = "yes" ] \
512 && [ -x /etc/init.d/gpm ] && start_service gpm
513 fi
514 fi
515
516 [ "${DETECT}" = "no" ] && DHCP="no"
517 [ "${DETECT}" = "yes" ] \
518 && NETDEVICES="$(awk -F: '/eth.:|tr.:|ath.:|wlan.:/{print $1}' /proc/net/dev 2>/dev/null)"
519
520 if [ -n "${NETDEVICES}" ]
521 then
522 for nics in ${NETDEVICES}
523 do
524 if [ "${DHCP}" = "yes" ]
525 then
526 einfo "Network device ${HILITE}${nics}${NORMAL} detected, DHCP broadcasting for IP ..."
527 if [ -f /var/run/dhcpcd-${nics}.pid ]
528 then
529 if [ -z "$(/sbin/ifconfig ${nics} | grep 'inet addr')" ]
530 then
531 kill $(cat /var/run/dhcpcd-${nics}.pid)
532 sleep 2
533 dhcpcd -n -h $(hostname) ${nics}
534 fi
535 fi
536 fi
537 done
538 if [ "${NFS}" = "yes" ]
539 then
540 [ -x /etc/init.d/portmap ] && start_service portmap
541 [ -x /etc/init.d/nfsmount ] && start_service nfsmount
542 fi
543 if [ "${PASSWD}" = "no" ]
544 then
545 echo "root:${PASSWORD}" | chpasswd > /dev/null 2>&1
546 else
547 start_service pwgen
548 fi
549 if [ "${SSHD}" = "yes" ]
550 then
551 # If we have passwd= on the command line, we do not run pwgen and we
552 # set the root password to PASSWORD.
553 if [ "${PASSWD}" = "yes" ]
554 then
555 ewarn "WARNING: You are starting sshd with a scrambled root password!!!"
556 ewarn "WARNING: You need to set a root password to be able to login remotely."
557 fi
558 [ -x /etc/init.d/sshd ] && start_service sshd
559 fi
560 else
561 ewarn "No Network device auto detected ..."
562 fi
563
564 if [ "${ALSA}" = "yes" ]
565 then
566 if [ -n "${SOUND_FULLNAME}" -o -n "${SOUND_DRIVER}" ]
567 then
568 local sndmsg="Soundcard:\n"
569
570 [ -n "${SOUND_FULLNAME}" ] \
571 && sndmsg="${sndmsg} ${WARN}${SOUND_FULLNAME}\n"
572 [ -n "${SOUND_DRIVER}" ] \
573 && sndmsg="${sndmsg} driver = ${SOUND_DRIVER}\n"
574
575 einfo "${sndmsg}"
576
577 if [ -x /etc/init.d/alsasound ]
578 then
579 start_service alsasound
580 fi
581
582 if [ -e /proc/asound/cards ]
583 then
584 for i in $(cat /proc/asound/cards | awk '{print $1}' | grep ^[[:digit:]])
585 do
586 if [ -d /proc/asound/card$i ] && [ -x /usr/bin/amixer ]
587 then
588 amixer -c $i scontrols > /etc/amixer
589 [ -n "$(grep Master /etc/amixer)" ] \
590 && amixer -c $i -q set Master 95% unmute \
591 >/dev/null 2>&1
592 [ -n "$(grep PCM /etc/amixer)" ] \
593 && amixer -c $i -q set PCM 95% unmute \
594 >/dev/null 2>&1
595 [ -n "$(grep Mic /etc/amixer)" ] \
596 && amixer -c $i -q set Mic 95% mute cap \
597 >/dev/null 2>&1
598 [ -n "$(grep Wave /etc/amixer)" ] \
599 && amixer -c $i -q set Wave 95% unmute \
600 >/dev/null 2>&1
601 [ -n "$(grep Capture /etc/amixer)" ] \
602 && amixer -c $i -q set Capture 95% unmute cap \
603 >/dev/null 2>&1
604 fi
605 done
606 fi
607 fi
608 else
609 ewarn "Skipping ALSA detection as requested on command line ..."
610 fi
611
612 [ -n "${XDESC}" ] && einfo "VideoCard: ${HILITE}${XDESC}${NORMAL}"
613
614 if [ "${X11}" = "yes" ]
615 then
616 if [ -x /etc/init.d/mkxf86config ]
617 then
618 start_service mkxf86config
619 fi
620 if [ -x /etc/init.d/x-setup ]
621 then
622 start_service x-setup
623 fi
624 else
625 touch /etc/init.d/.noxdm
626 fi
627
628 killall hwsetup 2>/dev/null
629 echo "6" > /proc/sys/kernel/printk
630 }
631
632 # vim: ts=4

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20