/[livecd-tools]/trunk/autoconfig
Gentoo

Diff of /trunk/autoconfig

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

Revision 49 Revision 113
1#!/sbin/runscript 1#!/sbin/runscript
2# Copyright 1999-2005 Gentoo Foundation 2# Copyright 1999-2005 Gentoo Foundation
3# Distributed under the terms of the GNU General Public License v2 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 $ 4# $Header: /var/cvsroot/gentoo/src/livecd-tools/autoconfig,v 1.64 2006/07/14 02:27:45 wolf31o2 Exp $
5 5
6echo "0" > /proc/sys/kernel/printk
7DHCP="yes" 6DHCP="yes"
8DETECT="yes" 7DETECT="yes"
9GPM="yes" 8GPM="yes"
10PCMCIA="no" 9PCMCIA="no"
11HOTPLUG="yes" 10HOTPLUG="yes"
12APM="no" 11APM="no"
13ACPI="no" 12ACPI="no"
14IDEDMA="yes" 13IDEDMA="yes"
14ALSA="yes"
15X11="yes"
16
17get_config() {
15CMDLINE="`cat /proc/cmdline`" 18 CMDLINE="$(cat /proc/cmdline)"
19
16for x in ${CMDLINE} ; do 20 for x in ${CMDLINE} ; do
17 if [ "${x}" = "nodetect" ]; then 21 case "${x}" in
22 nodetect)
18 DETECT="no" 23 DETECT="no"
19 GPM="no" 24 GPM="no"
20 HOTPLUG="no" 25 HOTPLUG="no"
21 APM="no" 26 APM="no"
22 ACPI="no" 27 ACPI="no"
23 fi 28 ALSA="no"
24 29 X11="no"
25 if [ "${x}" = "nodhcp" ]; then 30 ;;
31 nodhcp)
26 DHCP="no" 32 DHCP="no"
27 fi 33 ;;
28 34 nogpm)
29 if [ "${x}" = "nogpm" ]; then
30 GPM="no" 35 GPM="no"
31 fi 36 ;;
32 37 dopcmcia)
33 if [ "${x}" = "dopcmcia" ]; then
34 PCMCIA="yes" 38 PCMCIA="yes"
35 fi 39 ;;
36 40 doapm)
37 if [ "${x}" = "doapm" ]; then
38 APM="yes" 41 APM="yes"
39 ACPI="no" 42 ACPI="no"
40 fi 43 ;;
41 44 acpi=on|acpi=force)
42 if [ "${x}" = "acpi=on" -o "${x}" = "acpi=force" ]; then
43 APM="no" 45 APM="no"
44 ACPI="yes" 46 ACPI="yes"
45 fi 47 ;;
46 48 ide=nodma)
47 if [ "${x}" = "ide=nodma" ]; then
48 IDEDMA="no" 49 IDEDMA="no"
49 fi 50 ;;
50 51 nohotplug)
51 if [ "${x}" = "nohotplug" ]; then
52 HOTPLUG="no" 52 HOTPLUG="no"
53 fi 53 ;;
54 nosound)
55 ALSA="no"
56 ;;
57 nox)
58 X11="no"
59 ;;
60 esac
54done 61 done
62}
55 63
56depend() { 64depend() {
57 need modules 65 need modules
58 use alsasound 66 before net
59# provide gpm pcmcia apmd acpid coldplug 67# provide gpm pcmcia apmd acpid coldplug hdparm alsasound x-setup
68}
69
70# Checks whether a service will be started by autoconfig.
71# Usage: check_svc var service [service_alternative]
72check_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.
86list_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} x-setup)"
97
98 echo ${svcs}
99}
100
101unpack_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
113get_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
124detect_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
148detect_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} each"
159}
160
161detect_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
170detect_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 "PowerMac G4 AGP Graphics")
181 machtype="Apple PowerMac G4"
182 ;;
183 "PowerBook Titanium"|'PowerBook G4 15"')
184 machtype="Apple Powerbook G4"
185 ;;
186 "iBook 2 rev. 2")
187 machtype="Apple iBook G3"
188 ;;
189 "PowerMac G5")
190 machtype="Apple PowerMac G5"
191 ;;
192 "PowerMac G5 Dual Core")
193 machtype="Apple PowerMac G5 Dual Core"
194 ;;
195 "Unknown Intrepid-based")
196 machtype="Apple Mac-Mini"
197 ;;
198 "MPC8241")
199 machtype="Kurobox"
200 ;;
201 "CHRP Pegasos2")
202 machtype="Pegasos 2"
203 ;;
204 "CHRP IBM,9124-720")
205 machtype="IBM OP720"
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
105 ebegin ${BAD}"Skipping DHCP broadcast detection as requested on boot commandline." 314 ewarn "Skipping DHCP broadcast detection as requested on boot commandline ..."
106 fi 315 fi
107 316
108 #Read in what hwsetup has found 317 # Read in what hwsetup has found
109 [ -f /etc/sysconfig/knoppix ] && . /etc/sysconfig/knoppix 318 [ -f /etc/sysconfig/gentoo ] && . /etc/sysconfig/gentoo
110 319
111 # Mouse 320 # Mouse
112 if [ -n "${MOUSE_DEVICE}" ]; then 321 if [ -n "${MOUSE_DEVICE}" ]
322 then
113 ebegin ${GOOD}"Mouse is ${HILITE}${MOUSE_FULLNAME}${GOOD} at ${HILITE}${MOUSE_DEVICE}${NORMAL}" 323 einfo "Mouse is ${HILITE}${MOUSE_FULLNAME}${NORMAL} at ${HILITE}${MOUSE_DEVICE}${NORMAL} ..."
114 source /etc/sysconfig/mouse 324 source /etc/sysconfig/mouse
115 if [ -x /usr/sbin/gpm ]; then 325 if [ -x /usr/sbin/gpm ]
326 then
116 if [ `grep "#MOUSE=${MOUSETYPE}" /etc/conf.d/gpm` ]; then 327# if [ $(grep "#MOUSE=${MOUSETYPE}" /etc/conf.d/gpm) ]
328 if [ $([[ $'\n'$(</etc/conf.d/gpm) =~ $'\n''#MOUSE=${MOUSETYPE}' ]]) ]
329 then
117 sed -i "\@MOUSE=${MOUSETYPE}@s@^#@@" /etc/conf.d/gpm 330 sed -i "\@MOUSE=${MOUSETYPE}@s@^#@@" /etc/conf.d/gpm
118 else 331 else
119 echo "MOUSE=${MOUSETYPE}" >>/etc/conf.d/gpm 332 echo "MOUSE=${MOUSETYPE}" >>/etc/conf.d/gpm
120 fi 333 fi
334
121 if [ `grep "#MOUSEDEV=${DEVICE}" /etc/conf.d/gpm` ]; then 335# if [ $(grep "#MOUSEDEV=${DEVICE}" /etc/conf.d/gpm) ]
336 if [ $([[ $'\n'$(</etc/conf.d/gpm) =~ $'\n''#MOUSEDEV=${DEVICE}' ]]) ]
337 then
122 sed -i "\@MOUSEDEV=${DEVICE}@s@^#@@" /etc/conf.d/gpm 338 sed -i "\@MOUSEDEV=${DEVICE}@s@^#@@" /etc/conf.d/gpm
123 else 339 else
124 echo "MOUSEDEV=${DEVICE}" >>/etc/conf.d/gpm 340 echo "MOUSEDEV=${DEVICE}" >>/etc/conf.d/gpm
125 fi 341 fi
342
343 [ "${GPM}" = "yes" ] \
344 && [ -x /etc/init.d/gpm ] && start_service gpm
345 fi
346 fi
347
348 if [ "${HOTPLUG}" = "yes" ]
349 then
350 # Check whether we should be using hotplug or coldplug
351 if [ -x /etc/init.d/coldplug ]
352 then
353 start_service coldplug
354 elif [ -x /etc/init.d/hotplug ]
355 then
356 start_service hotplug
357 else
358 unpack_firmware
359 fi
360 else
361 ewarn "Hotplug disabled via cmdline ..."
362 fi
363
364 [ "${DETECT}" = "no" ] && DHCP="no"
365 [ "${DETECT}" = "yes" ] \
366 && NETDEVICES="$(awk -F: '/eth.:|tr.:|ath.:|wlan.:/{print $1}' /proc/net/dev 2>/dev/null)"
367
368 if [ -n "${NETDEVICES}" ]
369 then
370 for nics in ${NETDEVICES}
371 do
126 if [ "$GPM" = "yes" ]; then 372 if [ "${DHCP}" = "yes" ]
127 [ -x /etc/init.d/gpm ] && /etc/init.d/gpm start 373 then
374 einfo "Network device ${HILITE}${nics}${NORMAL} detected, DHCP broadcasting for IP ..."
375 dhcpcd -n -h $(hostname) &
376 fi
377 done
378 else
379 ewarn "No Network device auto detected ..."
380 fi
381
382 if [ "${ALSA}" = "yes" ]
383 then
384 if [ -n "${SOUND_FULLNAME}" -o -n "${SOUND_DRIVER}" ]
385 then
386 local sndmsg="Soundcard:\n"
387
388 [ -n "${SOUND_FULLNAME}" ] \
389 && sndmsg="${sndmsg} ${WARN}${SOUND_FULLNAME}\n"
390 [ -n "${SOUND_DRIVER}" ] \
391 && sndmsg="${sndmsg} driver = ${SOUND_DRIVER}\n"
392
393 einfo "${sndmsg}"
394
395
396 if [ -x /etc/init.d/alsasound ]
397 then
398 start_service alsasound
399 fi
400
401 if [ -e /proc/asound/cards ]
402 then
403 for i in $(cat /proc/asound/cards | awk '{print $1}' | grep ^[[:digit:]])
404 do
405 if [ -d /proc/asound/card$i ] && [ -x /usr/bin/amixer ]
406 then
407 amixer -c $i scontrols > /etc/amixer
408 [ -n "$(grep Master /etc/amixer)" ] \
409 && amixer -c $i -q set Master 95% unmute \
410 >/dev/null 2>&1
411 [ -n "$(grep PCM /etc/amixer)" ] \
412 && amixer -c $i -q set PCM 95% unmute \
413 >/dev/null 2>&1
414 [ -n "$(grep Mic /etc/amixer)" ] \
415 && amixer -c $i -q set Mic 95% mute cap \
416 >/dev/null 2>&1
417 [ -n "$(grep Wave /etc/amixer)" ] \
418 && amixer -c $i -q set Wave 95% unmute \
419 >/dev/null 2>&1
420 [ -n "$(grep Capture /etc/amixer)" ] \
421 && amixer -c $i -q set Capture 95% unmute cap \
422 >/dev/null 2>&1
423 fi
424 done
128 fi 425 fi
129 fi 426 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 427 else
138 [ -x /etc/init.d/hotplug ] && /etc/init.d/hotplug start 428 ewarn "Skipping ALSA detection as requested on command line ..."
429 fi
430
431 if [ "${X11}" = "yes" ]
432 then
433 if [ -x /etc/init.d/x-setup ]
434 then
435 start_service x-setup
436 elif [ -x /etc/init.d/mkxf86config ]
437 then
438 start_service mkxf86config
139 fi 439 fi
140 else 440 else
141 ebegin ${BAD}"Hotplug disabled via cmdline${NORMAL}" 441 touch /etc/init.d/.noxdm
142 fi
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 442 fi
157 eend
158 443
159 else 444# [ -n "${XDESC}" ] && einfo "VideoCard: ${HILITE}${XDESC}${NORMAL}"
160 ebegin ${BAD}"No Network device auto detected.${NORMAL}"
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
201 445
202 killall hwsetup 2>/dev/null 446 killall hwsetup 2>/dev/null
203 echo "6" > /proc/sys/kernel/printk 447 echo "6" > /proc/sys/kernel/printk
204
205} 448}
206 449
207# vim: ts=4 450# vim: ts=4

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

  ViewVC Help
Powered by ViewVC 1.1.20