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 2447 by niro, Thu Sep 3 13:47:44 2015 UTC revision 2476 by niro, Thu Sep 10 08:04:33 2015 UTC
# Line 6  validate_client() Line 6  validate_client()
6   local ip_address="$2"   local ip_address="$2"
7   local serial   local serial
8   local mtime   local mtime
9     local serial_id
10    
11   if [[ -z ${mac_address} ]]   if [[ -z ${mac_address} ]]
12   then   then
# Line 25  validate_client() Line 26  validate_client()
26   # first check if mac is registered   # first check if mac is registered
27   serial=$(mysqldo "select serial from client_serials where mac='${mac_address}'")   serial=$(mysqldo "select serial from client_serials where mac='${mac_address}'")
28    
29     # current mtime
30     mtime=$(date +%s)
31    
32   if [[ -z ${serial} ]]   if [[ -z ${serial} ]]
33   then   then
  mtime=$(date +%s)  
   
34   # 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)
35   serial=$(mysqldo "insert into client_serials (mtime, mac) values('${mtime}','${mac_address}'); select last_insert_id();")   serial=$(mysqldo "insert into client_serials (mtime, mac) values('${mtime}','${mac_address}'); select last_insert_id();")
36   fi   fi
# Line 44  validate_client() Line 46  validate_client()
46   SSLSAY_PORT="6666"   SSLSAY_PORT="6666"
47   nsslsay_fingerprint "register '${serial}'"   nsslsay_fingerprint "register '${serial}'"
48    
49     # register the client as online
50     serial_id=$(mysqldo "select serial from state_connected where serial=${serial};")
51     if [[ -n ${serial_id} ]]
52     then
53     mysqldo "update state_connected set ip='${ip_address}', mac='${mac_address}', mtime='${mtime}' where serial=${serial};"
54     else
55     mysqldo "insert into state_connected(serial,ip,mac,mtime) values('${serial}','${ip_address}','${mac_address}','${mtime}');"
56     fi
57    
58   return 0   return 0
59   fi   fi
60  }  }
# Line 79  register_client_local() Line 90  register_client_local()
90   return 1   return 1
91   fi   fi
92    
93     install -d "${MCORE_CONFIG_PATH}"
94   CONFIG="${MCORE_CONFIG_PATH}/serial"   CONFIG="${MCORE_CONFIG_PATH}/serial"
95   clearconfig   clearconfig
96   addconfig "CLIENT_SERIAL=\"${serial}\""   addconfig "CLIENT_SERIAL=\"${serial}\""

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