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