/[livecd-tools]/trunk/autoconfig
Gentoo

Diff of /trunk/autoconfig

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

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

Legend:
Removed from v.29  
changed lines
  Added in v.131

  ViewVC Help
Powered by ViewVC 1.1.20