/[livecd-tools]/trunk/autoconfig
Gentoo

Contents of /trunk/autoconfig

Parent Directory Parent Directory | Revision Log Revision Log


Revision 91 - (show annotations) (download)
Sat Jan 21 22:44:13 2006 UTC (11 years, 9 months ago) by wolf31o2
File size: 9244 byte(s)
Added Kurobox and Pegasos 2 thanks to #gentoo-ppc.

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.53 2006/01/21 22:44:13 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 # Only used on SGI CDs, this determines:
101 # A) CPU Type
102 # B) System
103 detect_mips() {
104 local cpuinfo="$(awk -F: '/^cpu model/{printf $2};/^$/{print ""}' /proc/cpuinfo 2>/dev/null | head -n 1 | cut -d" " -f2,3)"
105 local machinfo="$(awk -F: '/^system type/{printf $2};/^$/{print ""}' /proc/cpuinfo 2>/dev/null | cut -d" " -f2-)"
106 local machtype=""
107
108 case "${machinfo}" in
109 "SGI Indy")
110 machtype="SGI Indy" # Indy R4x00/R5000
111 ;;
112 "SGI Indigo2")
113 case "${cpuinfo}" in
114 R4*)
115 machtype="SGI Indigo2" # I2 R4x00
116 ;;
117 R8*)
118 machtype="SGI Indigo2 Power" # I2 R8000
119 ;;
120 R10*)
121 machtype="SGI Indigo2 Impact" # I2 R10000
122 ;;
123 esac
124 ;;
125 "SGI O2"|"SGI IP32")
126 machtype="SGI O2" # O2 R5K/RM5K2/RM7K/R10K/R12K
127 ;;
128 "SGI Octane"|"SGI IP30")
129 machtype="SGI Octane" # Octane R10K/R12K/R14K
130 ;;
131 "SGI Origin"|"SGI IP27")
132 machtype="SGI Origin" # Origin R10K/R12K
133 ;;
134 *)
135 machtype="Unknown SGI MIPS" # ???
136 ;;
137 esac
138
139 PC="Detected an ${machtype} w/ ${numcpu} ${cpuinfo} ${bit}"
140 }
141
142 detect_x86_amd64() {
143 local cpuinfo="$(awk -F: '/^model name/{printf $2};/^$/{print ""}' /proc/cpuinfo 2>/dev/null | head -n 1)"
144 local mhz="$(awk -F: '/^cpu MHz/{printf " %dMHz",int($2)};/^$/{print ""}' /proc/cpuinfo 2>/dev/null | head -n 1)"
145
146 PC="Detected ${numcpu} ${cpuinfo} ${mhz} ${bit}"
147 }
148
149 detect_ppc() {
150 local cpuinfo="$(awk -F: '/^cpu/{printf $2};/^$/{print ""}' /proc/cpuinfo 2>/dev/null | head -n 1)"
151 local mhz="$(awk -F: '/^clock/{printf " %dMHz",int($2)};/^$/{print ""}' /proc/cpuinfo 2>/dev/null | head -n 1)"
152 local machinfo="$(awk -F: '/^detected as/{printf $2}' /proc/cpuinfo | cut -d'(' -f2 | cut -d')' -f1)"
153 local machtype=""
154 # if [ -z "machinfo" ]
155 # then
156 # machinfo=$(awk -F: '/^machine/{printf $2}' /proc/cpuinfo)"
157 # fi
158
159 case "${machinfo}" in
160 "PowerMac G4 AGP Graphics")
161 machtype="Apple PowerMac G4"
162 ;;
163 "PowerBook Titanium")
164 machtype="Apple Powerbook G4"
165 ;;
166 "iBook 2 rev. 2")
167 machtype="Apple iBook G3"
168 ;;
169 "PowerMac G5 Dual Core")
170 machtype="Apple PowerMac G5 Dual Core"
171 ;;
172 "Unknown Intrepid-based")
173 machtype="Apple Mac-Mini"
174 ;;
175 "MPC8241")
176 machtype="Kurobox"
177 ;;
178 "CHRP Pegasos2")
179 machtype="Pegasos 2"
180 ;;
181 *)
182 machtype="Unknown PPC System"
183 ;;
184 esac
185
186 PC="Detected an ${machtype} w/ ${numcpu} ${cpuinfo} ${bit}"
187 }
188
189 start() {
190 echo "0" > /proc/sys/kernel/printk
191 get_config
192 if [ "${DETECT}" = "yes" ]
193 then
194 ebegin "Hardware detection started"
195 local numcpu="$(awk -F: '/^processor/{printf $2};/^$/{print ""}' /proc/cpuinfo 2>/dev/null | wc -l)"
196 local arch="$(uname -m)"
197 local ismips="no"
198 [ "${numcpu}" -gt '1' ] && bit="CPUs" || bit="CPU"
199 case ${arch} in
200 mips|mips64)
201 detect_mips
202 ismips="yes"
203 ;;
204 i?86|x86_64)
205 detect_x86_amd64
206 ;;
207 *)
208 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)"
209 ;;
210 esac
211 einfo "${PC}"
212 [ -x /usr/sbin/hwsetup ] && hwsetup -p >/dev/null
213 eend
214 else
215 ewarn "Hardware detection disabled via cmdline ..."
216 fi
217
218 if [ "${APM}" = "yes" ]
219 then
220 modprobe apm power_off=1 >/dev/null 2>&1 && \
221 einfo "APM BIOS found, power management functions enabled ..."
222 [ -x /etc/init.d/apmd ] && start_service apmd
223 else
224 [ "${ismips}" = "no" ] && ewarn "Not Loading APM Bios support ..."
225 fi
226
227 if [ "${ACPI}" = "yes" ]
228 then
229 modprobe processor >/dev/null 2>&1 && \
230 ebegin "ACPI power management functions enabled" && \
231 modprobe thermal >/dev/null
232 modprobe fan >/dev/null 2>&1
233 modprobe button >/dev/null 2>&1
234 modprobe battery >/dev/null 2>&1
235 modprobe ac >/dev/null 2>&1
236 [ -x /etc/init.d/acpid ] && start_service acpid
237 eend
238 else
239 [ "${ismips}" = "no" ] && ewarn "Not Loading ACPI support ..."
240 fi
241
242 if [ "${IDEDMA}" = "yes" ]
243 then
244 if [ "${ismips}" = "no" ]; then
245 [ -x /etc/init.d/hdparm ] && start_service hdparm
246 fi
247 fi
248
249 if [ "${PCMCIA}" = "yes" ]
250 then
251 einfo "PCMCIA enabled via cmdline ..."
252 [ -x /etc/init.d/pcmcia ] && start_service pcmcia
253 fi
254
255 if [ "${DHCP}" = "no" ]
256 then
257 sed -i -e '/^ifconfig_eth.*dhcp.*/ s/^/#/' \
258 -e '/^iface_eth.*dhcp.*/ s/^/#/' \
259 -e '/^config_eth.*dhcp.*/ s/^/#/' \
260 /etc/conf.d/net
261 ewarn "Skipping DHCP broadcast detection as requested on boot commandline ..."
262 fi
263
264 # Read in what hwsetup has found
265 [ -f /etc/sysconfig/knoppix ] && . /etc/sysconfig/knoppix
266 [ -f /etc/sysconfig/gentoo ] && . /etc/sysconfig/gentoo
267
268 # Mouse
269 if [ -n "${MOUSE_DEVICE}" ]
270 then
271 einfo "Mouse is ${HILITE}${MOUSE_FULLNAME}${NORMAL} at ${HILITE}${MOUSE_DEVICE}${NORMAL} ..."
272 source /etc/sysconfig/mouse
273 if [ -x /usr/sbin/gpm ]
274 then
275 [ $(grep "#MOUSE=${MOUSETYPE}" /etc/conf.d/gpm) ] \
276 && sed -i "\@MOUSE=${MOUSETYPE}@s@^#@@" /etc/conf.d/gpm \
277 || echo "MOUSE=${MOUSETYPE}" >>/etc/conf.d/gpm
278
279 [ $(grep "#MOUSEDEV=${DEVICE}" /etc/conf.d/gpm) ] \
280 && sed -i "\@MOUSEDEV=${DEVICE}@s@^#@@" /etc/conf.d/gpm \
281 || echo "MOUSEDEV=${DEVICE}" >>/etc/conf.d/gpm
282
283 [ "${GPM}" = "yes" ] \
284 && [ -x /etc/init.d/gpm ] && start_service gpm
285 fi
286 fi
287
288 if [ "${HOTPLUG}" = "yes" ]
289 then
290 # Check whether we should be using hotplug or coldplug
291 if [ -x /etc/init.d/coldplug ]
292 then
293 start_service coldplug
294 elif [ -x /etc/init.d/hotplug ]
295 then
296 start_service hotplug
297 fi
298 else
299 ewarn "Hotplug disabled via cmdline ..."
300 fi
301
302 [ "${DETECT}" = "no" ] && DHCP="no"
303 [ "${DETECT}" = "yes" ] \
304 && NETDEVICES="$(awk -F: '/eth.:|tr.:|ath.:|wlan.:/{print $1}' /proc/net/dev 2>/dev/null)"
305
306 if [ -n "${NETDEVICES}" ]
307 then
308 for nics in ${NETDEVICES}
309 do
310 if [ "${DHCP}" = "yes" ]
311 then
312 einfo "Network device ${HILITE}${nics}${NORMAL} detected, DHCP broadcasting for IP ..."
313 dhcpcd -n -h $(hostname) &
314 fi
315 done
316 else
317 ewarn "No Network device auto detected ..."
318 fi
319
320 if [ "${ALSA}" = "yes" ]
321 then
322 if [ -n "${SOUND_FULLNAME}" -o -n "${SOUND_DRIVER}" ]
323 then
324 local sndmsg="Soundcard:\n"
325
326 [ -n "${SOUND_FULLNAME}" ] \
327 && sndmsg="${sndmsg} ${WARN}${SOUND_FULLNAME}\n"
328 [ -n "${SOUND_DRIVER}" ] \
329 && sndmsg="${sndmsg} driver = ${SOUND_DRIVER}\n"
330
331 einfo "${sndmsg}"
332
333
334 if [ -x /etc/init.d/alsasound ]
335 then
336 start_service alsasound
337 fi
338
339 if [ -e /proc/asound/cards ]
340 then
341 for i in $(cat /proc/asound/cards | cut -d" " -f1)
342 do
343 if [ -d /proc/asound/card$i ] && [ -x /usr/bin/amixer ]
344 then
345 amixer -c $i scontrols > /etc/amixer
346 [ -n "$(grep Master /etc/amixer)" ] \
347 && amixer -c $i -q set Master 95% unmute \
348 >/dev/null 2>&1
349 [ -n "$(grep PCM /etc/amixer)" ] \
350 && amixer -c $i -q set PCM 95% unmute \
351 >/dev/null 2>&1
352 [ -n "$(grep Mic /etc/amixer)" ] \
353 && amixer -c $i -q set Mic 95% mute cap \
354 >/dev/null 2>&1
355 [ -n "$(grep Wave /etc/amixer)" ] \
356 && amixer -c $i -q set Wave 95% unmute \
357 >/dev/null 2>&1
358 [ -n "$(grep Capture /etc/amixer)" ] \
359 && amixer -c $i -q set Capture 95% unmute cap \
360 >/dev/null 2>&1
361 fi
362 done
363 fi
364 fi
365 else
366 ewarn "Skipping ALSA detection as requested on command line ..."
367 fi
368
369 if [ "${DETECT}" = "yes" ]
370 then
371 [ -x /etc/init.d/x-setup ] && start_service x-setup
372 fi
373
374 [ "${X11}" = "no" ] && touch /etc/init.d/.noxdm
375 [ -n "${XDESC}" ] && einfo "VideoCard: ${HILITE}${XDESC}${NORMAL}"
376
377 killall hwsetup 2>/dev/null
378 echo "6" > /proc/sys/kernel/printk
379 }
380
381 # vim: ts=4

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20