/[livecd-tools]/trunk/autoconfig
Gentoo

Diff of /trunk/autoconfig

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.77  
changed lines
  Added in v.78

  ViewVC Help
Powered by ViewVC 1.1.20