/[livecd-tools]/trunk/autoconfig
Gentoo

Contents of /trunk/autoconfig

Parent Directory Parent Directory | Revision Log Revision Log


Revision 74 - (hide annotations) (download)
Mon Aug 15 20:53:23 2005 UTC (12 years, 2 months ago) by wolf31o2
File size: 6818 byte(s)
Hopefully not broken dhcp changes...

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20