/[livecd-tools]/trunk/autoconfig
Gentoo

Contents of /trunk/autoconfig

Parent Directory Parent Directory | Revision Log Revision Log


Revision 81 - (show annotations) (download)
Mon Oct 17 15:08:59 2005 UTC (9 years, 2 months ago) by wolf31o2
File size: 8330 byte(s)
Updated to use new x86/amd64 machine information and changed if to case.

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.46 2005/10/17 15:08:59 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 start() {
150 echo "0" > /proc/sys/kernel/printk
151 get_config
152 if [ "${DETECT}" = "yes" ]
153 then
154 ebegin "Hardware detection started"
155 local numcpu="$(awk -F: '/^processor/{printf $2};/^$/{print ""}' /proc/cpuinfo 2>/dev/null | wc -l)"
156 local arch="$(uname -m)"
157 local ismips="no"
158 [ "${numcpu}" -gt '1' ] && bit="CPUs" || bit="CPU"
159 case ${arch} in
160 mips|mips64)
161 detect_mips
162 ismips="yes"
163 ;;
164 i386|i486|i586|i686|x86_64)
165 detect_x86_amd64
166 ;;
167 *)
168 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)"
169 ;;
170 esac
171 einfo "${PC}"
172 [ -x /usr/sbin/hwsetup ] && hwsetup -p >/dev/null
173 eend
174 else
175 ewarn "Hardware detection disabled via cmdline ..."
176 fi
177
178 if [ "${APM}" = "yes" ]
179 then
180 modprobe apm power_off=1 >/dev/null 2>&1 && \
181 einfo "APM BIOS found, power management functions enabled ..."
182 [ -x /etc/init.d/apmd ] && start_service apmd
183 else
184 [ "${ismips}" = "no" ] && ewarn "Not Loading APM Bios support ..."
185 fi
186
187 if [ "${ACPI}" = "yes" ]
188 then
189 modprobe processor >/dev/null 2>&1 && \
190 ebegin "ACPI power management functions enabled" && \
191 modprobe thermal >/dev/null
192 modprobe fan >/dev/null 2>&1
193 modprobe button >/dev/null 2>&1
194 modprobe battery >/dev/null 2>&1
195 modprobe ac >/dev/null 2>&1
196 [ -x /etc/init.d/acpid ] && start_service acpid
197 eend
198 else
199 [ "${ismips}" = "no" ] && ewarn "Not Loading ACPI support ..."
200 fi
201
202 if [ "${IDEDMA}" = "yes" ]
203 then
204 if [ "${ismips}" = "no" ]; then
205 [ -x /etc/init.d/hdparm ] && start_service hdparm
206 fi
207 fi
208
209 if [ "${PCMCIA}" = "yes" ]
210 then
211 einfo "PCMCIA enabled via cmdline ..."
212 [ -x /etc/init.d/pcmcia ] && start_service pcmcia
213 fi
214
215 if [ "${DHCP}" = "no" ]
216 then
217 sed -i -e '/^ifconfig_eth.*dhcp.*/ s/^/#/' \
218 -e '/^iface_eth.*dhcp.*/ s/^/#/' \
219 -e '/^config_eth.*dhcp.*/ s/^/#/' \
220 /etc/conf.d/net
221 ewarn "Skipping DHCP broadcast detection as requested on boot commandline ..."
222 fi
223
224 # Read in what hwsetup has found
225 [ -f /etc/sysconfig/knoppix ] && . /etc/sysconfig/knoppix
226 [ -f /etc/sysconfig/gentoo ] && . /etc/sysconfig/gentoo
227
228 # Mouse
229 if [ -n "${MOUSE_DEVICE}" ]
230 then
231 einfo "Mouse is ${HILITE}${MOUSE_FULLNAME}${NORMAL} at ${HILITE}${MOUSE_DEVICE}${NORMAL} ..."
232 source /etc/sysconfig/mouse
233 if [ -x /usr/sbin/gpm ]
234 then
235 [ $(grep "#MOUSE=${MOUSETYPE}" /etc/conf.d/gpm) ] \
236 && sed -i "\@MOUSE=${MOUSETYPE}@s@^#@@" /etc/conf.d/gpm \
237 || echo "MOUSE=${MOUSETYPE}" >>/etc/conf.d/gpm
238
239 [ $(grep "#MOUSEDEV=${DEVICE}" /etc/conf.d/gpm) ] \
240 && sed -i "\@MOUSEDEV=${DEVICE}@s@^#@@" /etc/conf.d/gpm \
241 || echo "MOUSEDEV=${DEVICE}" >>/etc/conf.d/gpm
242
243 [ "${GPM}" = "yes" ] \
244 && [ -x /etc/init.d/gpm ] && start_service gpm
245 fi
246 fi
247
248 if [ "${HOTPLUG}" = "yes" ]
249 then
250 # Check whether we should be using hotplug or coldplug
251 if [ -x /etc/init.d/coldplug ]
252 then
253 start_service coldplug
254 elif [ -x /etc/init.d/hotplug ]
255 then
256 start_service hotplug
257 fi
258 else
259 ewarn "Hotplug disabled via cmdline ..."
260 fi
261
262 [ "${DETECT}" = "no" ] && DHCP="no"
263 [ "${DETECT}" = "yes" ] \
264 && NETDEVICES="$(awk -F: '/eth.:|tr.:|ath.:|wlan.:/{print $1}' /proc/net/dev 2>/dev/null)"
265
266 if [ -n "${NETDEVICES}" ]
267 then
268 for nics in ${NETDEVICES}
269 do
270 if [ "${DHCP}" = "yes" ]
271 then
272 einfo "Network device ${HILITE}${nics}${NORMAL} detected, DHCP broadcasting for IP ..."
273 dhcpcd -n -h $(hostname) &
274 fi
275 done
276 else
277 ewarn "No Network device auto detected ..."
278 fi
279
280 if [ "${ALSA}" = "yes" ]
281 then
282 if [ -n "${SOUND_FULLNAME}" -o -n "${SOUND_DRIVER}" ]
283 then
284 local sndmsg="Soundcard:\n"
285
286 [ -n "${SOUND_FULLNAME}" ] \
287 && sndmsg="${sndmsg} ${WARN}${SOUND_FULLNAME}\n"
288 [ -n "${SOUND_DRIVER}" ] \
289 && sndmsg="${sndmsg} driver = ${SOUND_DRIVER}\n"
290
291 einfo "${sndmsg}"
292
293
294 if [ -x /etc/init.d/alsasound ]
295 then
296 start_service alsasound
297 else
298 ewarn "/etc/init.d/alsasound not found, skipping ..."
299 ewarn "You will need to set volume controls manually ..."
300 fi
301
302 for i in $(cat /proc/asound/cards | cut -d" " -f1)
303 do
304 if [ -d /proc/asound/card$i ] && [ -x /usr/bin/amixer ]
305 then
306 amixer -c $i scontrols > /etc/amixer
307 [ -n "$(grep Master /etc/amixer)" ] \
308 && amixer -c $i -q set Master 95% unmute \
309 >/dev/null 2>&1
310 [ -n "$(grep PCM /etc/amixer)" ] \
311 && amixer -c $i -q set PCM 95% unmute \
312 >/dev/null 2>&1
313 [ -n "$(grep Mic /etc/amixer)" ] \
314 && amixer -c $i -q set Mic 95% mute cap \
315 >/dev/null 2>&1
316 [ -n "$(grep Wave /etc/amixer)" ] \
317 && amixer -c $i -q set Wave 95% unmute \
318 >/dev/null 2>&1
319 [ -n "$(grep Capture /etc/amixer)" ] \
320 && amixer -c $i -q set Capture 95% unmute cap \
321 >/dev/null 2>&1
322 fi
323 done
324 fi
325 else
326 ewarn "Skipping ALSA detection as requested on boot commandline ..."
327 fi
328
329 if [ "${DETECT}" = "yes" ]
330 then
331 [ -x /etc/init.d/x-setup ] && schedule_service_startup x-setup
332 fi
333
334 [ "${X11}" = "no" ] && touch /etc/init.d/.noxdm
335 [ -n "${XDESC}" ] && einfo "VideoCard: ${HILITE}${XDESC}${NORMAL}"
336
337 killall hwsetup 2>/dev/null
338 echo "6" > /proc/sys/kernel/printk
339 }
340
341 # vim: ts=4

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20