/[livecd-tools]/trunk/autoconfig
Gentoo

Contents of /trunk/autoconfig

Parent Directory Parent Directory | Revision Log Revision Log


Revision 70 - (show annotations) (download)
Sun Jul 24 02:51:01 2005 UTC (9 years ago) by wolf31o2
File size: 6588 byte(s)
Added alsasound check before attempting to start the service.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20