Contents of /mcore-src/trunk/mcore-tools/src/modules/hwinfo/hardware.control.class.in
Parent Directory | Revision Log
Revision 2502 -
(show annotations)
(download)
Fri Sep 11 08:25:37 2015 UTC (9 years ago) by niro
File size: 3690 byte(s)
Fri Sep 11 08:25:37 2015 UTC (9 years ago) by niro
File size: 3690 byte(s)
-respect db NULL setting
1 | # $Id$ |
2 | |
3 | provide hardware |
4 | require hwdetection |
5 | require mysql |
6 | |
7 | run_hardware_detect() |
8 | { |
9 | local serial="$1" |
10 | |
11 | local cmd |
12 | local netcard_driver |
13 | local networking |
14 | local hostname |
15 | local domain |
16 | local graphic_driver |
17 | local monitor_info |
18 | local monitor_resolution |
19 | local keymap |
20 | local hwdetected |
21 | local auth |
22 | local i |
23 | |
24 | if [[ -z ${serial} ]] |
25 | then |
26 | decho "No serial given" |
27 | return 1 |
28 | fi |
29 | |
30 | # 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 | else |
37 | decho "running hardware detection" |
38 | fi |
39 | |
40 | 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 | decho "netcard_driver='${netcard_driver}'" |
47 | import_resource cfg_network "${serial}" module "${netcard_driver}" |
48 | else |
49 | decho "no netcard_driver found" |
50 | fi |
51 | networking=$(mysqldo "select networking from cfg_network where serial=${serial};") |
52 | if [[ -z ${networking} ]] || [[ ${networking} = NULL ]] |
53 | then |
54 | # set network to dhcp |
55 | decho "networking='dhcp'" |
56 | import_resource cfg_network "${serial}" networking "dhcp" |
57 | fi |
58 | hostname=$(mysqldo "select hostname from cfg_network where serial=${serial};") |
59 | if [[ -z ${hostname} ]] || [[ ${hostname} = NULL ]] |
60 | then |
61 | # set hostname to MCORE_DEFAULT_HOSTNAME |
62 | decho "hostname='${MCORE_DEFAULT_HOSTNAME}'" |
63 | import_resource cfg_network "${serial}" hostname "${MCORE_DEFAULT_HOSTNAME}" |
64 | fi |
65 | domain=$(mysqldo "select domain from cfg_network where serial=${serial};") |
66 | if [[ -z ${domain} ]] || [[ ${domain} = NULL ]] |
67 | then |
68 | # set domain to MCORE_DEFAULT_DOMAIN |
69 | decho "hostname='${MCORE_DEFAULT_DOMAIN}'" |
70 | import_resource cfg_network "${serial}" domain "${MCORE_DEFAULT_DOMAIN}" |
71 | fi |
72 | |
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 | nsslsay_queue_add "get hardware.detect info monitor" |
88 | 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 | |
98 | 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 | auth=$(mysqldo "select ${i} from client_auth where serial=${serial};") |
110 | if [[ -z ${auth} ]] || [[ ${auth} = NULL ]] |
111 | then |
112 | decho "set empty ${i} pass" |
113 | import_resource client_auth "${serial}" "${i}" "" |
114 | fi |
115 | done |
116 | |
117 | # update the hwdetected flags |
118 | import_resource client_serials "${serial}" hwdetected 1 |
119 | } |
120 | |
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 | } |