Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2430 by niro, Thu Sep 3 12:10:16 2015 UTC revision 2447 by niro, Thu Sep 3 13:47:44 2015 UTC
# Line 1  Line 1 
1    # $Id$
2    
3  validate_client()  validate_client()
4  {  {
5   local mac_address="$1"   local mac_address="$1"
6     local ip_address="$2"
7   local serial   local serial
8     local mtime
9    
10   if [[ -z ${mac_address} ]]   if [[ -z ${mac_address} ]]
11   then   then
# Line 10  validate_client() Line 13  validate_client()
13   return 1   return 1
14   fi   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   # first check if mac is registered
26   serial=$(mysqldo "select serial from client_serials where mac='${mac_address}'")   serial=$(mysqldo "select serial from client_serials where mac='${mac_address}'")
27    
28   if [[ -z ${serial} ]]   if [[ -z ${serial} ]]
29   then   then
30     mtime=$(date +%s)
31    
32   # request a new serial; one command now (cause must be done in the same session)   # 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('${CUR_MTIME}','${CUR_MAC}'); select last_insert_id();")   serial=$(mysqldo "insert into client_serials (mtime, mac) values('${mtime}','${mac_address}'); select last_insert_id();")
34   fi   fi
35    
36   echo "serial='${serial}'"   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()  register_client()
# Line 34  register_client() Line 60  register_client()
60   iface=$(iface_for_ip ${iface_ip})   iface=$(iface_for_ip ${iface_ip})
61   mac_address=$(mac_for_iface ${iface})   mac_address=$(mac_for_iface ${iface})
62    
63   echo "DEBUG: MCORE_CONTROL_SERVER='${MCORE_CONTROL_SERVER}'"   decho "MCORE_CONTROL_SERVER='${MCORE_CONTROL_SERVER}'"
64   echo "DEBUG: iface_ip='${iface_ip}'"   decho "iface_ip='${iface_ip}'"
65   echo "DEBUG: iface='${iface}'"   decho "iface='${iface}'"
66   echo "DEBUG: mac_address='${mac_address}'"   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   echo "register '${mac_address}'"   CONFIG="${MCORE_CONFIG_PATH}/serial"
83     clearconfig
84     addconfig "CLIENT_SERIAL=\"${serial}\""
85  }  }

Legend:
Removed from v.2430  
changed lines
  Added in v.2447