/[livecd-tools]/trunk/autoconfig
Gentoo

Contents of /trunk/autoconfig

Parent Directory Parent Directory | Revision Log Revision Log


Revision 101 - (show annotations) (download)
Fri May 19 23:52:00 2006 UTC (11 years, 9 months ago) by wolf31o2
File size: 10177 byte(s)
Add an unpack_firmware function in case we don't have either the hotplug or coldplug init scripts for udev >=089 compatibility.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20