Contents of /mcore-src/trunk/mcore-tools/src/include/register.global.class.in
Parent Directory | Revision Log
Revision 2433 -
(show annotations)
(download)
Thu Sep 3 12:29:41 2015 UTC (8 years, 9 months ago) by niro
File size: 1180 byte(s)
Thu Sep 3 12:29:41 2015 UTC (8 years, 9 months ago) by niro
File size: 1180 byte(s)
-fixed retvals and use nsslsay_fingerprint to send the registration
1 | |
2 | validate_client() |
3 | { |
4 | local mac_address="$1" |
5 | local serial |
6 | local mtime |
7 | |
8 | if [[ -z ${mac_address} ]] |
9 | then |
10 | eecho "Error: No mac_address given" |
11 | return 1 |
12 | fi |
13 | |
14 | # first check if mac is registered |
15 | serial=$(mysqldo "select serial from client_serials where mac='${mac_address}'") |
16 | |
17 | if [[ -z ${serial} ]] |
18 | then |
19 | mtime=$(date +%s) |
20 | |
21 | # request a new serial; one command now (cause must be done in the same session) |
22 | serial=$(mysqldo "insert into client_serials (mtime, mac) values('${mtime}','${mac_address}'); select last_insert_id();") |
23 | fi |
24 | |
25 | if [[ -z ${serial} ]] |
26 | then |
27 | return 1 |
28 | else |
29 | echo "serial='${serial}'" |
30 | return 0 |
31 | fi |
32 | } |
33 | |
34 | register_client() |
35 | { |
36 | local control_server_ip |
37 | local iface_ip |
38 | local iface |
39 | local mac_address |
40 | |
41 | control_server_ip=$(dns_to_ip ${MCORE_CONTROL_SERVER}) |
42 | iface_ip=$(iface_for_remote_addr ${control_server_ip}) |
43 | iface=$(iface_for_ip ${iface_ip}) |
44 | mac_address=$(mac_for_iface ${iface}) |
45 | |
46 | echo "DEBUG: MCORE_CONTROL_SERVER='${MCORE_CONTROL_SERVER}'" |
47 | echo "DEBUG: iface_ip='${iface_ip}'" |
48 | echo "DEBUG: iface='${iface}'" |
49 | echo "DEBUG: mac_address='${mac_address}'" |
50 | |
51 | echo "register '${mac_address}'" |
52 | nsslsay_fingerprint "register '${mac_address}'" |
53 | } |