Contents of /mcore-src/trunk/mcore-tools/src/modules/hwinfo/hardware.control.class.in
Parent Directory | Revision Log
Revision 2499 -
(show annotations)
(download)
Fri Sep 11 07:36:40 2015 UTC (9 years ago) by niro
File size: 3053 byte(s)
Fri Sep 11 07:36:40 2015 UTC (9 years ago) by niro
File size: 3053 byte(s)
-renamed set_hardware_detect() to run_hardware_detect() and provide a new set class to run the hardware detection to fix run_clasS() evaluation issues
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 hwdetected |
20 | |
21 | if [[ -z ${serial} ]] |
22 | then |
23 | decho "No serial given" |
24 | return 1 |
25 | fi |
26 | |
27 | # first check if hardware detect was already done |
28 | hwdetected=$(mysqldo "select hwdetected from client_serials where serial=${serial};") |
29 | if [[ ${hwdetected} = 1 ]] |
30 | then |
31 | decho "hardware detection already run, aborting" |
32 | return 0 |
33 | else |
34 | decho "running hardware detection" |
35 | fi |
36 | |
37 | nsslsay_queue_init |
38 | nsslsay_queue_add "nocolors" |
39 | nsslsay_queue_add "get hardware.detect driver netcard" |
40 | netcard_driver=$(control_client "${serial}" run-queue) |
41 | if [[ -n ${netcard_driver} ]] |
42 | then |
43 | decho "netcard_driver='${netcard_driver}'" |
44 | import_resource cfg_network "${serial}" module "${netcard_driver}" |
45 | else |
46 | decho "no netcard_driver found" |
47 | fi |
48 | networking=$(mysqldo "select networking from cfg_network where serial=${serial};") |
49 | if [[ -z ${networking} ]] || [[ ${networking} = NULL ]] |
50 | then |
51 | # set network to dhcp |
52 | decho "networking='dhcp'" |
53 | import_resource cfg_network "${serial}" networking "dhcp" |
54 | fi |
55 | hostname=$(mysqldo "select hostname from cfg_network where serial=${serial};") |
56 | if [[ -z ${hostname} ]] || [[ ${hostname} = NULL ]] |
57 | then |
58 | # set hostname to MCORE_DEFAULT_HOSTNAME |
59 | decho "hostname='${MCORE_DEFAULT_HOSTNAME}'" |
60 | import_resource cfg_network "${serial}" hostname "${MCORE_DEFAULT_HOSTNAME}" |
61 | fi |
62 | domain=$(mysqldo "select domain from cfg_network where serial=${serial};") |
63 | if [[ -z ${domain} ]] || [[ ${domain} = NULL ]] |
64 | then |
65 | # set domain to MCORE_DEFAULT_DOMAIN |
66 | decho "hostname='${MCORE_DEFAULT_DOMAIN}'" |
67 | import_resource cfg_network "${serial}" domain "${MCORE_DEFAULT_DOMAIN}" |
68 | fi |
69 | |
70 | nsslsay_queue_init |
71 | nsslsay_queue_add "nocolors" |
72 | nsslsay_queue_add "get hardware.detect driver graphic" |
73 | graphic_driver=$(control_client "${serial}" run-queue) |
74 | if [[ -n ${graphic_driver} ]] |
75 | then |
76 | decho "graphic_driver='${graphic_driver}'" |
77 | import_resource cfg_graphic "${serial}" module "${graphic_driver}" |
78 | else |
79 | decho "no graphic_driver found" |
80 | fi |
81 | |
82 | nsslsay_queue_init |
83 | nsslsay_queue_add "nocolors" |
84 | nsslsay_queue_add "get hardware.detect info monitor" |
85 | monitor_info=$(control_client "${serial}" run-queue) |
86 | monitor_resolution="${monitor_info##*;}" |
87 | if [[ -n ${monitor_resolution} ]] |
88 | then |
89 | decho "monitor_resolution='${monitor_resolution}'" |
90 | import_resource cfg_graphic "${serial}" resolution "${monitor_resolution}" |
91 | else |
92 | decho "no monitor_resolution found" |
93 | fi |
94 | |
95 | # update the hwdetected flags |
96 | import_resource client_serials "${serial}" hwdetected 1 |
97 | } |
98 | |
99 | set_hardware_detect() |
100 | { |
101 | local serial="${CLASS_ARGV[0]}" |
102 | |
103 | local cmd |
104 | local netcard_driver |
105 | local networking |
106 | local hostname |
107 | local domain |
108 | local graphic_driver |
109 | local monitor_info |
110 | local monitor_resolution |
111 | local hwdetected |
112 | |
113 | if [[ -z ${serial} ]] |
114 | then |
115 | eecho "No serial given" |
116 | return 1 |
117 | fi |
118 | |
119 | run_hardware_detect "${serial}" |
120 | } |