1 |
#!/bin/bash |
#!/bin/bash |
2 |
# $Header: /home/cvsd/magellan-cvs/magellan-src/installer/include/hwdetection.sh,v 1.1 2008-09-24 10:54:00 niro Exp $ |
# $Id$ |
3 |
|
|
4 |
## hwdetection, needs >= sys-apps/hwinfo |
## hwdetection, needs >= sys-apps/hwinfo |
5 |
|
|
75 |
{ |
{ |
76 |
local item="$1" |
local item="$1" |
77 |
local modules |
local modules |
|
|
|
|
# being little tricky here :) |
|
|
# does following: |
|
|
# grep: |
|
|
# -> 'Driver Modules: "via82cxxx", "ide_cd"' |
|
|
# cut: |
|
|
# -> ' "via82cxxx", "ide_cd"' |
|
|
# sed1: |
|
|
# -> ' modules="via82cxxx", "ide_cd"' |
|
|
# sed2: |
|
|
# -> ' modules="via82cxxx ide_cd"' |
|
|
# then evaluate -> eval modules="via82cxxx ide_cd" |
|
|
# and we get a variable $modules with all mods |
|
|
#eval $(hwinfo --"${item}" | grep "Driver Modules:" | cut -d: -f2 | sed -e "s:\":modules=\":" -e "s:\",\ \":\ :") |
|
|
|
|
78 |
local i |
local i |
79 |
|
|
80 |
for i in $(hwinfo --"${item}" | grep "Driver Modules:" | cut -d: -f2 ) |
for i in $(hwinfo --"${item}" | grep "Driver Modules:" | cut -d: -f2 ) |
81 |
do |
do |
82 |
eval $(echo "${i}" | sed -e "s:\":modules=\"\${modules}\ :" -e "s:,:\ :") |
eval $(echo "${i}" | sed -e "s:\":modules=\"\${modules}\ :" -e "s:,:\ :") |
83 |
done |
done |
84 |
echo "${modules}" |
remove_duplicates "${modules}" |
85 |
} |
} |
86 |
|
|
87 |
# remove_duplicates $list |
# remove_duplicates $list |
103 |
|
|
104 |
# remove all ':' and show the cleaned list |
# remove all ':' and show the cleaned list |
105 |
# this way fixes double spaces also |
# this way fixes double spaces also |
106 |
|
local counter |
107 |
|
declare -i counter=0 |
108 |
for i in $(echo ${fixed_list} | sed "s|:| |g") |
for i in $(echo ${fixed_list} | sed "s|:| |g") |
109 |
do |
do |
110 |
list+=" ${i}" |
(( counter++ )) |
111 |
|
if [[ ${counter} -eq 1 ]] |
112 |
|
then |
113 |
|
list="${i}" |
114 |
|
else |
115 |
|
list+=" ${i}" |
116 |
|
fi |
117 |
done |
done |
118 |
|
|
119 |
echo "${list}" |
echo "${list}" |
122 |
get_x11_driver_modules() |
get_x11_driver_modules() |
123 |
{ |
{ |
124 |
local modules |
local modules |
125 |
modules="$(hwinfo --gfxcard | grep "XFree86 v4 Server Module:" | cut -d: -f2)" |
modules="$(hwinfo --gfxcard | grep 'XFree86 v4 Server Module:' | sed 's/.*Module:\ \(.*\)/\1/')" |
126 |
|
|
127 |
# remove duplicates from list and show it |
# remove duplicates from list and show it |
128 |
remove_duplicates "${modules}" |
remove_duplicates "${modules}" |
129 |
} |
} |
130 |
|
|
131 |
|
get_evdev_device_path() |
132 |
|
{ |
133 |
|
local device="$1" |
134 |
|
local path |
135 |
|
|
136 |
|
case ${device} in |
137 |
|
mouse|keyboard) true;; |
138 |
|
*) die "unkown device";; |
139 |
|
esac |
140 |
|
|
141 |
|
path="$(hwinfo --${device} | grep 'Device Files:' | sed 's:.*\(/dev/input/event[0-5]\).*:\1:')" |
142 |
|
echo "${path}" |
143 |
|
} |
144 |
|
|
145 |
|
# get_netcard_driver_modules device |
146 |
|
# e.g. get_netcard_driver_modules eth0 |
147 |
|
get_netcard_driver_modules() |
148 |
|
{ |
149 |
|
local device="$1" |
150 |
|
local modules |
151 |
|
|
152 |
|
if [[ -z ${device} ]] |
153 |
|
then |
154 |
|
echo "Error: get_netcard_driver_module(): no device given" |
155 |
|
return 1 |
156 |
|
fi |
157 |
|
|
158 |
|
modules=$(hwinfo --netcard | grep -B1 "Device File: ${device}" | sed 's/.*Modules: \"\(.*\)\"/\1/;q') |
159 |
|
remove_duplicates "${modules}" |
160 |
|
} |
161 |
|
|
162 |
|
get_blkid_information() |
163 |
|
{ |
164 |
|
local partition="$1" |
165 |
|
local variable="$2" |
166 |
|
local method |
167 |
|
|
168 |
|
case $1 in |
169 |
|
--uuid|-u) shift; method="-U"; partition="$1"; variable="$2" ;; |
170 |
|
--label|-l) shift; method="-L"; partition="$1"; variable="$2" ;; |
171 |
|
esac |
172 |
|
|
173 |
|
if [[ -z ${partition} ]] |
174 |
|
then |
175 |
|
echo "Error: get_get_blkid_information()(): no partition given" |
176 |
|
return 1 |
177 |
|
fi |
178 |
|
|
179 |
|
if [[ -z ${variable} ]] |
180 |
|
then |
181 |
|
echo "Error: get_get_blkid_information()(): no variable given" |
182 |
|
return 1 |
183 |
|
fi |
184 |
|
|
185 |
|
blkid -o value -s "${variable}" "${method}" "${partition}" |
186 |
|
} |
187 |
|
|
188 |
|
get_fstype() |
189 |
|
{ |
190 |
|
local partition="$1" |
191 |
|
if [[ -z ${partition} ]] |
192 |
|
then |
193 |
|
echo "Error: get_fstype(): no partition given" |
194 |
|
return 1 |
195 |
|
fi |
196 |
|
|
197 |
|
# does not work with uuids |
198 |
|
#mount -f --guess-fstype ${partition} |
199 |
|
|
200 |
|
get_blkid_information ${partition} TYPE |
201 |
|
} |
202 |
|
|
203 |
|
get_uuid() |
204 |
|
{ |
205 |
|
local partition="$1" |
206 |
|
if [[ -z ${partition} ]] |
207 |
|
then |
208 |
|
echo "Error: get_uuid(): no partition given" |
209 |
|
return 1 |
210 |
|
fi |
211 |
|
|
212 |
|
# does not work with uuids |
213 |
|
#mount -f --guess-fstype ${partition} |
214 |
|
|
215 |
|
get_blkid_information ${partition} UUID |
216 |
|
} |
217 |
|
|
218 |
# create_initrd {/path/to/initrd kernelversion </path/to/config>} |
# create_initrd {/path/to/initrd kernelversion </path/to/config>} |
219 |
# when nothing given then /boot/initrd-$(uname -r).img $(uname -r) will be used |
# when nothing given then /boot/initrd-$(uname -r).img $(uname -r) will be used |
220 |
# default config path is /etc/conf.d/mkinitrd |
# default config path is /etc/conf.d/mkinitrd |
226 |
local chroot |
local chroot |
227 |
#local root |
#local root |
228 |
local modules |
local modules |
229 |
|
# enabled framebuffer modules as default |
230 |
|
local framebuffer=1 |
231 |
|
local uvesafb_config="/etc/modprobe.d/uvesafb.conf" |
232 |
|
|
233 |
# very basic getops |
# very basic getops |
234 |
for i in $* |
for i in $* |
235 |
do |
do |
236 |
case $1 in |
case $1 in |
|
#--root|-r) shift; root="$1" ;; |
|
237 |
--initrd|-i) shift; initrd="$1" ;; |
--initrd|-i) shift; initrd="$1" ;; |
238 |
--config|-c) shift; config="$1" ;; |
--config|-c) shift; config="$1" ;; |
239 |
--kernelversion|-v) shift; kernel="$1" ;; |
--kernelversion|-v) shift; kernel="$1" ;; |
240 |
|
--nofb) shift; framebuffer=0 |
241 |
esac |
esac |
242 |
shift |
shift |
243 |
done |
done |
249 |
if [[ ! -z ${INSTALL_ROOT} ]] |
if [[ ! -z ${INSTALL_ROOT} ]] |
250 |
then |
then |
251 |
config="${INSTALL_ROOT}/${config}" |
config="${INSTALL_ROOT}/${config}" |
252 |
|
uvesafb_config="${INSTALL_ROOT}/${uvesafb_config}" |
253 |
chroot="chrooted" |
chroot="chrooted" |
254 |
fi |
fi |
255 |
|
|
264 |
modules+=" $(grep ide_disk /proc/modules | cut -d' ' -f4 | sed '/-/d;s:,:\ :g')" |
modules+=" $(grep ide_disk /proc/modules | cut -d' ' -f4 | sed '/-/d;s:,:\ :g')" |
265 |
fi |
fi |
266 |
|
|
267 |
|
# check for usb-storage and add usb host drivers |
268 |
|
if [[ ! -z $(echo ${modules} | grep usb[_-]storage) ]] |
269 |
|
then |
270 |
|
# add usb1, usb1.1, usb2 and ubs3 hosts |
271 |
|
modules+=" uhci-hcd ohci-hcd ehci-hcd xhci-hcd" |
272 |
|
fi |
273 |
|
|
274 |
|
# add some generic modules |
275 |
|
modules+=" sg_mod sg loop sr_mod sd_mod ide-cd ide-cd_mod ide-disk" |
276 |
|
|
277 |
|
# add generic framebuffer modules |
278 |
|
if [[ ${framebuffer} = 1 ]] |
279 |
|
then |
280 |
|
modules+=" uvesafb" |
281 |
|
|
282 |
|
# setup modprobe conf too |
283 |
|
[[ ! -d $(dirname ${uvesafb_config}) ]] && install -d $(dirname ${uvesafb_config}) |
284 |
|
cat > ${uvesafb_config} << EOF |
285 |
|
# This file sets the parameters for uvesafb module. |
286 |
|
# The following format should be used: |
287 |
|
# options uvesafb mode_option=<xres>x<yres>[-<bpp>][@<refresh>] scroll=<ywrap|ypan|redraw> ... |
288 |
|
# |
289 |
|
# For more details see: |
290 |
|
# http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=Documentation/fb/uvesafb.txt |
291 |
|
# |
292 |
|
EOF |
293 |
|
# fix a issues with virtualbox and 'ywrap' |
294 |
|
if [[ ! -z $(hwinfo --bios | grep -i virtualbox) ]] |
295 |
|
then |
296 |
|
# use redraw on virtualbox |
297 |
|
echo "options uvesafb mode_option=1024x768-32@60 scroll=redraw" >> ${uvesafb_config} |
298 |
|
else |
299 |
|
# default config 1024x768 and 60 HZ |
300 |
|
echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" >> ${uvesafb_config} |
301 |
|
fi |
302 |
|
fi |
303 |
|
|
304 |
# remove all duplicate modules |
# remove all duplicate modules |
305 |
modules="$(remove_duplicates ${modules})" |
modules="$(remove_duplicates ${modules})" |
306 |
|
|
326 |
umount ${INSTALL_ROOT}/proc |
umount ${INSTALL_ROOT}/proc |
327 |
umount ${INSTALL_ROOT}/sys |
umount ${INSTALL_ROOT}/sys |
328 |
} |
} |
|
|
|
|
# special: memory (size), floppy (modprobe floppy), smp (support y/n) |
|
|
# sound (which module? -> eval $(hwinfo --sound | grep "Driver Modules:" | cut -d: -f2 | sed s:\":a=\":) ) |
|
|
# |
|
|
|
|
|
# for i in cdrom cpu disk floppy gfxcard keyboard memory monitor mouse |
|
|
# netcard pppoe scsi smp \ |
|
|
# sound wlan |
|
|
# do |
|
|
# echo -------- ${i} |
|
|
# get_hwinfo ${i} |
|
|
# echo ------------------------------------------------- |
|
|
# echo |
|
|
# done |
|
|
|
|
|
# get_driver_modules sound |
|
|
# get_driver_modules wlan |
|
|
# get_driver_modules cdrom |
|
|
# get_driver_modules disk |
|
|
# get_driver_modules gfxcard |
|
|
# get_x11_driver_modules |
|
|
|
|
|
# # get a modules list |
|
|
# for i in sound wlan cdrom disk gfxcard |
|
|
# do |
|
|
# ALL_MODULES="${ALL_MODULES} $(get_driver_modules ${i})" |
|
|
# done |
|
|
# ALL_MODULES="${ALL_MODULES} $(get_x11_driver_modules)" |
|
|
# # show a clean list |
|
|
# for i in $(remove_duplicates ${ALL_MODULES}) |
|
|
# do |
|
|
# echo ${i} |
|
|
# done |
|
|
|
|
|
#create_initrd /root/TEST/initrd |
|
|
#get_driver_modules cdrom |
|
|
#get_driver_modules disk |
|
|
#get_driver_modules scsi |
|
|
#get_driver_modules all |
|
|
|
|
|
# network |
|
|
#get_hwinfo --with-description netcard |
|
|
#get_driver_modules netcard |
|
|
|
|
|
#get_hwinfo disk |
|
|
#get_hwinfo partition | grep /dev/hda |
|