Magellan Linux

Contents of /mcore-src/trunk/mcore-tools/src/modules/hwinfo/hardware.control.class.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2497 - (show annotations) (download)
Thu Sep 10 14:08:40 2015 UTC (8 years, 7 months ago) by niro
File size: 2619 byte(s)
-run hardware detection on register_client if hardware was provided and not already run
1 # $Id$
2
3 provide hardware
4 require hwdetection
5 require mysql
6
7 set_hardware_detect()
8 {
9 local serial="${CLASS_ARGV[0]}"
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 # first check if hardware detect was already done
22 hwdetected=$(mysqldo "select hwdetected from client_serials where serial=${serial};")
23 if [[ ${hwdetected} = 1 ]]
24 then
25 decho "hardware detection already run, aborting"
26 return 0
27 fi
28
29 nsslsay_queue_init
30 nsslsay_queue_add "nocolors"
31 nsslsay_queue_add "get hardware.detect driver netcard"
32 netcard_driver=$(control_client "${serial}" run-queue)
33 if [[ -n ${netcard_driver} ]]
34 then
35 decho "netcard_driver='${netcard_driver}'"
36 import_resource cfg_network "${serial}" module "${netcard_driver}"
37 else
38 decho "no netcard_driver found"
39 fi
40 networking=$(mysqldo "select networking from cfg_network where serial=${serial};")
41 if [[ -z ${networking} ]] || [[ ${networking} = NULL ]]
42 then
43 # set network to dhcp
44 decho "networking='dhcp'"
45 import_resource cfg_network "${serial}" networking "dhcp"
46 fi
47 hostname=$(mysqldo "select hostname from cfg_network where serial=${serial};")
48 if [[ -z ${hostname} ]] || [[ ${hostname} = NULL ]]
49 then
50 # set hostname to MCORE_DEFAULT_HOSTNAME
51 decho "hostname='${MCORE_DEFAULT_HOSTNAME}'"
52 import_resource cfg_network "${serial}" hostname "${MCORE_DEFAULT_HOSTNAME}"
53 fi
54 domain=$(mysqldo "select domain from cfg_network where serial=${serial};")
55 if [[ -z ${domain} ]] || [[ ${domain} = NULL ]]
56 then
57 # set domain to MCORE_DEFAULT_DOMAIN
58 decho "hostname='${MCORE_DEFAULT_DOMAIN}'"
59 import_resource cfg_network "${serial}" domain "${MCORE_DEFAULT_DOMAIN}"
60 fi
61
62 nsslsay_queue_init
63 nsslsay_queue_add "nocolors"
64 nsslsay_queue_add "get hardware.detect driver graphic"
65 graphic_driver=$(control_client "${serial}" run-queue)
66 if [[ -n ${graphic_driver} ]]
67 then
68 decho "graphic_driver='${graphic_driver}'"
69 import_resource cfg_graphic "${serial}" module "${graphic_driver}"
70 else
71 decho "no graphic_driver found"
72 fi
73
74 nsslsay_queue_init
75 nsslsay_queue_add "nocolors"
76 nsslsay_queue_add "get hardware.detect info monitor"
77 monitor_info=$(control_client "${serial}" run-queue)
78 monitor_resolution="${monitor_info##*;}"
79 if [[ -n ${monitor_resolution} ]]
80 then
81 decho "monitor_resolution='${monitor_resolution}'"
82 import_resource cfg_graphic "${serial}" resolution "${monitor_resolution}"
83 else
84 decho "no monitor_resolution found"
85 fi
86
87 # update the hwdetected flags
88 import_resource client_serial "${serial}" hwdetected 1
89 }