Contents of /mcore-src/trunk/mcore-tools/src/modules/hwinfo/hardware.control.class.in
Parent Directory | Revision Log
Revision 2500 -
(show annotations)
(download)
Fri Sep 11 08:20:34 2015 UTC (8 years, 8 months ago) by niro
File size: 3639 byte(s)
Fri Sep 11 08:20:34 2015 UTC (8 years, 8 months ago) by niro
File size: 3639 byte(s)
-import keymap and user passwords
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 i |
22 | |
23 | if [[ -z ${serial} ]] |
24 | then |
25 | decho "No serial given" |
26 | return 1 |
27 | fi |
28 | |
29 | # 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 | else |
36 | decho "running hardware detection" |
37 | fi |
38 | |
39 | 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 | decho "netcard_driver='${netcard_driver}'" |
46 | import_resource cfg_network "${serial}" module "${netcard_driver}" |
47 | else |
48 | decho "no netcard_driver found" |
49 | fi |
50 | networking=$(mysqldo "select networking from cfg_network where serial=${serial};") |
51 | if [[ -z ${networking} ]] || [[ ${networking} = NULL ]] |
52 | then |
53 | # set network to dhcp |
54 | decho "networking='dhcp'" |
55 | import_resource cfg_network "${serial}" networking "dhcp" |
56 | fi |
57 | hostname=$(mysqldo "select hostname from cfg_network where serial=${serial};") |
58 | if [[ -z ${hostname} ]] || [[ ${hostname} = NULL ]] |
59 | then |
60 | # set hostname to MCORE_DEFAULT_HOSTNAME |
61 | decho "hostname='${MCORE_DEFAULT_HOSTNAME}'" |
62 | import_resource cfg_network "${serial}" hostname "${MCORE_DEFAULT_HOSTNAME}" |
63 | fi |
64 | domain=$(mysqldo "select domain from cfg_network where serial=${serial};") |
65 | if [[ -z ${domain} ]] || [[ ${domain} = NULL ]] |
66 | then |
67 | # set domain to MCORE_DEFAULT_DOMAIN |
68 | decho "hostname='${MCORE_DEFAULT_DOMAIN}'" |
69 | import_resource cfg_network "${serial}" domain "${MCORE_DEFAULT_DOMAIN}" |
70 | fi |
71 | |
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 | nsslsay_queue_add "get hardware.detect info monitor" |
87 | 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 | |
97 | 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 | # update the hwdetected flags |
116 | import_resource client_serials "${serial}" hwdetected 1 |
117 | } |
118 | |
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 | } |