1 |
# $Id$ |
# $Id$ |
2 |
|
|
3 |
|
provide hardware |
4 |
require hwdetection |
require hwdetection |
5 |
require mysql |
require mysql |
6 |
|
|
7 |
set_hardware_detect() |
run_hardware_detect() |
8 |
{ |
{ |
9 |
local serial="${CLASS_ARGV[0]}" |
local serial="$1" |
10 |
|
|
11 |
local cmd |
local cmd |
12 |
local netcard_driver |
local netcard_driver |
13 |
|
local networking |
14 |
|
local hostname |
15 |
|
local domain |
16 |
local graphic_driver |
local graphic_driver |
17 |
local monitor_info |
local monitor_info |
18 |
local monitor_resolution |
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 |
nsslsay_queue_init |
41 |
nsslsay_queue_add "nocolors" |
nsslsay_queue_add "nocolors" |
42 |
nsslsay_queue_add "get hardware.detect driver netcard" |
#nsslsay_queue_add "get hardware.detect driver netcard" |
43 |
|
nsslsay_queue_add "get hardware.detect driver connected-iface" |
44 |
netcard_driver=$(control_client "${serial}" run-queue) |
netcard_driver=$(control_client "${serial}" run-queue) |
45 |
if [[ -n ${netcard_driver} ]] |
if [[ -n ${netcard_driver} ]] |
46 |
then |
then |
49 |
else |
else |
50 |
decho "no netcard_driver found" |
decho "no netcard_driver found" |
51 |
fi |
fi |
52 |
if [[ -z $(mysqldo "select networking from cfg_network where serial=${serial};") ]] |
networking=$(mysqldo "select networking from cfg_network where serial=${serial};") |
53 |
|
if [[ -z ${networking} ]] || [[ ${networking} = NULL ]] |
54 |
then |
then |
55 |
# set network to dhcp |
# set network to dhcp |
56 |
decho "networking='dhcp'" |
decho "networking='dhcp'" |
57 |
import_resource cfg_network "${serial}" networking "dhcp" |
import_resource cfg_network "${serial}" networking "dhcp" |
58 |
fi |
fi |
59 |
if [[ -z $(mysqldo "select hostname from cfg_network where serial=${serial};") ]] |
hostname=$(mysqldo "select hostname from cfg_network where serial=${serial};") |
60 |
|
if [[ -z ${hostname} ]] || [[ ${hostname} = NULL ]] |
61 |
then |
then |
62 |
# set hostname to MCORE_DEFAULT_HOSTNAME |
# set hostname to MCORE_DEFAULT_HOSTNAME |
63 |
decho "hostname='${MCORE_DEFAULT_HOSTNAME}'" |
decho "hostname='${MCORE_DEFAULT_HOSTNAME}'" |
64 |
import_resource cfg_network "${serial}" hostname "${MCORE_DEFAULT_HOSTNAME}" |
import_resource cfg_network "${serial}" hostname "${MCORE_DEFAULT_HOSTNAME}" |
65 |
fi |
fi |
66 |
if [[ -z $(mysqldo "select domain from cfg_network where serial=${serial};") ]] |
domain=$(mysqldo "select domain from cfg_network where serial=${serial};") |
67 |
|
if [[ -z ${domain} ]] || [[ ${domain} = NULL ]] |
68 |
then |
then |
69 |
# set domain to MCORE_DEFAULT_DOMAIN |
# set domain to MCORE_DEFAULT_DOMAIN |
70 |
decho "hostname='${MCORE_DEFAULT_DOMAIN}'" |
decho "hostname='${MCORE_DEFAULT_DOMAIN}'" |
95 |
else |
else |
96 |
decho "no monitor_resolution found" |
decho "no monitor_resolution found" |
97 |
fi |
fi |
98 |
|
|
99 |
|
keymap=$(mysqldo "select keymap from cfg_input where serial=${serial};") |
100 |
|
if [[ -z ${keymap} ]] || [[ ${keymap} = NULL ]] |
101 |
|
then |
102 |
|
# set keymap to MCORE_DEFAULT_KEYMAP |
103 |
|
decho "keymap='${MCORE_DEFAULT_KEYMAP}'" |
104 |
|
import_resource cfg_input "${serial}" keymap "${MCORE_DEFAULT_KEYMAP}" |
105 |
|
fi |
106 |
|
|
107 |
|
# now setup some empty database entries if the does not exist |
108 |
|
for i in user root vnc |
109 |
|
do |
110 |
|
auth=$(mysqldo "select ${i} from client_auth where serial=${serial};") |
111 |
|
if [[ -z ${auth} ]] || [[ ${auth} = NULL ]] |
112 |
|
then |
113 |
|
decho "set empty ${i} pass" |
114 |
|
import_resource client_auth "${serial}" "${i}" "" |
115 |
|
fi |
116 |
|
done |
117 |
|
|
118 |
|
# create an empty screensaver entry |
119 |
|
decho "set empty screensaver" |
120 |
|
import_resource cfg_screensaver "${serial}" "screensaver" "" |
121 |
|
|
122 |
|
# update the hwdetected flags |
123 |
|
import_resource client_serials "${serial}" hwdetected 1 |
124 |
|
} |
125 |
|
|
126 |
|
set_hardware_detect() |
127 |
|
{ |
128 |
|
local serial="${CLASS_ARGV[0]}" |
129 |
|
|
130 |
|
local cmd |
131 |
|
local netcard_driver |
132 |
|
local networking |
133 |
|
local hostname |
134 |
|
local domain |
135 |
|
local graphic_driver |
136 |
|
local monitor_info |
137 |
|
local monitor_resolution |
138 |
|
local hwdetected |
139 |
|
|
140 |
|
if [[ -z ${serial} ]] |
141 |
|
then |
142 |
|
eecho "No serial given" |
143 |
|
return 1 |
144 |
|
fi |
145 |
|
|
146 |
|
run_hardware_detect "${serial}" |
147 |
} |
} |