/[livecd-tools]/trunk/autoconfig
Gentoo

Diff of /trunk/autoconfig

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

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

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

  ViewVC Help
Powered by ViewVC 1.1.20