1 |
|
# $Id$ |
2 |
|
|
3 |
validate_client() |
validate_client() |
4 |
{ |
{ |
5 |
local mac_address="$1" |
local mac_address="$1" |
6 |
|
local ip_address="$2" |
7 |
local serial |
local serial |
8 |
local mtime |
local mtime |
9 |
|
local serial_id |
10 |
|
|
11 |
if [[ -z ${mac_address} ]] |
if [[ -z ${mac_address} ]] |
12 |
then |
then |
14 |
return 1 |
return 1 |
15 |
fi |
fi |
16 |
|
|
17 |
|
if [[ -z ${ip_address} ]] |
18 |
|
then |
19 |
|
eecho "Error: No ip_address given" |
20 |
|
return 1 |
21 |
|
fi |
22 |
|
|
23 |
|
decho "registering mac_address='${mac_address}'" |
24 |
|
decho "registering ip_address='${ip_address}'" |
25 |
|
|
26 |
# first check if mac is registered |
# first check if mac is registered |
27 |
serial=$(mysqldo "select serial from client_serials where mac='${mac_address}'") |
serial=$(mysqldo "select serial from client_serials where mac='${mac_address}'") |
28 |
|
|
38 |
then |
then |
39 |
return 1 |
return 1 |
40 |
else |
else |
41 |
echo "serial='${serial}'" |
decho "serial='${serial}'" |
42 |
|
rvecho "${serial}" |
43 |
|
|
44 |
|
SSLSAY_IP="${ip_address}" |
45 |
|
SSLSAY_PORT="6666" |
46 |
|
nsslsay_fingerprint "register '${serial}'" |
47 |
|
|
48 |
|
# register the client as online |
49 |
|
serial_id=$(mysqldo "select serial from state_connected where serial=${serial};") |
50 |
|
if [[ -n ${serial_id} ]] |
51 |
|
then |
52 |
|
mysqldo "update state_connected set ip='${ip_address}', mac='${mac_address}', mtime='${mtime}' where serial=${serial};" |
53 |
|
else |
54 |
|
mysqldo "insert into state_connected(serial,ip,mac,mtime) values('${serial}','${ip_address}','${mac_address}','${mtime}');" |
55 |
|
fi |
56 |
|
|
57 |
return 0 |
return 0 |
58 |
fi |
fi |
59 |
} |
} |
70 |
iface=$(iface_for_ip ${iface_ip}) |
iface=$(iface_for_ip ${iface_ip}) |
71 |
mac_address=$(mac_for_iface ${iface}) |
mac_address=$(mac_for_iface ${iface}) |
72 |
|
|
73 |
echo "DEBUG: MCORE_CONTROL_SERVER='${MCORE_CONTROL_SERVER}'" |
decho "MCORE_CONTROL_SERVER='${MCORE_CONTROL_SERVER}'" |
74 |
echo "DEBUG: iface_ip='${iface_ip}'" |
decho "iface_ip='${iface_ip}'" |
75 |
echo "DEBUG: iface='${iface}'" |
decho "iface='${iface}'" |
76 |
echo "DEBUG: mac_address='${mac_address}'" |
decho "mac_address='${mac_address}'" |
77 |
|
|
78 |
|
decho "register '${mac_address}'" |
79 |
|
nsslsay_fingerprint "register '${mac_address}' '${iface_ip}'" |
80 |
|
} |
81 |
|
|
82 |
|
register_client_local() |
83 |
|
{ |
84 |
|
local serial="$1" |
85 |
|
|
86 |
|
if [[ -z ${serial} ]] |
87 |
|
then |
88 |
|
eecho "No serial given" |
89 |
|
return 1 |
90 |
|
fi |
91 |
|
|
92 |
echo "register '${mac_address}'" |
install -d "${MCORE_CONFIG_PATH}" |
93 |
nsslsay_fingerprint "register '${mac_address}'" |
CONFIG="${MCORE_CONFIG_PATH}/serial" |
94 |
|
clearconfig |
95 |
|
addconfig "CLIENT_SERIAL=\"${serial}\"" |
96 |
} |
} |