Magellan Linux

Contents of /mcore-src/trunk/mcore-tools/daemon/client/include/hardware.client.class

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1644 - (show annotations) (download)
Thu Mar 10 18:14:13 2011 UTC (13 years, 1 month ago) by niro
File size: 5825 byte(s)
-use rvecho() for function retvals
-get_hardware_detect(): added a sanity check for allowed actions
1 provide hardware
2 require hwdetection
3
4 helper_hardware_netcard_device()
5 {
6 local device
7 local CONFIG
8
9 device="$(get_hwinfo netcard)"
10
11 CONFIG="${MCORE_CONFIG_PATH}/hardware/netcard.device"
12 clearconfig
13 addconfig "${device}"
14
15 rvecho "${device}"
16 }
17
18 helper_hardware_netcard_driver()
19 {
20 local driver
21 local CONFIG
22
23 driver="$(get_driver_modules netcard)"
24
25 CONFIG="${MCORE_CONFIG_PATH}/hardware/netcard.driver"
26 clearconfig
27 addconfig "${driver}"
28
29 rvecho "${driver}"
30 }
31
32 #wlan.device
33 #wlan.driver
34
35 # hardware_graphic_device()
36 # {
37 # local device
38 # graphic.device
39 # }
40
41 helper_hardware_graphic_driver()
42 {
43 local driver
44 local CONFIG
45
46 driver="$(get_x11_driver_modules)"
47
48 # sane fallback
49 [[ -z ${driver} ]] && driver="vesa"
50
51 CONFIG="${MCORE_CONFIG_PATH}/hardware/graphic.driver"
52 clearconfig
53 addconfig "${driver}"
54
55 rvecho "${driver}"
56 }
57
58 helper_hardware_disk_device()
59 {
60 local device
61 local CONFIG
62
63 device="$(get_hwinfo disk)"
64
65 CONFIG="${MCORE_CONFIG_PATH}/hardware/disk.device"
66 clearconfig
67 addconfig "${device}"
68
69 rvecho "${device}"
70 }
71
72 helper_hardware_cdrom_device()
73 {
74 local device
75 local CONFIG
76
77 device="$(get_hwinfo cdrom)"
78
79 CONFIG="${MCORE_CONFIG_PATH}/hardware/cdrom.device"
80 clearconfig
81 addconfig "${device}"
82
83 rvecho "${device}"
84 }
85
86 helper_hardware_keyboard_device()
87 {
88 local device
89 local CONFIG
90
91 device="$(get_hwinfo keyboard)"
92
93 CONFIG="${MCORE_CONFIG_PATH}/hardware/keyboard.device"
94 clearconfig
95 addconfig "${device}"
96
97 rvecho "${device}"
98 }
99
100 # helper_hardware_keyboard_info()
101 # {
102 # keyboard.info
103 # }
104
105 helper_hardware_mouse_device()
106 {
107 local device
108 local CONFIG
109
110 device="$(get_hwinfo mouse)"
111
112 CONFIG="${MCORE_CONFIG_PATH}/hardware/mouse.device"
113 clearconfig
114 addconfig "${device}"
115
116 rvecho "${device}"
117 }
118
119 # helper_hardware_mouse_info()
120 # {
121 # mouse.info
122 # }
123
124 helper_hardware_printer_device()
125 {
126 local device
127 local CONFIG
128
129 device="$(get_hwinfo printer)"
130
131 CONFIG="${MCORE_CONFIG_PATH}/hardware/printer.device"
132 clearconfig
133 addconfig "${device}"
134
135 rvecho "${device}"
136 }
137
138 helper_hardware_printer_driver()
139 {
140 local driver
141 local CONFIG
142
143 driver="$(get_driver_modules printer)"
144
145 CONFIG="${MCORE_CONFIG_PATH}/hardware/printer.driver"
146 clearconfig
147 addconfig "${driver}"
148
149 rvecho "${driver}"
150 }
151
152 # hardware_printer_info()
153 # {
154 # printer.info
155 # }
156
157 helper_hardware_sound_device()
158 {
159 local device
160 local CONFIG
161
162 device="$(get_hwinfo sound)"
163
164 CONFIG="${MCORE_CONFIG_PATH}/hardware/sound.device"
165 clearconfig
166 addconfig "${device}"
167
168 rvecho "${device}"
169 }
170
171 helper_hardware_sound_driver()
172 {
173 local driver
174 local CONFIG
175
176 driver="$(get_driver_modules sound)"
177
178 CONFIG="${MCORE_CONFIG_PATH}/hardware/sound.driver"
179 clearconfig
180 addconfig "${driver}"
181
182 rvecho "${driver}"
183 }
184
185 # helper_hardware_sound_info()
186 # {
187 # sound.info
188 # }
189
190 helper_hardware_monitor_info()
191 {
192 local info
193 local CONFIG
194
195 info="$(get_hwinfo_monitor)"
196
197 CONFIG="${MCORE_CONFIG_PATH}/hardware/monitor.hsync"
198 clearconfig
199 addconfig "$(echo ${info} | cut -d';' -f1)"
200
201 CONFIG="${MCORE_CONFIG_PATH}/hardware/monitor.vsync"
202 clearconfig
203 addconfig "$(echo ${info} | cut -d';' -f2)"
204
205 CONFIG="${MCORE_CONFIG_PATH}/hardware/monitor.resolution"
206 clearconfig
207 addconfig "$(echo ${info} | cut -d';' -f3)"
208
209 rvecho "${info}"
210 }
211
212 helper_hardware_arch_info()
213 {
214 local info
215 local CONFIG
216
217 info="$(hwinfo --short --arch)"
218
219 CONFIG="${MCORE_CONFIG_PATH}/hardware/arch.info"
220 clearconfig
221 addconfig "${info}"
222
223 rvecho "${info}"
224 }
225
226 helper_hardware_cpu_info()
227 {
228 local info
229 local CONFIG
230
231 info="$(hwinfo --short --cpu)"
232
233 CONFIG="${MCORE_CONFIG_PATH}/hardware/cpu.info"
234 clearconfig
235 addconfig "${info}"
236
237 rvecho "${info}"
238 }
239
240 helper_hardware_memory_info()
241 {
242 local info
243 local CONFIG
244
245 info="$(get_hwinfo memory)"
246
247 CONFIG="${MCORE_CONFIG_PATH}/hardware/memory.info"
248 clearconfig
249 addconfig "${info}"
250
251 rvecho "${info}"
252 }
253
254 # helper_hardware_framebuffer_info()
255 # {
256 # framebuffer.info
257 # }
258
259 # helper_hardware_bios_info()
260 # {
261 # bios.info -> zotac, virtualbox etc??
262 # }
263
264 # get_hardware_info()
265 # {
266 # local class="$1"
267 #
268 # case "${class}" in
269 # memory|cpu|arch|monitor) helper_hardware_"${class}"_info ;;
270 # esac
271 # }
272 #
273 # get_hardware_driver()
274 # {
275 # local class="$1"
276 #
277 # case "${class}" in
278 # netcard|graphic|sound|printer) helper_hardware_"${class}"_driver ;;
279 # esac
280 # }
281 #
282 # get_hardware_device()
283 # {
284 # local class="$1"
285 #
286 # case "${class}" in
287 # netcard|graphic|sound|printer) helper_hardware_"${class}"_device ;;
288 # disk|cdrom|keyboard|mouse) helper_hardware_"${class}"_device ;;
289 # esac
290 # }
291
292 help_hardware_detect()
293 {
294 mecho "get hardware.detect [action] [class]"
295 mecho " Prints information about the systems hardware"
296 mecho " Available classes:"
297 mecho " memory, cpu, arch, monitor, netcard, graphic, sound,"
298 mecho " printer, disk, cdrom, keyboard, mouse"
299 mecho " Available actions:"
300 mecho " info - general information about a hwclass"
301 mecho " driver - needed drivers of selected class if available"
302 mecho " device - prints the device of selected class if available"
303 }
304
305 get_hardware_detect()
306 {
307 local action="$1"
308 local class="$2"
309
310 # sanity check
311 case "${action}" in
312 info|driver|device) ;;
313 *) help_hardware_detect && return 1 ;;
314 esac
315
316 case "${class}" in
317 memory) helper_hardware_"${class}"_"${action}" ;;
318 cpu) helper_hardware_"${class}"_"${action}" ;;
319 arch) helper_hardware_"${class}"_"${action}" ;;
320 monitor) helper_hardware_"${class}"_"${action}" ;;
321 netcard) helper_hardware_"${class}"_"${action}" ;;
322 graphic) helper_hardware_"${class}"_"${action}" ;;
323 sound) helper_hardware_"${class}"_"${action}" ;;
324 printer) helper_hardware_"${class}"_"${action}" ;;
325 disk) helper_hardware_"${class}"_"${action}" ;;
326 cdrom) helper_hardware_"${class}"_"${action}" ;;
327 keyboard) helper_hardware_"${class}"_"${action}" ;;
328 mouse) helper_hardware_"${class}"_"${action}" ;;
329 *) help_hardware_detect && return 1 ;;
330 esac
331 }