/[livecd-tools]/trunk/autoconfig
Gentoo

Diff of /trunk/autoconfig

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 49 Revision 126
1#!/sbin/runscript 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.25 2005/05/12 13:04:27 wolf31o2 Exp $
5 2
6echo "0" > /proc/sys/kernel/printk
7DHCP="yes" 3DHCP="yes"
8DETECT="yes" 4DETECT="yes"
9GPM="yes" 5GPM="yes"
10PCMCIA="no" 6PCMCIA="no"
11HOTPLUG="yes" 7HOTPLUG="yes"
12APM="no" 8APM="no"
13ACPI="no" 9ACPI="no"
14IDEDMA="yes" 10IDEDMA="yes"
11ALSA="yes"
12X11="yes"
13
14get_config() {
15CMDLINE="`cat /proc/cmdline`" 15 CMDLINE="$(cat /proc/cmdline)"
16
16for x in ${CMDLINE} ; do 17 for x in ${CMDLINE} ; do
17 if [ "${x}" = "nodetect" ]; then 18 case "${x}" in
19 nodetect)
18 DETECT="no" 20 DETECT="no"
19 GPM="no" 21 GPM="no"
20 HOTPLUG="no" 22 HOTPLUG="no"
21 APM="no" 23 APM="no"
22 ACPI="no" 24 ACPI="no"
23 fi 25 ALSA="no"
24 26 X11="no"
25 if [ "${x}" = "nodhcp" ]; then 27 ;;
28 nodhcp)
26 DHCP="no" 29 DHCP="no"
27 fi 30 ;;
28 31 nogpm)
29 if [ "${x}" = "nogpm" ]; then
30 GPM="no" 32 GPM="no"
31 fi 33 ;;
32 34 dopcmcia)
33 if [ "${x}" = "dopcmcia" ]; then
34 PCMCIA="yes" 35 PCMCIA="yes"
35 fi 36 ;;
36 37 doapm)
37 if [ "${x}" = "doapm" ]; then
38 APM="yes" 38 APM="yes"
39 ACPI="no" 39 ACPI="no"
40 fi 40 ;;
41 41 acpi\=on|acpi\=force)
42 if [ "${x}" = "acpi=on" -o "${x}" = "acpi=force" ]; then
43 APM="no" 42 APM="no"
44 ACPI="yes" 43 ACPI="yes"
45 fi 44 ;;
46 45 ide\=nodma)
47 if [ "${x}" = "ide=nodma" ]; then
48 IDEDMA="no" 46 IDEDMA="no"
49 fi 47 ;;
50 48 nohotplug)
51 if [ "${x}" = "nohotplug" ]; then
52 HOTPLUG="no" 49 HOTPLUG="no"
53 fi 50 ;;
51 nosound)
52 ALSA="no"
53 ;;
54 nox)
55 X11="no"
56 ;;
57 esac
54done 58 done
59}
55 60
56depend() { 61depend() {
57 need modules 62 need modules
58 use alsasound 63 before net
59# provide gpm pcmcia apmd acpid coldplug 64# provide gpm pcmcia apmd acpid coldplug hdparm alsasound mkxf86config x-setup
65}
66
67# Checks whether a service will be started by autoconfig.
68# Usage: check_svc var service [service_alternative]
69check_svc() {
70 if [ "${1}" = "yes" ]
71 then
72 if [ -x "/etc/init.d/${2}" ]
73 then
74 echo "${2}"
75 elif [ -n "${3}" -a -x "/etc/init.d/${3}" ]
76 then
77 echo "${3}"
78 fi
79 fi
80}
81
82# Prints an ordered list of services that will be started by autoconfig.
83list_services() {
84 get_config
85
86 local svcs="$(check_svc ${APM} apmd)"
87 svcs="${svcs} $(check_svc ${ACPI} acpid)"
88 svcs="${svcs} $(check_svc ${IDEDMA} hdparm)"
89 svcs="${svcs} $(check_svc ${PCMCIA} pcmcia)"
90 svcs="${svcs} $(check_svc ${GPM} gpm)"
91 svcs="${svcs} $(check_svc ${HOTPLUG} coldplug hotplug)"
92 svcs="${svcs} $(check_svc ${ALSA} alsasound)"
93 svcs="${svcs} $(check_svc ${X11} mkxf86config x-setup)"
94
95 echo ${svcs}
96}
97
98unpack_firmware() {
99 # This unpacks any firmware tarballs.
100 # This has been moved here from coldplug, but might not be very effective
101 # since udev does coldplugging in 089 and higher.
102 if [ -e /lib/firmware.tar.bz2 ]
103 then
104 ebegin "Unpacking hotplug firmware"
105 tar xjf /lib/firmware.tar.bz2 -C /lib/firmware
106 eend 0
107 fi
108}
109
110get_info() {
111 local tmp
112
113 if [ ! -z "${1}" -a ! -z "${2}" ]
114 then
115 tmp=$(grep "^$1[[:space:]]\+:" /proc/cpuinfo | head -n 1 | cut -d" " -f3-)
116# tmp=$([[ $'\n'$(</proc/cpuinfo) =~ $'\n''$1[[:space:]]\+:' ]] | head -n 1 | cut -d" " -f3-)
117 eval "${2}='${tmp}'"
118 fi
119}
120
121detect_mips() {
122 get_info "cpu model" cpuinfo
123 get_info "system type" machinfo
124 cpuinfo="${cpuinfo%% FPU*}"
125
126 case "${machinfo}" in
127 "SGI Indigo2")
128 case "${cpuinfo}" in
129 R4*)
130 machinfo="SGI Indigo2" # I2 R4x00
131 ;;
132 R8*)
133 machinfo="SGI Indigo2 Power" # I2 R8000
134 ;;
135 R10*)
136 machinfo="SGI Indigo2 Impact" # I2 R10000
137 ;;
138 esac
139 ;;
140 esac
141
142 PC="Detected an ${machinfo} w/ ${numcpu} ${cpuinfo} CPU(s)"
143}
144
145detect_x86_amd64_ia64() {
146 if [ "${1}" = "ia64" ]
147 then
148 get_info "family" cpuinfo
149 else
150 get_info "model name" cpuinfo
151 fi
152 get_info "cpu MHz" mhz
153 mhz="${mhz%%.*}MHz"
154
155 PC="Detected ${numcpu} ${cpuinfo} CPU(s) @ ${mhz}"
156}
157
158detect_alpha() {
159 get_info "platform string" machinfo
160 get_info "cpu" cpuinfo1
161 get_info "cpu model" cpuinfo2
162 get_info "cpus detected" numcpu
163
164 PC="Detected ${numcpu} ${cpuinfo1} ${cpuinfo2} CPU(s) in a ${machinfo} system"
165}
166
167detect_ppc() {
168 get_info "cpu" cpuinfo
169 get_info "clock" mhz
170 get_info "detected as" machinfo
171 machinfo="${machinfo##*\(}"
172 machinfo="${machinfo%%\)*}"
173
174 local machtype=""
175
176 case "${machinfo}" in
177 "CHRP Pegasos2")
178 machtype="Pegasos 2"
179 ;;
180 "CHRP IBM,9124-720")
181 machtype="IBM OP720"
182 ;;
183 "iBook 2 rev. 2")
184 machtype="Apple iBook G3"
185 ;;
186 "iMac G5"*)
187 machtype="Apple iMac G5"
188 ;;
189 "MPC8241")
190 machtype="Kurobox"
191 ;;
192 "PowerMac G5")
193 machtype="Apple PowerMac G5"
194 ;;
195 "PowerMac G5 Dual Core")
196 machtype="Apple PowerMac G5 Dual Core"
197 ;;
198 "PowerMac G4 AGP Graphics")
199 machtype="Apple PowerMac G4"
200 ;;
201 "PowerBook Titanium"|'PowerBook G4 15"')
202 machtype="Apple Powerbook G4"
203 ;;
204 "Unknown Intrepid-based")
205 machtype="Apple Mac-Mini"
206 ;;
207 *)
208 machtype="Unknown PPC System"
209 ;;
210 esac
211
212 PC="Detected a(n) ${machtype} w/ ${numcpu} ${cpuinfo} CPU(s)"
213}
214
215detect_sparc() {
216 get_info "cpu" cpuinfo
217 get_info "ncpus active" numcpu
218 get_info "ncpus probed" numprobed
219
220 PC="Detected ${numcpu} active ${cpuinfo} CPU(s) of ${numprobed} total"
60} 221}
61 222
62start() { 223start() {
224 echo "0" > /proc/sys/kernel/printk
225 get_config
63 if [ "${DETECT}" = "yes" ]; then 226 if [ "${DETECT}" = "yes" ]
227 then
64 ebegin ${WARN}"Hardware detection started" 228 ebegin "Hardware detection started"
65 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` 229 local numcpu="$(grep -c '^processor[[:space:]]\+:' /proc/cpuinfo)"
66 ebegin ${GOOD}"${PC}" 230# local numcpu=$([[ $'\n'$(</proc/cpuinfo) =~ $'\n''processor[[:space:]]\+:' ]] | wc -l)
67 eend 231 local arch="$(uname -m)"
232
233 case ${arch} in
234 mips*)
235 detect_mips
236 ACPI="no"
237 APM="no"
238 IDEDMA="no"
239 ;;
240 i?86|x86_64)
241 detect_x86_amd64_ia64
242 ;;
243 alpha)
244 detect_alpha
245 ACPI="no"
246 APM="no"
247 ;;
248 sparc*)
249 detect_sparc
250 ACPI="no"
251 APM="no"
252 ;;
253 powerpc*)
254 detect_ppc
255 ACPI="no"
256 APM="no"
257 ;;
258 ia64)
259 detect_x86_amd64_ia64 "ia64"
260 APM="no"
261 ;;
262 *)
263 PC=
264 ;;
265 esac
266 [ -n "${PC}" ] && einfo "${PC}"
68 [ -x /usr/sbin/hwsetup ] && hwsetup -p >/dev/null 267 [ -x /usr/sbin/hwsetup ] && hwsetup -p >/dev/null
69 eend 268 eend
70 else 269 else
71 ebegin ${WARN}"Hardware detection disabled via cmdline$NORMAL" 270 ewarn "Hardware detection disabled via cmdline ..."
72 fi 271 fi
73 272
74 if [ "${APM}" = "yes" ]; then 273 if [ "${APM}" = "yes" ]
75 modprobe apm power_off=1 >/dev/null 2>&1 && ebegin ${GOOD}"APM BIOS found, power management functions enabled.${NORMAL}" 274 then
76 [ -x /etc/init.d/apmd ] && /etc/init.d/apmd start 275 modprobe apm power_off=1 >/dev/null 2>&1 && \
276 einfo "APM BIOS found, power management functions enabled ..."
277 [ -x /etc/init.d/apmd ] && start_service apmd
77 else 278 else
78 ebegin ${GOOD}"Not Loading APM Bios support.${NORMAL}" 279 einfo "Not Loading APM Bios support ..."
79 eend
80 fi 280 fi
81 281
82 if [ "${ACPI}" = "yes" ]; then 282 if [ "${ACPI}" = "yes" ]
83 modprobe processor >/dev/null 2>&1 && ebegin ${GOOD} ACPI power management functions enabled.${NORMAL} && modprobe thermal >/dev/null 283 then
284 modprobe processor >/dev/null 2>&1 && \
285 ebegin "ACPI power management functions enabled" && \
286 modprobe thermal >/dev/null
84 modprobe fan >/dev/null 2>&1 287 modprobe fan >/dev/null 2>&1
85 modprobe button >/dev/null 2>&1 288 modprobe button >/dev/null 2>&1
86 modprobe battery >/dev/null 2>&1 289 modprobe battery >/dev/null 2>&1
87 modprobe ac >/dev/null 2>&1 290 modprobe ac >/dev/null 2>&1
88 [ -x /etc/init.d/acpid ] && /etc/init.d/acpid start 291 [ -x /etc/init.d/acpid ] && start_service acpid
89 eend 292 eend
293 else
294 einfo "Not Loading ACPI support ..."
90 fi 295 fi
91 296
92 if [ "${IDEDMA}" = "yes" ]; then 297 if [ "${IDEDMA}" = "yes" ]
93 [ -x /etc/init.d/hdparm ] && /etc/init.d/hdparm start 298 then
299 [ -x /etc/init.d/hdparm ] && start_service hdparm
94 fi 300 fi
95 301
96 if [ "${PCMCIA}" = "yes" ]; then 302 if [ "${PCMCIA}" = "yes" ]
303 then
97 ebegin ${HILITE} "PCMCIA enabled via cmdline" 304 einfo "PCMCIA enabled via cmdline ..."
98 /etc/init.d/pcmcia start 305 [ -x /etc/init.d/pcmcia ] && start_service pcmcia
99 fi 306 fi
100 307
101 if [ "${DHCP}" = "no" ]; then 308 if [ "${DHCP}" = "no" ]
309 then
102 sed -i -e '/^ifconfig_eth.*dhcp.*/ s/^/#/' \ 310 sed -i -e '/^ifconfig_eth.*dhcp.*/ s/^/#/' \
103 -e '/^iface_eth.*dhcp.*/ s/^/#/' \ 311 -e '/^iface_eth.*dhcp.*/ s/^/#/' \
312 -e '/^config_eth.*dhcp.*/ s/^/#/' \
104 /etc/conf.d/net 313 /etc/conf.d/net
314 for i in `seq 0 4`
315 do
316 echo "config_eth$i=( \"none\" )" >> /etc/conf.d/net
317 done
105 ebegin ${BAD}"Skipping DHCP broadcast detection as requested on boot commandline." 318 ewarn "Skipping DHCP broadcast detection as requested on boot commandline ..."
106 fi 319 fi
107 320
108 #Read in what hwsetup has found 321 # Read in what hwsetup has found
109 [ -f /etc/sysconfig/knoppix ] && . /etc/sysconfig/knoppix 322 [ -f /etc/sysconfig/gentoo ] && . /etc/sysconfig/gentoo
110 323
111 # Mouse 324 # Mouse
112 if [ -n "${MOUSE_DEVICE}" ]; then 325 if [ -n "${MOUSE_DEVICE}" ]
326 then
113 ebegin ${GOOD}"Mouse is ${HILITE}${MOUSE_FULLNAME}${GOOD} at ${HILITE}${MOUSE_DEVICE}${NORMAL}" 327 einfo "Mouse is ${HILITE}${MOUSE_FULLNAME}${NORMAL} at ${HILITE}${MOUSE_DEVICE}${NORMAL} ..."
114 source /etc/sysconfig/mouse 328 source /etc/sysconfig/mouse
115 if [ -x /usr/sbin/gpm ]; then 329 if [ -x /usr/sbin/gpm ]
330 then
116 if [ `grep "#MOUSE=${MOUSETYPE}" /etc/conf.d/gpm` ]; then 331 if [ $(grep "#MOUSE=${MOUSETYPE}" /etc/conf.d/gpm) ]
332# if [ $([[ $'\n'$(</etc/conf.d/gpm) =~ $'\n''#MOUSE=${MOUSETYPE}' ]]) ]
333 then
117 sed -i "\@MOUSE=${MOUSETYPE}@s@^#@@" /etc/conf.d/gpm 334 sed -i "\@MOUSE=${MOUSETYPE}@s@^#@@" /etc/conf.d/gpm
118 else 335 else
119 echo "MOUSE=${MOUSETYPE}" >>/etc/conf.d/gpm 336 echo "MOUSE=${MOUSETYPE}" >>/etc/conf.d/gpm
120 fi 337 fi
338
121 if [ `grep "#MOUSEDEV=${DEVICE}" /etc/conf.d/gpm` ]; then 339 if [ $(grep "#MOUSEDEV=${DEVICE}" /etc/conf.d/gpm) ]
340# if [ $([[ $'\n'$(</etc/conf.d/gpm) =~ $'\n''#MOUSEDEV=${DEVICE}' ]]) ]
341 then
122 sed -i "\@MOUSEDEV=${DEVICE}@s@^#@@" /etc/conf.d/gpm 342 sed -i "\@MOUSEDEV=${DEVICE}@s@^#@@" /etc/conf.d/gpm
123 else 343 else
124 echo "MOUSEDEV=${DEVICE}" >>/etc/conf.d/gpm 344 echo "MOUSEDEV=${DEVICE}" >>/etc/conf.d/gpm
125 fi 345 fi
346
347 [ "${GPM}" = "yes" ] \
348 && [ -x /etc/init.d/gpm ] && start_service gpm
349 fi
350 fi
351
352 # First off, we want hotplug/coldplug enabled, so let's re-enable it. We do
353 # this even if we aren't startup up the hotplug/coldplug services for the
354 # installer.
355 sed -i 's/RC_COLDPLUG="no"/RC_COLDPLUG="yes"/' /etc/conf.d/rc
356 # Now, we check if we're supposed to run a coldplug script.
357 if [ "${HOTPLUG}" = "yes" ]
358 then
359 # Check whether we should be using hotplug or coldplug
360 if [ -x /etc/init.d/coldplug ]
361 then
362 start_service coldplug
363 elif [ -x /etc/init.d/hotplug ]
364 then
365 start_service hotplug
366 else
367 unpack_firmware
368 [ -x /sbin/udevtrigger ] && /sbin/udevtrigger
369 fi
370 else
371 ewarn "Hotplug/Coldplug disabled via cmdline ..."
372 fi
373
374 [ "${DETECT}" = "no" ] && DHCP="no"
375 [ "${DETECT}" = "yes" ] \
376 && NETDEVICES="$(awk -F: '/eth.:|tr.:|ath.:|wlan.:/{print $1}' /proc/net/dev 2>/dev/null)"
377
378 if [ -n "${NETDEVICES}" ]
379 then
380 for nics in ${NETDEVICES}
381 do
126 if [ "$GPM" = "yes" ]; then 382 if [ "${DHCP}" = "yes" ]
127 [ -x /etc/init.d/gpm ] && /etc/init.d/gpm start 383 then
384 einfo "Network device ${HILITE}${nics}${NORMAL} detected, DHCP broadcasting for IP ..."
385 fi
386 done
387 else
388 ewarn "No Network device auto detected ..."
389 fi
390
391 if [ "${ALSA}" = "yes" ]
392 then
393 if [ -n "${SOUND_FULLNAME}" -o -n "${SOUND_DRIVER}" ]
394 then
395 local sndmsg="Soundcard:\n"
396
397 [ -n "${SOUND_FULLNAME}" ] \
398 && sndmsg="${sndmsg} ${WARN}${SOUND_FULLNAME}\n"
399 [ -n "${SOUND_DRIVER}" ] \
400 && sndmsg="${sndmsg} driver = ${SOUND_DRIVER}\n"
401
402 einfo "${sndmsg}"
403
404 if [ -x /etc/init.d/alsasound ]
405 then
406 start_service alsasound
407 fi
408
409 if [ -e /proc/asound/cards ]
410 then
411 for i in $(cat /proc/asound/cards | awk '{print $1}' | grep ^[[:digit:]])
412 do
413 if [ -d /proc/asound/card$i ] && [ -x /usr/bin/amixer ]
414 then
415 amixer -c $i scontrols > /etc/amixer
416 [ -n "$(grep Master /etc/amixer)" ] \
417 && amixer -c $i -q set Master 95% unmute \
418 >/dev/null 2>&1
419 [ -n "$(grep PCM /etc/amixer)" ] \
420 && amixer -c $i -q set PCM 95% unmute \
421 >/dev/null 2>&1
422 [ -n "$(grep Mic /etc/amixer)" ] \
423 && amixer -c $i -q set Mic 95% mute cap \
424 >/dev/null 2>&1
425 [ -n "$(grep Wave /etc/amixer)" ] \
426 && amixer -c $i -q set Wave 95% unmute \
427 >/dev/null 2>&1
428 [ -n "$(grep Capture /etc/amixer)" ] \
429 && amixer -c $i -q set Capture 95% unmute cap \
430 >/dev/null 2>&1
431 fi
432 done
128 fi 433 fi
129 fi 434 fi
130 eend
131 fi
132
133 if [ "${HOTPLUG}" = "yes" ]; then
134 #Check whether we should be using hotplug or coldplug
135 if [ -x /etc/init.d/coldplug ]; then
136 /etc/init.d/coldplug start
137 else 435 else
138 [ -x /etc/init.d/hotplug ] && /etc/init.d/hotplug start 436 ewarn "Skipping ALSA detection as requested on command line ..."
437 fi
438
439 [ -n "${XDESC}" ] && einfo "VideoCard: ${HILITE}${XDESC}${NORMAL}"
440
441 if [ "${X11}" = "yes" ]
442 then
443 if [ -x /etc/init.d/mkxf86config ]
444 then
445 start_service mkxf86config
139 fi 446 fi
140 else 447 if [ -x /etc/init.d/x-setup ]
141 ebegin ${BAD}"Hotplug disabled via cmdline${NORMAL}" 448 then
142 fi 449 start_service x-setup
143
144 if [ "${DETECT}" = "no" ]; then
145 DHCP="no"
146 fi
147
148 if [ "${DETECT}" = "yes" ]; then
149 NETDEVICES="`awk -F: '/eth.:|tr.:/{print $1}' /proc/net/dev 2>/dev/null`"
150 fi
151
152 if [ -n "${NETDEVICES}" ]; then
153 if [ "${DHCP}" = "yes" ]; then
154 ebegin ${GOOD}"Network device${HILITE}${NETDEVICES}${GOOD} detected,${WARN} DHCP broadcasting for IP.${NORMAL}"
155 dhcpcd -h $(hostname) &
156 fi 450 fi
157 eend
158
159 else 451 else
160 ebegin ${BAD}"No Network device auto detected.${NORMAL}" 452 touch /etc/init.d/.noxdm
161 fi
162
163
164 if [ -n "${SOUND_FULLNAME}" -o -n "${SOUND_DRIVER}" ]; then
165 ebegin ${GOOD}"Soundcard:"
166 eend
167 [ -n "${SOUND_FULLNAME}" ]
168 ebegin " ${WARN}${SOUND_FULLNAME}"
169 [ -n "${SOUND_DRIVER}" ]
170 ebegin ${WARN}" driver = ${SOUND_DRIVER}"${HILITE}
171 if [ -d /proc/asound/card0 ] && [ -x /usr/bin/amixer ]; then
172 amixer scontrols > /etc/amixer
173 if [ -n "`grep Master /etc/amixer`" ]
174 then
175 amixer -q set Master 95% unmute >/dev/null 2>&1
176 fi
177 if [ -n "`grep PCM /etc/amixer`" ]
178 then
179 amixer -q set PCM 95% unmute >/dev/null 2>&1
180 fi
181 if [ -n "`grep Mic /etc/amixer`" ]
182 then
183 amixer -q set Mic 95% unmute cap >/dev/null 2>&1
184 fi
185 if [ -n "`grep Wave /etc/amixer`" ]
186 then
187 amixer -q set Wave 95% unmute >/dev/null 2>&1
188 fi
189 if [ -n "`grep Capture /etc/amixer`" ]
190 then
191 amixer -q set Capture 95% unmute cap >/dev/null 2>&1
192 fi
193 fi
194 fi
195
196
197 if [ -n "${XDESC}" -o -n "${XDESC}" ]; then
198 ebegin ${GOOD}"VideoCard: ${WARN} ${XDESC}"
199 eend
200 fi 453 fi
201 454
202 killall hwsetup 2>/dev/null 455 killall hwsetup 2>/dev/null
203 echo "6" > /proc/sys/kernel/printk 456 echo "6" > /proc/sys/kernel/printk
204
205} 457}
206 458
207# vim: ts=4 459# vim: ts=4

Legend:
Removed from v.49  
changed lines
  Added in v.126

  ViewVC Help
Powered by ViewVC 1.1.20