/[livecd-tools]/trunk/autoconfig
Gentoo

Contents of /trunk/autoconfig

Parent Directory Parent Directory | Revision Log Revision Log


Revision 78 - (hide annotations) (download)
Wed Oct 12 17:15:27 2005 UTC (13 years, 1 month ago) by wolf31o2
File size: 6554 byte(s)
Added patch from Joshua Kinard <kumba@gentoo.org> for bug #106988.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20