1 |
|
# $Id$ |
2 |
|
|
3 |
validate_client() |
validate_client() |
4 |
{ |
{ |
5 |
local mac_address="$1" |
local mac_address="$1" |
6 |
local serial |
local serial |
7 |
|
local mtime |
8 |
|
|
9 |
if [[ -z ${mac_address} ]] |
if [[ -z ${mac_address} ]] |
10 |
then |
then |
12 |
return 1 |
return 1 |
13 |
fi |
fi |
14 |
|
|
15 |
|
decho "registering mac_address='${mac_address}'" |
16 |
|
|
17 |
# first check if mac is registered |
# first check if mac is registered |
18 |
serial=$(mysqldo "select serial from client_serials where mac='${mac_address}'") |
serial=$(mysqldo "select serial from client_serials where mac='${mac_address}'") |
19 |
|
|
20 |
if [[ -z ${serial} ]] |
if [[ -z ${serial} ]] |
21 |
then |
then |
22 |
|
mtime=$(date +%s) |
23 |
|
|
24 |
# request a new serial; one command now (cause must be done in the same session) |
# request a new serial; one command now (cause must be done in the same session) |
25 |
serial=$(mysqldo "insert into client_serials (mtime, mac) values('${CUR_MTIME}','${CUR_MAC}'); select last_insert_id();") |
serial=$(mysqldo "insert into client_serials (mtime, mac) values('${mtime}','${mac_address}'); select last_insert_id();") |
26 |
fi |
fi |
27 |
|
|
28 |
echo "serial='${serial}'" |
if [[ -z ${serial} ]] |
29 |
|
then |
30 |
|
return 1 |
31 |
|
else |
32 |
|
echo "serial='${serial}'" |
33 |
|
return 0 |
34 |
|
fi |
35 |
} |
} |
36 |
|
|
37 |
register_client() |
register_client() |
46 |
iface=$(iface_for_ip ${iface_ip}) |
iface=$(iface_for_ip ${iface_ip}) |
47 |
mac_address=$(mac_for_iface ${iface}) |
mac_address=$(mac_for_iface ${iface}) |
48 |
|
|
49 |
echo "DEBUG: MCORE_CONTROL_SERVER='${MCORE_CONTROL_SERVER}'" |
decho "MCORE_CONTROL_SERVER='${MCORE_CONTROL_SERVER}'" |
50 |
echo "DEBUG: iface_ip='${iface_ip}'" |
decho "iface_ip='${iface_ip}'" |
51 |
echo "DEBUG: iface='${iface}'" |
decho "iface='${iface}'" |
52 |
echo "DEBUG: mac_address='${mac_address}'" |
decho "mac_address='${mac_address}'" |
53 |
|
|
54 |
echo "register '${mac_address}'" |
decho "register '${mac_address}'" |
55 |
|
nsslsay_fingerprint "register '${mac_address}'" |
56 |
} |
} |