Annotation of /trunk/hwinfo/emulate-hwsetup.sh
Parent Directory | Revision Log
Revision 1200 -
(hide annotations)
(download)
(as text)
Mon Nov 22 22:59:53 2010 UTC (13 years, 11 months ago) by niro
File MIME type: application/x-sh
File size: 4093 byte(s)
Mon Nov 22 22:59:53 2010 UTC (13 years, 11 months ago) by niro
File MIME type: application/x-sh
File size: 4093 byte(s)
-added necard_module fallback for systems without netlink -added a verbose message, what we are doing
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 | niro | 1200 | echo -n "Autoconfiguring devices... " 1>&2 |
23 | |||
24 | niro | 1197 | GFXCARD_INFO="$(${HWINFO} --gfxcard)" |
25 | NETCARD_INFO="$(${HWINFO} --netcard)" | ||
26 | MOUSE_INFO="$(${HWINFO} --mouse)" | ||
27 | |||
28 | # eval arrays with all modules and descriptions | ||
29 | # | ||
30 | # graphic | ||
31 | eval $(echo GFXCARD_MODULE=\($(echo "${GFXCARD_INFO}" | grep 'XFree86.*Module:' | sed 's:.*\:\ \(.*\)$:\"\1\":')\)) | ||
32 | eval $(echo GFXCARD_DESC=\($(echo "${GFXCARD_INFO}" | grep 'Model:' | sed 's:.*\:\ \"\(.*\)\"$:\"\1\":')\)) | ||
33 | # the xserver is always xorg, no array needed | ||
34 | GFXCARD_XSERVER="Xorg" | ||
35 | # | ||
36 | # network | ||
37 | eval $(echo NETCARD_MODULE=\($(echo "${NETCARD_INFO}" | grep 'Driver Modules:' | sed 's:.*\:\ \"\(.*\)\"$:\"\1\":')\)) | ||
38 | eval $(echo NETCARD_DESC=\($(echo "${NETCARD_INFO}" | grep 'Model:' | sed 's:.*\:\ \"\(.*\)\"$:\"\1\":')\)) | ||
39 | niro | 1200 | # fallback (only needed for systems without netlink) |
40 | eval $(echo NETCARD_MODULE_FB=\($(echo "${NETCARD_INFO}" | grep 'Driver Activation Cmd:' | sed 's:.*\:\ \"modprobe\ \(.*\)\"$:\"\1\":')\)) | ||
41 | niro | 1197 | # |
42 | # mouse | ||
43 | eval $(echo MOUSE_MODULE=\($(echo "${MOUSE_INFO}" | grep 'Driver Modules:' | sed 's:.*\:\ \"\(.*\)\"$:\"\1\":')\)) | ||
44 | eval $(echo MOUSE_DESC=\($(echo "${MOUSE_INFO}" | grep 'Model:' | sed 's:.*\:\ \"\(.*\)\"$:\"\1\":')\)) | ||
45 | eval $(echo MOUSE_DEVICE=\($(echo "${MOUSE_INFO}" | grep 'Device File:' | sed 's:.*\:\ \(.*\)[$\ ].*:\"\1\":')\)) | ||
46 | eval $(echo MOUSE_GPM_PROTO=\($(echo "${MOUSE_INFO}" | grep 'GPM.*Protocol:' | sed 's:.*\:\ \(.*\)$:\"\1\":')\)) | ||
47 | eval $(echo MOUSE_X11_PROTO=\($(echo "${MOUSE_INFO}" | grep 'XFree86.*Protocol:' | sed 's:.*\:\ \(.*\)$:\"\1\":')\)) | ||
48 | |||
49 | # get the number of devices for each class | ||
50 | GFXCARD_COUNT=$(echo "${GFXCARD_INFO}" | grep -c "[0-9a-zA-Z]\: .*\:\ .*") | ||
51 | NETCARD_COUNT=$(echo "${NETCARD_INFO}" | grep -c "[0-9a-zA-Z]\: .*\:\ .*") | ||
52 | MOUSE_COUNT=$(echo "${MOUSE_INFO}" | grep -c "[0-9a-zA-Z]\: .*\:\ .*") | ||
53 | |||
54 | |||
55 | # clear all config files | ||
56 | clearconfig xserver | ||
57 | clearconfig netcard | ||
58 | clearconfig knoppix | ||
59 | clearconfig mouse | ||
60 | |||
61 | for ((i=0; i<GFXCARD_COUNT; i++)) | ||
62 | do | ||
63 | niro | 1198 | # fallback to vesa |
64 | if [[ -z ${GFXCARD_MODULE[${i}]} ]] | ||
65 | then | ||
66 | GFXCARD_MODULE[${i}]="vesa" | ||
67 | fi | ||
68 | niro | 1197 | addconfig xserver "XSERVER=\"${GFXCARD_XSERVER}\"" |
69 | addconfig xserver "XMODULE=\"${GFXCARD_MODULE[${i}]}\"" | ||
70 | addconfig xserver "XDESC=\"${GFXCARD_DESC[${i}]}\"" | ||
71 | |||
72 | # add them to knoppix too | ||
73 | addconfig knoppix "XSERVER=\"${GFXCARD_XSERVER}\"" | ||
74 | addconfig knoppix "XMODULE=\"${GFXCARD_MODULE[${i}]}\"" | ||
75 | addconfig knoppix "XDESC=\"${GFXCARD_DESC[${i}]}\"" | ||
76 | done | ||
77 | |||
78 | for ((i=0; i<NETCARD_COUNT; i++)) | ||
79 | do | ||
80 | niro | 1200 | # use fallback |
81 | if [[ -z ${NETCARD_MODULE[${i}]} ]] | ||
82 | then | ||
83 | NETCARD_MODULE[${i}]="${NETCARD_MODULE_FB[${i}]}" | ||
84 | fi | ||
85 | niro | 1197 | addconfig netcard "FULLNAME=\"${NETCARD_DESC[${i}]}\"" |
86 | addconfig netcard "DRIVER=\"${NETCARD_MODULE[${i}]}\"" | ||
87 | |||
88 | # add them to knoppix too | ||
89 | addconfig knoppix "NETCARD_FULLNAME=\"${NETCARD_DESC[${i}]}\"" | ||
90 | addconfig knoppix "NETCARD_DRIVER=\"${NETCARD_MODULE[${i}]}\"" | ||
91 | done | ||
92 | |||
93 | for ((i=0; i<MOUSE_COUNT; i++)) | ||
94 | do | ||
95 | # fix mouseproto to be hwsetup compatible (it just guesses the proto :/ ) | ||
96 | case "${MOUSE_GPM_PROTO[${i}]}" in | ||
97 | exps2) MOUSE_GPM_PROTO[${i}]="ps2" ;; | ||
98 | niro | 1198 | "") MOUSE_GPM_PROTO[${i}]="ps2" ;; |
99 | niro | 1197 | esac |
100 | case "${MOUSE_X11_PROTO[${i}]}" in | ||
101 | explorerps/2) MOUSE_X11_PROTO[${i}]="IMPS/2" ;; | ||
102 | ps/2) MOUSE_X11_PROTO[${i}]="PS/2" ;; | ||
103 | niro | 1198 | "") MOUSE_X11_PROTO[${i}]="PS/2" ;; |
104 | niro | 1197 | esac |
105 | |||
106 | addconfig mouse "MOUSETYPE=\"${MOUSE_GPM_PROTO[${i}]}\"" | ||
107 | addconfig mouse "XMOUSETYPE=\"${MOUSE_X11_PROTO[${i}]}\"" | ||
108 | addconfig mouse "FULLNAME=\"${MOUSE_DESC[${i}]}\"" | ||
109 | addconfig mouse "DEVICE=\"${MOUSE_DEVICE[${i}]}\"" | ||
110 | addconfig mouse "DRIVER=\"${MOUSE_MODULE[${i}]}\"" | ||
111 | |||
112 | # add them to knoppix too | ||
113 | addconfig knoppix "MOUSE_MOUSETYPE=\"${MOUSE_GPM_PROTO[${i}]}\"" | ||
114 | addconfig knoppix "MOUSE_XMOUSETYPE=\"${MOUSE_X11_PROTO[${i}]}\"" | ||
115 | addconfig knoppix "MOUSE_FULLNAME=\"${MOUSE_DESC[${i}]}\"" | ||
116 | addconfig knoppix "MOUSE_DEVICE=\"${MOUSE_DEVICE[${i}]}\"" | ||
117 | addconfig knoppix "MOUSE_DRIVER=\"${MOUSE_MODULE[${i}]}\"" | ||
118 | done | ||
119 | niro | 1200 | |
120 | echo "Done." 1>&2 |