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