/[livecd-tools]/trunk/autoconfig
Gentoo

Contents of /trunk/autoconfig

Parent Directory Parent Directory | Revision Log Revision Log


Revision 125 - (show annotations) (download)
Wed Dec 20 15:13:35 2006 UTC (7 years, 8 months ago) by wolf31o2
File size: 9878 byte(s)
We need to turn on the RC_COLDPLUG in /etc/conf.d/rc since we're now disabling it in catalyst.
1 #!/sbin/runscript
2
3 DHCP="yes"
4 DETECT="yes"
5 GPM="yes"
6 PCMCIA="no"
7 HOTPLUG="yes"
8 APM="no"
9 ACPI="no"
10 IDEDMA="yes"
11 ALSA="yes"
12 X11="yes"
13
14 get_config() {
15 CMDLINE="$(cat /proc/cmdline)"
16
17 for x in ${CMDLINE} ; do
18 case "${x}" in
19 nodetect)
20 DETECT="no"
21 GPM="no"
22 HOTPLUG="no"
23 APM="no"
24 ACPI="no"
25 ALSA="no"
26 X11="no"
27 ;;
28 nodhcp)
29 DHCP="no"
30 ;;
31 nogpm)
32 GPM="no"
33 ;;
34 dopcmcia)
35 PCMCIA="yes"
36 ;;
37 doapm)
38 APM="yes"
39 ACPI="no"
40 ;;
41 acpi\=on|acpi\=force)
42 APM="no"
43 ACPI="yes"
44 ;;
45 ide\=nodma)
46 IDEDMA="no"
47 ;;
48 nohotplug)
49 HOTPLUG="no"
50 ;;
51 nosound)
52 ALSA="no"
53 ;;
54 nox)
55 X11="no"
56 ;;
57 esac
58 done
59 }
60
61 depend() {
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]
69 check_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.
83 list_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
98 unpack_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
110 get_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
121 detect_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
145 detect_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
158 detect_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
167 detect_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
215 detect_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"
221 }
222
223 start() {
224 echo "0" > /proc/sys/kernel/printk
225 get_config
226 if [ "${DETECT}" = "yes" ]
227 then
228 ebegin "Hardware detection started"
229 local numcpu="$(grep -c '^processor[[:space:]]\+:' /proc/cpuinfo)"
230 # local numcpu=$([[ $'\n'$(</proc/cpuinfo) =~ $'\n''processor[[:space:]]\+:' ]] | wc -l)
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}"
267 [ -x /usr/sbin/hwsetup ] && hwsetup -p >/dev/null
268 eend
269 else
270 ewarn "Hardware detection disabled via cmdline ..."
271 fi
272
273 if [ "${APM}" = "yes" ]
274 then
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
278 else
279 einfo "Not Loading APM Bios support ..."
280 fi
281
282 if [ "${ACPI}" = "yes" ]
283 then
284 modprobe processor >/dev/null 2>&1 && \
285 ebegin "ACPI power management functions enabled" && \
286 modprobe thermal >/dev/null
287 modprobe fan >/dev/null 2>&1
288 modprobe button >/dev/null 2>&1
289 modprobe battery >/dev/null 2>&1
290 modprobe ac >/dev/null 2>&1
291 [ -x /etc/init.d/acpid ] && start_service acpid
292 eend
293 else
294 einfo "Not Loading ACPI support ..."
295 fi
296
297 if [ "${IDEDMA}" = "yes" ]
298 then
299 [ -x /etc/init.d/hdparm ] && start_service hdparm
300 fi
301
302 if [ "${PCMCIA}" = "yes" ]
303 then
304 einfo "PCMCIA enabled via cmdline ..."
305 [ -x /etc/init.d/pcmcia ] && start_service pcmcia
306 fi
307
308 if [ "${DHCP}" = "no" ]
309 then
310 sed -i -e '/^ifconfig_eth.*dhcp.*/ s/^/#/' \
311 -e '/^iface_eth.*dhcp.*/ s/^/#/' \
312 -e '/^config_eth.*dhcp.*/ s/^/#/' \
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
318 ewarn "Skipping DHCP broadcast detection as requested on boot commandline ..."
319 fi
320
321 # Read in what hwsetup has found
322 [ -f /etc/sysconfig/gentoo ] && . /etc/sysconfig/gentoo
323
324 # Mouse
325 if [ -n "${MOUSE_DEVICE}" ]
326 then
327 einfo "Mouse is ${HILITE}${MOUSE_FULLNAME}${NORMAL} at ${HILITE}${MOUSE_DEVICE}${NORMAL} ..."
328 source /etc/sysconfig/mouse
329 if [ -x /usr/sbin/gpm ]
330 then
331 if [ $(grep "#MOUSE=${MOUSETYPE}" /etc/conf.d/gpm) ]
332 # if [ $([[ $'\n'$(</etc/conf.d/gpm) =~ $'\n''#MOUSE=${MOUSETYPE}' ]]) ]
333 then
334 sed -i "\@MOUSE=${MOUSETYPE}@s@^#@@" /etc/conf.d/gpm
335 else
336 echo "MOUSE=${MOUSETYPE}" >>/etc/conf.d/gpm
337 fi
338
339 if [ $(grep "#MOUSEDEV=${DEVICE}" /etc/conf.d/gpm) ]
340 # if [ $([[ $'\n'$(</etc/conf.d/gpm) =~ $'\n''#MOUSEDEV=${DEVICE}' ]]) ]
341 then
342 sed -i "\@MOUSEDEV=${DEVICE}@s@^#@@" /etc/conf.d/gpm
343 else
344 echo "MOUSEDEV=${DEVICE}" >>/etc/conf.d/gpm
345 fi
346
347 [ "${GPM}" = "yes" ] \
348 && [ -x /etc/init.d/gpm ] && start_service gpm
349 fi
350 fi
351
352 if [ "${HOTPLUG}" = "yes" ]
353 then
354 # First off, we want hotplug/coldplug enabled, so let's re-enable it
355 sed -i 's/RC_COLDPLUG="no"/RC_COLDPLUG="yes"/' /etc/conf.d/rc
356 # Check whether we should be using hotplug or coldplug
357 if [ -x /etc/init.d/coldplug ]
358 then
359 start_service coldplug
360 elif [ -x /etc/init.d/hotplug ]
361 then
362 start_service hotplug
363 else
364 unpack_firmware
365 [ -x /sbin/udevtrigger ] && /sbin/udevtrigger
366 fi
367 else
368 ewarn "Hotplug/Coldplug disabled via cmdline ..."
369 fi
370
371 [ "${DETECT}" = "no" ] && DHCP="no"
372 [ "${DETECT}" = "yes" ] \
373 && NETDEVICES="$(awk -F: '/eth.:|tr.:|ath.:|wlan.:/{print $1}' /proc/net/dev 2>/dev/null)"
374
375 if [ -n "${NETDEVICES}" ]
376 then
377 for nics in ${NETDEVICES}
378 do
379 if [ "${DHCP}" = "yes" ]
380 then
381 einfo "Network device ${HILITE}${nics}${NORMAL} detected, DHCP broadcasting for IP ..."
382 dhcpcd -n -h $(hostname) &
383 fi
384 done
385 else
386 ewarn "No Network device auto detected ..."
387 fi
388
389 if [ "${ALSA}" = "yes" ]
390 then
391 if [ -n "${SOUND_FULLNAME}" -o -n "${SOUND_DRIVER}" ]
392 then
393 local sndmsg="Soundcard:\n"
394
395 [ -n "${SOUND_FULLNAME}" ] \
396 && sndmsg="${sndmsg} ${WARN}${SOUND_FULLNAME}\n"
397 [ -n "${SOUND_DRIVER}" ] \
398 && sndmsg="${sndmsg} driver = ${SOUND_DRIVER}\n"
399
400 einfo "${sndmsg}"
401
402
403 if [ -x /etc/init.d/alsasound ]
404 then
405 start_service alsasound
406 fi
407
408 if [ -e /proc/asound/cards ]
409 then
410 for i in $(cat /proc/asound/cards | awk '{print $1}' | grep ^[[:digit:]])
411 do
412 if [ -d /proc/asound/card$i ] && [ -x /usr/bin/amixer ]
413 then
414 amixer -c $i scontrols > /etc/amixer
415 [ -n "$(grep Master /etc/amixer)" ] \
416 && amixer -c $i -q set Master 95% unmute \
417 >/dev/null 2>&1
418 [ -n "$(grep PCM /etc/amixer)" ] \
419 && amixer -c $i -q set PCM 95% unmute \
420 >/dev/null 2>&1
421 [ -n "$(grep Mic /etc/amixer)" ] \
422 && amixer -c $i -q set Mic 95% mute cap \
423 >/dev/null 2>&1
424 [ -n "$(grep Wave /etc/amixer)" ] \
425 && amixer -c $i -q set Wave 95% unmute \
426 >/dev/null 2>&1
427 [ -n "$(grep Capture /etc/amixer)" ] \
428 && amixer -c $i -q set Capture 95% unmute cap \
429 >/dev/null 2>&1
430 fi
431 done
432 fi
433 fi
434 else
435 ewarn "Skipping ALSA detection as requested on command line ..."
436 fi
437
438 [ -n "${XDESC}" ] && einfo "VideoCard: ${HILITE}${XDESC}${NORMAL}"
439
440 if [ "${X11}" = "yes" ]
441 then
442 if [ -x /etc/init.d/mkxf86config ]
443 then
444 start_service mkxf86config
445 fi
446 if [ -x /etc/init.d/x-setup ]
447 then
448 start_service x-setup
449 fi
450 else
451 touch /etc/init.d/.noxdm
452 fi
453
454 killall hwsetup 2>/dev/null
455 echo "6" > /proc/sys/kernel/printk
456 }
457
458 # vim: ts=4

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20