Magellan Linux

Annotation of /trunk/hwinfo/emulate-hwsetup.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1198 - (hide annotations) (download) (as text)
Mon Nov 22 22:06:20 2010 UTC (13 years, 11 months ago) by niro
File MIME type: application/x-sh
File size: 3723 byte(s)
added some fallbacks
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 niro 1198 # fallback to vesa
60     if [[ -z ${GFXCARD_MODULE[${i}]} ]]
61     then
62     GFXCARD_MODULE[${i}]="vesa"
63     fi
64    
65 niro 1197 addconfig xserver "XSERVER=\"${GFXCARD_XSERVER}\""
66     addconfig xserver "XMODULE=\"${GFXCARD_MODULE[${i}]}\""
67     addconfig xserver "XDESC=\"${GFXCARD_DESC[${i}]}\""
68    
69     # add them to knoppix too
70     addconfig knoppix "XSERVER=\"${GFXCARD_XSERVER}\""
71     addconfig knoppix "XMODULE=\"${GFXCARD_MODULE[${i}]}\""
72     addconfig knoppix "XDESC=\"${GFXCARD_DESC[${i}]}\""
73     done
74    
75     for ((i=0; i<NETCARD_COUNT; i++))
76     do
77     addconfig netcard "FULLNAME=\"${NETCARD_DESC[${i}]}\""
78     addconfig netcard "DRIVER=\"${NETCARD_MODULE[${i}]}\""
79    
80     # add them to knoppix too
81     addconfig knoppix "NETCARD_FULLNAME=\"${NETCARD_DESC[${i}]}\""
82     addconfig knoppix "NETCARD_DRIVER=\"${NETCARD_MODULE[${i}]}\""
83     done
84    
85     for ((i=0; i<MOUSE_COUNT; i++))
86     do
87     # fix mouseproto to be hwsetup compatible (it just guesses the proto :/ )
88     case "${MOUSE_GPM_PROTO[${i}]}" in
89     exps2) MOUSE_GPM_PROTO[${i}]="ps2" ;;
90 niro 1198 "") MOUSE_GPM_PROTO[${i}]="ps2" ;;
91 niro 1197 esac
92     case "${MOUSE_X11_PROTO[${i}]}" in
93     explorerps/2) MOUSE_X11_PROTO[${i}]="IMPS/2" ;;
94     ps/2) MOUSE_X11_PROTO[${i}]="PS/2" ;;
95 niro 1198 "") MOUSE_X11_PROTO[${i}]="PS/2" ;;
96 niro 1197 esac
97    
98     addconfig mouse "MOUSETYPE=\"${MOUSE_GPM_PROTO[${i}]}\""
99     addconfig mouse "XMOUSETYPE=\"${MOUSE_X11_PROTO[${i}]}\""
100     addconfig mouse "FULLNAME=\"${MOUSE_DESC[${i}]}\""
101     addconfig mouse "DEVICE=\"${MOUSE_DEVICE[${i}]}\""
102     addconfig mouse "DRIVER=\"${MOUSE_MODULE[${i}]}\""
103    
104     # add them to knoppix too
105     addconfig knoppix "MOUSE_MOUSETYPE=\"${MOUSE_GPM_PROTO[${i}]}\""
106     addconfig knoppix "MOUSE_XMOUSETYPE=\"${MOUSE_X11_PROTO[${i}]}\""
107     addconfig knoppix "MOUSE_FULLNAME=\"${MOUSE_DESC[${i}]}\""
108     addconfig knoppix "MOUSE_DEVICE=\"${MOUSE_DEVICE[${i}]}\""
109     addconfig knoppix "MOUSE_DRIVER=\"${MOUSE_MODULE[${i}]}\""
110     done