/[livecd-tools]/trunk/autoconfig
Gentoo

Diff of /trunk/autoconfig

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

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

Legend:
Removed from v.49  
changed lines
  Added in v.76

  ViewVC Help
Powered by ViewVC 1.1.20