Contents of /alx-src/branches/alxconf-060/bin/alx-hwdetection.sh
Parent Directory | Revision Log
Revision 4912 -
(show annotations)
(download)
(as text)
Wed May 29 09:31:01 2013 UTC (10 years, 11 months ago) by niro
File MIME type: application/x-sh
File size: 3879 byte(s)
Wed May 29 09:31:01 2013 UTC (10 years, 11 months ago) by niro
File MIME type: application/x-sh
File size: 3879 byte(s)
-always use openchrome on dell optiplex fx130
1 | #!/bin/bash |
2 | |
3 | # hwinfo wrapper to use hwinfo with sudo if requested |
4 | hwinfo() |
5 | { |
6 | local use_sudo="" |
7 | case ${SUDO} in |
8 | yes|y|true|1) use_sudo=sudo ;; |
9 | esac |
10 | |
11 | ${use_sudo} /usr/sbin/hwinfo $@ |
12 | } |
13 | |
14 | # get_hwinfo $hw_item |
15 | get_hwinfo() |
16 | { |
17 | local enable_desc="0" |
18 | |
19 | if [[ $1 = --with-description ]] || [[ $1 = -d ]] |
20 | then |
21 | enable_desc=1 |
22 | shift |
23 | fi |
24 | |
25 | local item="$1" |
26 | local all |
27 | local i |
28 | |
29 | # handle special items |
30 | case ${item} in |
31 | memory) get_hwinfo_memory; return ;; |
32 | smp) get_hwinfo_smp; return ;; |
33 | esac |
34 | |
35 | all=$(hwinfo --short --"${item}") |
36 | |
37 | declare -i i=0 |
38 | while read device description |
39 | do |
40 | # skip the first line |
41 | (( i++ )) |
42 | [ ${i} -eq 1 ] && continue |
43 | |
44 | if [[ ${enable_desc} = 1 ]] |
45 | then |
46 | echo "${device};${description}" |
47 | else |
48 | echo "${device}" |
49 | fi |
50 | done <<< "${all}" |
51 | } |
52 | |
53 | # remove_duplicates $list |
54 | remove_duplicates() |
55 | { |
56 | local list="$@" |
57 | local fixed_list=":" |
58 | local i |
59 | |
60 | for i in ${list} |
61 | do |
62 | if [[ -z $(echo "${fixed_list}" | fgrep ":${i}:") ]] |
63 | then |
64 | fixed_list="${fixed_list}${i}:" |
65 | fi |
66 | done |
67 | |
68 | unset list |
69 | |
70 | # remove all ':' and show the cleaned list |
71 | # this way fixes double spaces also |
72 | local counter |
73 | declare -i counter=0 |
74 | for i in $(echo ${fixed_list} | sed "s|:| |g") |
75 | do |
76 | (( counter++ )) |
77 | if [[ ${counter} -eq 1 ]] |
78 | then |
79 | list="${i}" |
80 | else |
81 | list+=" ${i}" |
82 | fi |
83 | done |
84 | |
85 | echo "${list}" |
86 | } |
87 | |
88 | get_x11_driver_modules() |
89 | { |
90 | local modules |
91 | modules="$(hwinfo --gfxcard | grep 'XFree86 v4 Server Module:' | sed 's/.*Module:\ \(.*\)/\1/')" |
92 | |
93 | # use vesa if nothing was found |
94 | [[ -z ${modules} ]] && modules="vesa" |
95 | |
96 | # use openchrome module on dell optiplex fx130 |
97 | if [[ ! -z $(hwinfo --bios | grep -i -A1 dell | grep -i fx130) ]] |
98 | then |
99 | modules="${modules//unichrome/openchrome}" |
100 | fi |
101 | |
102 | # remove duplicates from list and show it |
103 | remove_duplicates "${modules}" |
104 | } |
105 | |
106 | get_drm_driver_modules() |
107 | { |
108 | local modules |
109 | modules="$(hwinfo --gfxcard | grep 'Driver:' | sed 's/.*: \"\(.*\)\"/\1/;q')" |
110 | |
111 | # use vesa if nothing was found |
112 | [[ -z ${modules} ]] && modules="uvesafb" |
113 | |
114 | # remove duplicates from list and show it |
115 | remove_duplicates "${modules}" |
116 | } |
117 | |
118 | get_wlan_driver_modules() |
119 | { |
120 | local device="$1" |
121 | local modules |
122 | |
123 | if [[ -z ${device} ]] |
124 | then |
125 | echo "Error: get_netcard_driver_module(): no device given" |
126 | return 1 |
127 | fi |
128 | |
129 | modules=$(hwinfo --wlan | grep -B1 "Device File: ${device}" | sed 's/.*Modules: \"\(.*\)\"/\1/;q') |
130 | remove_duplicates "${modules}" |
131 | } |
132 | |
133 | get_netcard_driver_modules() |
134 | { |
135 | local device="$1" |
136 | local modules |
137 | |
138 | if [[ -z ${device} ]] |
139 | then |
140 | echo "Error: get_netcard_driver_module(): no device given" |
141 | return 1 |
142 | fi |
143 | |
144 | modules=$(hwinfo --netcard | grep -B1 "Device File: ${device}" | sed 's/.*Modules: \"\(.*\)\"/\1/;q') |
145 | remove_duplicates "${modules}" |
146 | } |
147 | |
148 | get_system_type() |
149 | { |
150 | local hwinfo |
151 | local systemtype |
152 | |
153 | hwinfo="$(hwinfo --bios --storage)" |
154 | |
155 | if [[ ! -z $(echo "${hwinfo}" | grep -i zotac) ]] |
156 | then |
157 | systemtype="zotac" |
158 | elif [[ ! -z $(echo "${hwinfo}" | grep -i CLE266) ]] |
159 | then |
160 | systemtype="rangee" |
161 | elif [[ ! -z $(echo "${hwinfo}" | grep -i i810) ]] |
162 | then |
163 | systemtype="maxdata" |
164 | elif [[ ! -z $(echo "${hwinfo}" | grep -i i815) ]] |
165 | then |
166 | systemtype="maxdata" |
167 | else |
168 | systemtype="standard" |
169 | fi |
170 | |
171 | echo "${systemtype}" |
172 | } |
173 | |
174 | intel_framebuffer_quirk_required() |
175 | { |
176 | local retval=0 |
177 | local fbdev |
178 | |
179 | if [[ -e /proc/fb ]] |
180 | then |
181 | if [[ ! -z $(grep 'inteldrmfb' /proc/fb) ]] |
182 | then |
183 | fbdev=$(grep 'inteldrmfb' /proc/fb | sed 's:\([0-9]\).*:\1:') |
184 | if [[ ${fbdev} != 0 ]] |
185 | then |
186 | retval="${fbdev}" |
187 | fi |
188 | fi |
189 | fi |
190 | |
191 | echo "${retval}" |
192 | } |
193 | |
194 | # debug |
195 | #echo "LAN: $(get_netcard_driver_modules eth0)" |
196 | #echo "WLAN: $(get_wlan_driver_modules wlan0)" |
197 | #echo "X11: $(get_x11_driver_modules)" |
198 | #echo "KMS/FB: $(get_drm_driver_modules)" |
199 | |
200 | case $1 in |
201 | wlan) get_wlan_driver_modules wlan0 ;; |
202 | lan) get_netcard_driver_modules eth0 ;; |
203 | vga) get_x11_driver_modules ;; |
204 | console) get_drm_driver_modules ;; |
205 | system) get_system_type ;; |
206 | intel-fb-quirk) intel_framebuffer_quirk_required ;; |
207 | esac |