Magellan Linux

Contents of /mcore-src/trunk/mcore-tools/src/include/register.global.class.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2431 - (show annotations) (download)
Thu Sep 3 12:15:13 2015 UTC (8 years, 8 months ago) by niro
File size: 1069 byte(s)
-resolv mtime and fix broken variables
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 echo "serial='${serial}'"
26 }
27
28 register_client()
29 {
30 local control_server_ip
31 local iface_ip
32 local iface
33 local mac_address
34
35 control_server_ip=$(dns_to_ip ${MCORE_CONTROL_SERVER})
36 iface_ip=$(iface_for_remote_addr ${control_server_ip})
37 iface=$(iface_for_ip ${iface_ip})
38 mac_address=$(mac_for_iface ${iface})
39
40 echo "DEBUG: MCORE_CONTROL_SERVER='${MCORE_CONTROL_SERVER}'"
41 echo "DEBUG: iface_ip='${iface_ip}'"
42 echo "DEBUG: iface='${iface}'"
43 echo "DEBUG: mac_address='${mac_address}'"
44
45 echo "register '${mac_address}'"
46 }