Contents of /mcore-src/trunk/mcore-tools/src/include/register.global.class.in
Parent Directory | Revision Log
Revision 2447 -
(show annotations)
(download)
Thu Sep 3 13:47:44 2015 UTC (8 years, 8 months ago) by niro
File size: 1716 byte(s)
Thu Sep 3 13:47:44 2015 UTC (8 years, 8 months ago) by niro
File size: 1716 byte(s)
-use oneline nsslsay cmds
1 | # $Id$ |
2 | |
3 | validate_client() |
4 | { |
5 | local mac_address="$1" |
6 | local ip_address="$2" |
7 | local serial |
8 | local mtime |
9 | |
10 | if [[ -z ${mac_address} ]] |
11 | then |
12 | eecho "Error: No mac_address given" |
13 | return 1 |
14 | fi |
15 | |
16 | if [[ -z ${ip_address} ]] |
17 | then |
18 | eecho "Error: No ip_address given" |
19 | return 1 |
20 | fi |
21 | |
22 | decho "registering mac_address='${mac_address}'" |
23 | decho "registering ip_address='${ip_address}'" |
24 | |
25 | # first check if mac is registered |
26 | serial=$(mysqldo "select serial from client_serials where mac='${mac_address}'") |
27 | |
28 | if [[ -z ${serial} ]] |
29 | then |
30 | mtime=$(date +%s) |
31 | |
32 | # request a new serial; one command now (cause must be done in the same session) |
33 | serial=$(mysqldo "insert into client_serials (mtime, mac) values('${mtime}','${mac_address}'); select last_insert_id();") |
34 | fi |
35 | |
36 | if [[ -z ${serial} ]] |
37 | then |
38 | return 1 |
39 | else |
40 | decho "serial='${serial}'" |
41 | rvecho "${serial}" |
42 | |
43 | SSLSAY_IP="${ip_address}" |
44 | SSLSAY_PORT="6666" |
45 | nsslsay_fingerprint "register '${serial}'" |
46 | |
47 | return 0 |
48 | fi |
49 | } |
50 | |
51 | register_client() |
52 | { |
53 | local control_server_ip |
54 | local iface_ip |
55 | local iface |
56 | local mac_address |
57 | |
58 | control_server_ip=$(dns_to_ip ${MCORE_CONTROL_SERVER}) |
59 | iface_ip=$(iface_for_remote_addr ${control_server_ip}) |
60 | iface=$(iface_for_ip ${iface_ip}) |
61 | mac_address=$(mac_for_iface ${iface}) |
62 | |
63 | decho "MCORE_CONTROL_SERVER='${MCORE_CONTROL_SERVER}'" |
64 | decho "iface_ip='${iface_ip}'" |
65 | decho "iface='${iface}'" |
66 | decho "mac_address='${mac_address}'" |
67 | |
68 | decho "register '${mac_address}'" |
69 | nsslsay_fingerprint "register '${mac_address}' '${iface_ip}'" |
70 | } |
71 | |
72 | register_client_local() |
73 | { |
74 | local serial="$1" |
75 | |
76 | if [[ -z ${serial} ]] |
77 | then |
78 | eecho "No serial given" |
79 | return 1 |
80 | fi |
81 | |
82 | CONFIG="${MCORE_CONFIG_PATH}/serial" |
83 | clearconfig |
84 | addconfig "CLIENT_SERIAL=\"${serial}\"" |
85 | } |