Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2430 - (hide annotations) (download)
Thu Sep 3 12:10:16 2015 UTC (8 years, 8 months ago) by niro
File size: 1034 byte(s)
-added initial client registration class
1 niro 2430
2     validate_client()
3     {
4     local mac_address="$1"
5     local serial
6    
7     if [[ -z ${mac_address} ]]
8     then
9     eecho "Error: No mac_address given"
10     return 1
11     fi
12    
13     # first check if mac is registered
14     serial=$(mysqldo "select serial from client_serials where mac='${mac_address}'")
15    
16     if [[ -z ${serial} ]]
17     then
18     # request a new serial; one command now (cause must be done in the same session)
19     serial=$(mysqldo "insert into client_serials (mtime, mac) values('${CUR_MTIME}','${CUR_MAC}'); select last_insert_id();")
20     fi
21    
22     echo "serial='${serial}'"
23     }
24    
25     register_client()
26     {
27     local control_server_ip
28     local iface_ip
29     local iface
30     local mac_address
31    
32     control_server_ip=$(dns_to_ip ${MCORE_CONTROL_SERVER})
33     iface_ip=$(iface_for_remote_addr ${control_server_ip})
34     iface=$(iface_for_ip ${iface_ip})
35     mac_address=$(mac_for_iface ${iface})
36    
37     echo "DEBUG: MCORE_CONTROL_SERVER='${MCORE_CONTROL_SERVER}'"
38     echo "DEBUG: iface_ip='${iface_ip}'"
39     echo "DEBUG: iface='${iface}'"
40     echo "DEBUG: mac_address='${mac_address}'"
41    
42     echo "register '${mac_address}'"
43     }