Annotation of /trunk/hwinfo/emulate-hwsetup.sh
Parent Directory | Revision Log
Revision 1197 -
(hide annotations)
(download)
(as text)
Mon Nov 22 11:37:48 2010 UTC (13 years, 11 months ago) by niro
File MIME type: application/x-sh
File size: 3550 byte(s)
Mon Nov 22 11:37:48 2010 UTC (13 years, 11 months ago) by niro
File MIME type: application/x-sh
File size: 3550 byte(s)
added hwsetup emulation script
1 | niro | 1197 | #!/bin/bash |
2 | |||
3 | export LC_ALL=C | ||
4 | |||
5 | HWSETUP_DIR=/etc/sysconfig/hwsetup | ||
6 | HWINFO="/usr/sbin/hwinfo" | ||
7 | |||
8 | clearconfig() | ||
9 | { | ||
10 | local file="$1" | ||
11 | : > ${HWSETUP_DIR}/${file} | ||
12 | } | ||
13 | |||
14 | addconfig() | ||
15 | { | ||
16 | local file="$1" | ||
17 | local data="$2" | ||
18 | |||
19 | echo "${data}" >> ${HWSETUP_DIR}/${file} | ||
20 | } | ||
21 | |||
22 | GFXCARD_INFO="$(${HWINFO} --gfxcard)" | ||
23 | NETCARD_INFO="$(${HWINFO} --netcard)" | ||
24 | MOUSE_INFO="$(${HWINFO} --mouse)" | ||
25 | |||
26 | # eval arrays with all modules and descriptions | ||
27 | # | ||
28 | # graphic | ||
29 | eval $(echo GFXCARD_MODULE=\($(echo "${GFXCARD_INFO}" | grep 'XFree86.*Module:' | sed 's:.*\:\ \(.*\)$:\"\1\":')\)) | ||
30 | eval $(echo GFXCARD_DESC=\($(echo "${GFXCARD_INFO}" | grep 'Model:' | sed 's:.*\:\ \"\(.*\)\"$:\"\1\":')\)) | ||
31 | # the xserver is always xorg, no array needed | ||
32 | GFXCARD_XSERVER="Xorg" | ||
33 | # | ||
34 | # network | ||
35 | eval $(echo NETCARD_MODULE=\($(echo "${NETCARD_INFO}" | grep 'Driver Modules:' | sed 's:.*\:\ \"\(.*\)\"$:\"\1\":')\)) | ||
36 | eval $(echo NETCARD_DESC=\($(echo "${NETCARD_INFO}" | grep 'Model:' | sed 's:.*\:\ \"\(.*\)\"$:\"\1\":')\)) | ||
37 | # | ||
38 | # mouse | ||
39 | eval $(echo MOUSE_MODULE=\($(echo "${MOUSE_INFO}" | grep 'Driver Modules:' | sed 's:.*\:\ \"\(.*\)\"$:\"\1\":')\)) | ||
40 | eval $(echo MOUSE_DESC=\($(echo "${MOUSE_INFO}" | grep 'Model:' | sed 's:.*\:\ \"\(.*\)\"$:\"\1\":')\)) | ||
41 | eval $(echo MOUSE_DEVICE=\($(echo "${MOUSE_INFO}" | grep 'Device File:' | sed 's:.*\:\ \(.*\)[$\ ].*:\"\1\":')\)) | ||
42 | eval $(echo MOUSE_GPM_PROTO=\($(echo "${MOUSE_INFO}" | grep 'GPM.*Protocol:' | sed 's:.*\:\ \(.*\)$:\"\1\":')\)) | ||
43 | eval $(echo MOUSE_X11_PROTO=\($(echo "${MOUSE_INFO}" | grep 'XFree86.*Protocol:' | sed 's:.*\:\ \(.*\)$:\"\1\":')\)) | ||
44 | |||
45 | # get the number of devices for each class | ||
46 | GFXCARD_COUNT=$(echo "${GFXCARD_INFO}" | grep -c "[0-9a-zA-Z]\: .*\:\ .*") | ||
47 | NETCARD_COUNT=$(echo "${NETCARD_INFO}" | grep -c "[0-9a-zA-Z]\: .*\:\ .*") | ||
48 | MOUSE_COUNT=$(echo "${MOUSE_INFO}" | grep -c "[0-9a-zA-Z]\: .*\:\ .*") | ||
49 | |||
50 | |||
51 | # clear all config files | ||
52 | clearconfig xserver | ||
53 | clearconfig netcard | ||
54 | clearconfig knoppix | ||
55 | clearconfig mouse | ||
56 | |||
57 | for ((i=0; i<GFXCARD_COUNT; i++)) | ||
58 | do | ||
59 | addconfig xserver "XSERVER=\"${GFXCARD_XSERVER}\"" | ||
60 | addconfig xserver "XMODULE=\"${GFXCARD_MODULE[${i}]}\"" | ||
61 | addconfig xserver "XDESC=\"${GFXCARD_DESC[${i}]}\"" | ||
62 | |||
63 | # add them to knoppix too | ||
64 | addconfig knoppix "XSERVER=\"${GFXCARD_XSERVER}\"" | ||
65 | addconfig knoppix "XMODULE=\"${GFXCARD_MODULE[${i}]}\"" | ||
66 | addconfig knoppix "XDESC=\"${GFXCARD_DESC[${i}]}\"" | ||
67 | done | ||
68 | |||
69 | for ((i=0; i<NETCARD_COUNT; i++)) | ||
70 | do | ||
71 | addconfig netcard "FULLNAME=\"${NETCARD_DESC[${i}]}\"" | ||
72 | addconfig netcard "DRIVER=\"${NETCARD_MODULE[${i}]}\"" | ||
73 | |||
74 | # add them to knoppix too | ||
75 | addconfig knoppix "NETCARD_FULLNAME=\"${NETCARD_DESC[${i}]}\"" | ||
76 | addconfig knoppix "NETCARD_DRIVER=\"${NETCARD_MODULE[${i}]}\"" | ||
77 | done | ||
78 | |||
79 | for ((i=0; i<MOUSE_COUNT; i++)) | ||
80 | do | ||
81 | # fix mouseproto to be hwsetup compatible (it just guesses the proto :/ ) | ||
82 | case "${MOUSE_GPM_PROTO[${i}]}" in | ||
83 | exps2) MOUSE_GPM_PROTO[${i}]="ps2" ;; | ||
84 | esac | ||
85 | case "${MOUSE_X11_PROTO[${i}]}" in | ||
86 | explorerps/2) MOUSE_X11_PROTO[${i}]="IMPS/2" ;; | ||
87 | ps/2) MOUSE_X11_PROTO[${i}]="PS/2" ;; | ||
88 | esac | ||
89 | |||
90 | addconfig mouse "MOUSETYPE=\"${MOUSE_GPM_PROTO[${i}]}\"" | ||
91 | addconfig mouse "XMOUSETYPE=\"${MOUSE_X11_PROTO[${i}]}\"" | ||
92 | addconfig mouse "FULLNAME=\"${MOUSE_DESC[${i}]}\"" | ||
93 | addconfig mouse "DEVICE=\"${MOUSE_DEVICE[${i}]}\"" | ||
94 | addconfig mouse "DRIVER=\"${MOUSE_MODULE[${i}]}\"" | ||
95 | |||
96 | # add them to knoppix too | ||
97 | addconfig knoppix "MOUSE_MOUSETYPE=\"${MOUSE_GPM_PROTO[${i}]}\"" | ||
98 | addconfig knoppix "MOUSE_XMOUSETYPE=\"${MOUSE_X11_PROTO[${i}]}\"" | ||
99 | addconfig knoppix "MOUSE_FULLNAME=\"${MOUSE_DESC[${i}]}\"" | ||
100 | addconfig knoppix "MOUSE_DEVICE=\"${MOUSE_DEVICE[${i}]}\"" | ||
101 | addconfig knoppix "MOUSE_DRIVER=\"${MOUSE_MODULE[${i}]}\"" | ||
102 | done |