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 2502 - (hide annotations) (download)
Fri Sep 11 08:25:37 2015 UTC (8 years, 8 months ago) by niro
File size: 3690 byte(s)
-respect db NULL setting
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     nsslsay_queue_add "get hardware.detect driver netcard"
43     netcard_driver=$(control_client "${serial}" run-queue)
44     if [[ -n ${netcard_driver} ]]
45     then
46 niro 2495 decho "netcard_driver='${netcard_driver}'"
47     import_resource cfg_network "${serial}" module "${netcard_driver}"
48 niro 2487 else
49     decho "no netcard_driver found"
50     fi
51 niro 2496 networking=$(mysqldo "select networking from cfg_network where serial=${serial};")
52     if [[ -z ${networking} ]] || [[ ${networking} = NULL ]]
53 niro 2488 then
54     # set network to dhcp
55 niro 2493 decho "networking='dhcp'"
56 niro 2488 import_resource cfg_network "${serial}" networking "dhcp"
57     fi
58 niro 2496 hostname=$(mysqldo "select hostname from cfg_network where serial=${serial};")
59     if [[ -z ${hostname} ]] || [[ ${hostname} = NULL ]]
60 niro 2488 then
61     # set hostname to MCORE_DEFAULT_HOSTNAME
62 niro 2493 decho "hostname='${MCORE_DEFAULT_HOSTNAME}'"
63 niro 2488 import_resource cfg_network "${serial}" hostname "${MCORE_DEFAULT_HOSTNAME}"
64     fi
65 niro 2496 domain=$(mysqldo "select domain from cfg_network where serial=${serial};")
66     if [[ -z ${domain} ]] || [[ ${domain} = NULL ]]
67 niro 2491 then
68     # set domain to MCORE_DEFAULT_DOMAIN
69 niro 2493 decho "hostname='${MCORE_DEFAULT_DOMAIN}'"
70 niro 2491 import_resource cfg_network "${serial}" domain "${MCORE_DEFAULT_DOMAIN}"
71     fi
72 niro 2487
73     nsslsay_queue_init
74     nsslsay_queue_add "nocolors"
75     nsslsay_queue_add "get hardware.detect driver graphic"
76     graphic_driver=$(control_client "${serial}" run-queue)
77     if [[ -n ${graphic_driver} ]]
78     then
79     decho "graphic_driver='${graphic_driver}'"
80     import_resource cfg_graphic "${serial}" module "${graphic_driver}"
81     else
82     decho "no graphic_driver found"
83     fi
84    
85     nsslsay_queue_init
86     nsslsay_queue_add "nocolors"
87 niro 2493 nsslsay_queue_add "get hardware.detect info monitor"
88 niro 2487 monitor_info=$(control_client "${serial}" run-queue)
89     monitor_resolution="${monitor_info##*;}"
90     if [[ -n ${monitor_resolution} ]]
91     then
92     decho "monitor_resolution='${monitor_resolution}'"
93     import_resource cfg_graphic "${serial}" resolution "${monitor_resolution}"
94     else
95     decho "no monitor_resolution found"
96     fi
97 niro 2497
98 niro 2500 keymap=$(mysqldo "select keymap from cfg_input where serial=${serial};")
99     if [[ -z ${keymap} ]] || [[ ${keymap} = NULL ]]
100     then
101     # set keymap to MCORE_DEFAULT_KEYMAP
102     decho "keymap='${MCORE_DEFAULT_KEYMAP}'"
103     import_resource cfg_input "${serial}" keymap "${MCORE_DEFAULT_KEYMAP}"
104     fi
105    
106     # now setup some empty database entries if the does not exist
107     for i in user root vnc
108     do
109 niro 2502 auth=$(mysqldo "select ${i} from client_auth where serial=${serial};")
110     if [[ -z ${auth} ]] || [[ ${auth} = NULL ]]
111 niro 2500 then
112     decho "set empty ${i} pass"
113     import_resource client_auth "${serial}" "${i}" ""
114     fi
115     done
116    
117 niro 2497 # update the hwdetected flags
118 niro 2499 import_resource client_serials "${serial}" hwdetected 1
119 niro 2487 }
120 niro 2499
121     set_hardware_detect()
122     {
123     local serial="${CLASS_ARGV[0]}"
124    
125     local cmd
126     local netcard_driver
127     local networking
128     local hostname
129     local domain
130     local graphic_driver
131     local monitor_info
132     local monitor_resolution
133     local hwdetected
134    
135     if [[ -z ${serial} ]]
136     then
137     eecho "No serial given"
138     return 1
139     fi
140    
141     run_hardware_detect "${serial}"
142     }