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