/[livecd-tools]/trunk/autoconfig
Gentoo

Contents of /trunk/autoconfig

Parent Directory Parent Directory | Revision Log Revision Log


Revision 79 - (show annotations) (download)
Wed Oct 12 17:42:25 2005 UTC (8 years, 11 months ago) by wolf31o2
File size: 8020 byte(s)
Added patch from Joshua Kinard <kumba@gentoo.org> for bug #106990.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20