/[livecd-tools]/trunk/autoconfig
Gentoo

Contents of /trunk/autoconfig

Parent Directory Parent Directory | Revision Log Revision Log


Revision 77 - (hide annotations) (download)
Tue Aug 30 17:52:45 2005 UTC (12 years, 1 month ago) by wolf31o2
File size: 6961 byte(s)
Changing schedule_service_startup -> start_service for bug #104020, also removed extra XDESC for bug #103391.

1 zhen 2 #!/sbin/runscript
2 wolf31o2 44 # Copyright 1999-2005 Gentoo Foundation
3 zhen 2 # Distributed under the terms of the GNU General Public License v2
4 wolf31o2 77 # $Header: /var/cvsroot/gentoo/src/livecd-tools/autoconfig,v 1.42 2005/08/30 17:52:45 wolf31o2 Exp $
5 zhen 4
6 zhen 2 DHCP="yes"
7     DETECT="yes"
8 wolf31o2 24 GPM="yes"
9 zhen 2 PCMCIA="no"
10     HOTPLUG="yes"
11     APM="no"
12     ACPI="no"
13 wolf31o2 49 IDEDMA="yes"
14 wolf31o2 68 ALSA="yes"
15 wolf31o2 76 X11="yes"
16 wolf31o2 51
17 wolf31o2 68 get_config() {
18     CMDLINE="$(cat /proc/cmdline)"
19 wolf31o2 51
20 wolf31o2 68 for x in ${CMDLINE} ; do
21     if [ "${x}" = "nodetect" ]
22     then
23     DETECT="no"
24     GPM="no"
25     HOTPLUG="no"
26     APM="no"
27     ACPI="no"
28     ALSA="no"
29 wolf31o2 76 X11="no"
30 wolf31o2 68 fi
31 zhen 2
32 wolf31o2 68 if [ "${x}" = "nodhcp" ]
33     then
34     DHCP="no"
35     fi
36 zhen 4
37 wolf31o2 68 if [ "${x}" = "nogpm" ]
38     then
39     GPM="no"
40     fi
41 wolf31o2 31
42 wolf31o2 68 if [ "${x}" = "dopcmcia" ]
43     then
44     PCMCIA="yes"
45     fi
46 zhen 4
47 wolf31o2 68 if [ "${x}" = "doapm" ]
48     then
49     APM="yes"
50     ACPI="no"
51     fi
52 zhen 4
53 wolf31o2 68 if [ "${x}" = "acpi=on" -o "${x}" = "acpi=force" ]
54     then
55     APM="no"
56     ACPI="yes"
57     fi
58 wolf31o2 10
59 wolf31o2 68 if [ "${x}" = "ide=nodma" ]
60     then
61     IDEDMA="no"
62     fi
63 wolf31o2 49
64 wolf31o2 68 if [ "${x}" = "nohotplug" ]
65     then
66     HOTPLUG="no"
67     fi
68 zhen 2
69 wolf31o2 68 if [ "${x}" = "nosound" ]
70     then
71     ALSA="no"
72     fi
73 wolf31o2 76
74     if [ "${x}" = "nox" ]
75     then
76     X11="no"
77     fi
78 wolf31o2 68 done
79     }
80    
81 zhen 2 depend() {
82     need modules
83 wolf31o2 50 before net
84 wolf31o2 76 # provide gpm pcmcia apmd acpid coldplug hdparm alsasound x-setup
85 zhen 2 }
86    
87 wolf31o2 69 # Checks whether a service will be started by autoconfig.
88     # Usage: check_svc var service [service_alternative]
89     check_svc() {
90     if [ "$1" = "yes" ]; then
91     if [ -x "/etc/init.d/$2" ]; then
92     echo "$2"
93     elif [ -n "$3" -a -x "/etc/init.d/$3" ]; then
94     echo "$3"
95     fi
96     fi
97     }
98    
99     # Prints an ordered list of services that will be started by autoconfig.
100     list_services() {
101     get_config
102    
103     local svcs="$(check_svc ${APM} apmd)"
104     svcs="${svcs} $(check_svc ${ACPI} acpid)"
105     svcs="${svcs} $(check_svc ${IDEDMA} hdparm)"
106     svcs="${svcs} $(check_svc ${PCMCIA} pcmcia)"
107     svcs="${svcs} $(check_svc ${GPM} gpm)"
108     svcs="${svcs} $(check_svc ${HOTPLUG} coldplug hotplug)"
109     svcs="${svcs} $(check_svc ${ALSA} alsasound)"
110    
111     echo ${svcs}
112     }
113    
114 zhen 2 start() {
115 wolf31o2 69 echo "0" > /proc/sys/kernel/printk
116 wolf31o2 68 get_config
117 wolf31o2 51 if [ "${DETECT}" = "yes" ]
118     then
119 wolf31o2 18 ebegin ${WARN}"Hardware detection started"
120 wolf31o2 51 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)
121 wolf31o2 18 ebegin ${GOOD}"${PC}"
122 zhen 2 eend
123 wolf31o2 14 [ -x /usr/sbin/hwsetup ] && hwsetup -p >/dev/null
124 zhen 2 eend
125 wolf31o2 6 else
126 wolf31o2 18 ebegin ${WARN}"Hardware detection disabled via cmdline$NORMAL"
127 wolf31o2 6 fi
128 zhen 2
129 wolf31o2 51 if [ "${APM}" = "yes" ]
130     then
131 wolf31o2 29 modprobe apm power_off=1 >/dev/null 2>&1 && ebegin ${GOOD}"APM BIOS found, power management functions enabled.${NORMAL}"
132 wolf31o2 77 [ -x /etc/init.d/apmd ] && start_service apmd
133 zhen 2 else
134 wolf31o2 18 ebegin ${GOOD}"Not Loading APM Bios support.${NORMAL}"
135 wolf31o2 6 eend
136     fi
137 zhen 2
138 wolf31o2 51 if [ "${ACPI}" = "yes" ]
139     then
140 wolf31o2 29 modprobe processor >/dev/null 2>&1 && ebegin ${GOOD} ACPI power management functions enabled.${NORMAL} && modprobe thermal >/dev/null
141     modprobe fan >/dev/null 2>&1
142     modprobe button >/dev/null 2>&1
143     modprobe battery >/dev/null 2>&1
144     modprobe ac >/dev/null 2>&1
145 wolf31o2 77 [ -x /etc/init.d/acpid ] && start_service acpid
146 wolf31o2 6 eend
147     fi
148 zhen 2
149 wolf31o2 51 if [ "${IDEDMA}" = "yes" ]
150     then
151 wolf31o2 77 [ -x /etc/init.d/hdparm ] && start_service hdparm
152 wolf31o2 49 fi
153    
154 wolf31o2 51 if [ "${PCMCIA}" = "yes" ]
155     then
156 wolf31o2 18 ebegin ${HILITE} "PCMCIA enabled via cmdline"
157 wolf31o2 77 [ -x /etc/init.d/pcmcia ] && start_service pcmcia
158 wolf31o2 6 fi
159 zhen 2
160 wolf31o2 51 if [ "${DHCP}" = "no" ]
161     then
162 wolf31o2 48 sed -i -e '/^ifconfig_eth.*dhcp.*/ s/^/#/' \
163     -e '/^iface_eth.*dhcp.*/ s/^/#/' \
164 wolf31o2 55 -e '/^config_eth.*dhcp.*/ s/^/#/' \
165 wolf31o2 25 /etc/conf.d/net
166 wolf31o2 18 ebegin ${BAD}"Skipping DHCP broadcast detection as requested on boot commandline."
167 wolf31o2 6 fi
168 zhen 2
169 wolf31o2 6 #Read in what hwsetup has found
170     [ -f /etc/sysconfig/knoppix ] && . /etc/sysconfig/knoppix
171 wolf31o2 64 [ -f /etc/sysconfig/gentoo ] && . /etc/sysconfig/gentoo
172 zhen 2
173 wolf31o2 6 # Mouse
174 wolf31o2 51 if [ -n "${MOUSE_DEVICE}" ]
175     then
176 wolf31o2 18 ebegin ${GOOD}"Mouse is ${HILITE}${MOUSE_FULLNAME}${GOOD} at ${HILITE}${MOUSE_DEVICE}${NORMAL}"
177 wolf31o2 6 source /etc/sysconfig/mouse
178 wolf31o2 51 if [ -x /usr/sbin/gpm ]
179     then
180     if [ $(grep "#MOUSE=${MOUSETYPE}" /etc/conf.d/gpm) ]
181     then
182 wolf31o2 24 sed -i "\@MOUSE=${MOUSETYPE}@s@^#@@" /etc/conf.d/gpm
183     else
184     echo "MOUSE=${MOUSETYPE}" >>/etc/conf.d/gpm
185     fi
186 wolf31o2 51 if [ $(grep "#MOUSEDEV=${DEVICE}" /etc/conf.d/gpm) ]
187     then
188 wolf31o2 24 sed -i "\@MOUSEDEV=${DEVICE}@s@^#@@" /etc/conf.d/gpm
189     else
190     echo "MOUSEDEV=${DEVICE}" >>/etc/conf.d/gpm
191     fi
192 wolf31o2 51 if [ "${GPM}" = "yes" ]
193     then
194 wolf31o2 77 [ -x /etc/init.d/gpm ] && start_service gpm
195 wolf31o2 24 fi
196 wolf31o2 29 fi
197 wolf31o2 6 eend
198     fi
199 zhen 2
200 wolf31o2 51 if [ "${HOTPLUG}" = "yes" ]
201     then
202 wolf31o2 17 #Check whether we should be using hotplug or coldplug
203 wolf31o2 51 if [ -x /etc/init.d/coldplug ]
204     then
205 wolf31o2 77 start_service coldplug
206 wolf31o2 67 elif [ -x /etc/init.d/hotplug ]
207     then
208 wolf31o2 77 start_service hotplug
209 wolf31o2 17 fi
210 zhen 2 else
211 wolf31o2 18 ebegin ${BAD}"Hotplug disabled via cmdline${NORMAL}"
212 wolf31o2 6 fi
213 zhen 2
214 wolf31o2 51 if [ "${DETECT}" = "no" ]
215     then
216 wolf31o2 6 DHCP="no"
217     fi
218 zhen 2
219 wolf31o2 51 if [ "${DETECT}" = "yes" ]
220     then
221 wolf31o2 61 NETDEVICES="$(awk -F: '/eth.:|tr.:|ath.:|wlan.:/{print $1}' /proc/net/dev 2>/dev/null)"
222 wolf31o2 6 fi
223 zhen 2
224 wolf31o2 51 if [ -n "${NETDEVICES}" ]
225     then
226 wolf31o2 74 for nics in ${NETDEVICES}
227     do
228     if [ "${DHCP}" = "yes" ]
229     then
230     ebegin ${GOOD}"Network device${HILITE}${nics}${GOOD} detected,${WARN} DHCP broadcasting for IP.${NORMAL}"
231     dhcpcd -n -h $(hostname) &
232     fi
233     eend
234     done
235 zhen 2 else
236 wolf31o2 18 ebegin ${BAD}"No Network device auto detected.${NORMAL}"
237 wolf31o2 6 fi
238 zhen 2
239 wolf31o2 68 if [ "${ALSA}" = "yes" ]
240 wolf31o2 51 then
241 wolf31o2 68 if [ -n "${SOUND_FULLNAME}" -o -n "${SOUND_DRIVER}" ]
242 wolf31o2 51 then
243 wolf31o2 68 ebegin ${GOOD}"Soundcard:"
244     eend
245     [ -n "${SOUND_FULLNAME}" ]
246     ebegin " ${WARN}${SOUND_FULLNAME}"
247     [ -n "${SOUND_DRIVER}" ]
248     ebegin ${WARN}" driver = ${SOUND_DRIVER}"${HILITE}
249 wolf31o2 70 if [ -x /etc/init.d/alsasound ]
250     then
251 wolf31o2 77 start_service alsasound
252 wolf31o2 70 else
253     ebegin ${WARN}"/etc/init.d/alsasound not found, skipping."
254 wolf31o2 71 einfo "You will need to set volume controls manually."
255 wolf31o2 70 fi
256 wolf31o2 73 for i in $(cat /proc/asound/cards | cut -d" " -f1)
257     do
258     if [ -d /proc/asound/card$i ] && [ -x /usr/bin/amixer ]
259 wolf31o2 68 then
260 wolf31o2 73 amixer -c $i scontrols > /etc/amixer
261     if [ -n "$(grep Master /etc/amixer)" ]
262     then
263     amixer -c $i -q set Master 95% unmute >/dev/null 2>&1
264     fi
265     if [ -n "$(grep PCM /etc/amixer)" ]
266     then
267     amixer -c $i -q set PCM 95% unmute >/dev/null 2>&1
268     fi
269     if [ -n "$(grep Mic /etc/amixer)" ]
270     then
271     amixer -c $i -q set Mic 95% mute cap >/dev/null 2>&1
272     fi
273     if [ -n "$(grep Wave /etc/amixer)" ]
274     then
275     amixer -c $i -q set Wave 95% unmute >/dev/null 2>&1
276     fi
277     if [ -n "$(grep Capture /etc/amixer)" ]
278     then
279     amixer -c $i -q set Capture 95% unmute cap >/dev/null 2>&1
280     fi
281 wolf31o2 68 fi
282 wolf31o2 73 done
283 wolf31o2 15 fi
284 wolf31o2 68 else
285     ebegin ${BAD}"Skipping ALSA detection as requested on boot commandline."
286 wolf31o2 6 fi
287 zhen 2
288 wolf31o2 76 if [ "${DETECT}" = "yes" ]
289     then
290     if [ -x /etc/init.d/x-setup ]
291     then
292     schedule_service_startup x-setup
293     fi
294     fi
295    
296     if [ "${X11}" = "no" ]
297     then
298     touch /etc/init.d/.noxdm
299     fi
300    
301 wolf31o2 77 if [ -n "${XDESC}" ]
302 wolf31o2 51 then
303 wolf31o2 76 ebegin ${GOOD}"VideoCard: ${WARN} ${XDESC}"
304     eend
305 wolf31o2 6 fi
306 zhen 2
307 wolf31o2 6 killall hwsetup 2>/dev/null
308     echo "6" > /proc/sys/kernel/printk
309 zhen 2 }
310 wolf31o2 6
311     # vim: ts=4

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20