Magellan Linux

Annotation of /mcore-src/trunk/mcore-tools/src/modules/hwinfo/hardware.control.class.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2617 - (hide annotations) (download)
Fri Sep 25 07:28:51 2015 UTC (8 years, 8 months ago) by niro
File size: 4025 byte(s)
-add an vnc db entry on hardware-detection
1 niro 2487 # $Id$
2    
3 niro 2497 provide hardware
4 niro 2487 require hwdetection
5     require mysql
6    
7 niro 2499 run_hardware_detect()
8 niro 2487 {
9 niro 2499 local serial="$1"
10 niro 2487
11     local cmd
12     local netcard_driver
13 niro 2496 local networking
14     local hostname
15     local domain
16 niro 2487 local graphic_driver
17     local monitor_info
18     local monitor_resolution
19 niro 2500 local keymap
20 niro 2497 local hwdetected
21 niro 2502 local auth
22 niro 2500 local i
23 niro 2487
24 niro 2499 if [[ -z ${serial} ]]
25     then
26     decho "No serial given"
27     return 1
28     fi
29    
30 niro 2497 # first check if hardware detect was already done
31     hwdetected=$(mysqldo "select hwdetected from client_serials where serial=${serial};")
32     if [[ ${hwdetected} = 1 ]]
33     then
34     decho "hardware detection already run, aborting"
35     return 0
36 niro 2498 else
37     decho "running hardware detection"
38 niro 2497 fi
39    
40 niro 2487 nsslsay_queue_init
41     nsslsay_queue_add "nocolors"
42 niro 2614 #nsslsay_queue_add "get hardware.detect driver netcard"
43     nsslsay_queue_add "get hardware.detect driver connected-iface"
44 niro 2487 netcard_driver=$(control_client "${serial}" run-queue)
45     if [[ -n ${netcard_driver} ]]
46     then
47 niro 2495 decho "netcard_driver='${netcard_driver}'"
48     import_resource cfg_network "${serial}" module "${netcard_driver}"
49 niro 2487 else
50     decho "no netcard_driver found"
51     fi
52 niro 2496 networking=$(mysqldo "select networking from cfg_network where serial=${serial};")
53     if [[ -z ${networking} ]] || [[ ${networking} = NULL ]]
54 niro 2488 then
55     # set network to dhcp
56 niro 2493 decho "networking='dhcp'"
57 niro 2488 import_resource cfg_network "${serial}" networking "dhcp"
58     fi
59 niro 2496 hostname=$(mysqldo "select hostname from cfg_network where serial=${serial};")
60     if [[ -z ${hostname} ]] || [[ ${hostname} = NULL ]]
61 niro 2488 then
62     # set hostname to MCORE_DEFAULT_HOSTNAME
63 niro 2493 decho "hostname='${MCORE_DEFAULT_HOSTNAME}'"
64 niro 2488 import_resource cfg_network "${serial}" hostname "${MCORE_DEFAULT_HOSTNAME}"
65     fi
66 niro 2496 domain=$(mysqldo "select domain from cfg_network where serial=${serial};")
67     if [[ -z ${domain} ]] || [[ ${domain} = NULL ]]
68 niro 2491 then
69     # set domain to MCORE_DEFAULT_DOMAIN
70 niro 2493 decho "hostname='${MCORE_DEFAULT_DOMAIN}'"
71 niro 2491 import_resource cfg_network "${serial}" domain "${MCORE_DEFAULT_DOMAIN}"
72     fi
73 niro 2487
74     nsslsay_queue_init
75     nsslsay_queue_add "nocolors"
76     nsslsay_queue_add "get hardware.detect driver graphic"
77     graphic_driver=$(control_client "${serial}" run-queue)
78     if [[ -n ${graphic_driver} ]]
79     then
80     decho "graphic_driver='${graphic_driver}'"
81     import_resource cfg_graphic "${serial}" module "${graphic_driver}"
82     else
83     decho "no graphic_driver found"
84     fi
85    
86     nsslsay_queue_init
87     nsslsay_queue_add "nocolors"
88 niro 2493 nsslsay_queue_add "get hardware.detect info monitor"
89 niro 2487 monitor_info=$(control_client "${serial}" run-queue)
90     monitor_resolution="${monitor_info##*;}"
91     if [[ -n ${monitor_resolution} ]]
92     then
93     decho "monitor_resolution='${monitor_resolution}'"
94     import_resource cfg_graphic "${serial}" resolution "${monitor_resolution}"
95     else
96     decho "no monitor_resolution found"
97     fi
98 niro 2497
99 niro 2500 keymap=$(mysqldo "select keymap from cfg_input where serial=${serial};")
100     if [[ -z ${keymap} ]] || [[ ${keymap} = NULL ]]
101     then
102     # set keymap to MCORE_DEFAULT_KEYMAP
103     decho "keymap='${MCORE_DEFAULT_KEYMAP}'"
104     import_resource cfg_input "${serial}" keymap "${MCORE_DEFAULT_KEYMAP}"
105     fi
106    
107     # now setup some empty database entries if the does not exist
108     for i in user root vnc
109     do
110 niro 2502 auth=$(mysqldo "select ${i} from client_auth where serial=${serial};")
111     if [[ -z ${auth} ]] || [[ ${auth} = NULL ]]
112 niro 2500 then
113     decho "set empty ${i} pass"
114     import_resource client_auth "${serial}" "${i}" ""
115     fi
116     done
117    
118 niro 2508 # create an empty screensaver entry
119     decho "set empty screensaver"
120     import_resource cfg_screensaver "${serial}" "screensaver" ""
121    
122 niro 2617 # create an vnc entry with the database defaults
123     decho "set vnc to database defaults"
124     import_resource cfg_vnc "${serial}" "service" ""
125    
126 niro 2497 # update the hwdetected flags
127 niro 2499 import_resource client_serials "${serial}" hwdetected 1
128 niro 2487 }
129 niro 2499
130     set_hardware_detect()
131     {
132     local serial="${CLASS_ARGV[0]}"
133    
134     local cmd
135     local netcard_driver
136     local networking
137     local hostname
138     local domain
139     local graphic_driver
140     local monitor_info
141     local monitor_resolution
142     local hwdetected
143    
144     if [[ -z ${serial} ]]
145     then
146     eecho "No serial given"
147     return 1
148     fi
149    
150     run_hardware_detect "${serial}"
151     }