/[livecd-tools]/trunk/autoconfig
Gentoo

Diff of /trunk/autoconfig

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

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

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

  ViewVC Help
Powered by ViewVC 1.1.20