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 2445 by niro, Thu Sep 3 13:36:12 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     local cmd
10    
11   if [[ -z ${mac_address} ]]   if [[ -z ${mac_address} ]]
12   then   then
# Line 10  validate_client() Line 14  validate_client()
14   return 1   return 1
15   fi   fi
16    
17     if [[ -z ${ip_address} ]]
18     then
19     eecho "Error: No ip_address given"
20     return 1
21     fi
22    
23     decho "registering mac_address='${mac_address}'"
24     decho "registering ip_address='${ip_address}'"
25    
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   if [[ -z ${serial} ]]   if [[ -z ${serial} ]]
30   then   then
31     mtime=$(date +%s)
32    
33   # 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)
34   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();")
35   fi   fi
36    
37   echo "serial='${serial}'"   if [[ -z ${serial} ]]
38     then
39     return 1
40     else
41     decho "serial='${serial}'"
42     rvecho "${serial}"
43    
44     cmd+="quiet"
45     cmd+="register '${serial}'"
46     SSLSAY_IP="${ip_address}"
47     SSLSAY_PORT="6666"
48     nsslsay_fingerprint ${cmd}
49    
50     return 0
51     fi
52  }  }
53    
54  register_client()  register_client()
# Line 28  register_client() Line 57  register_client()
57   local iface_ip   local iface_ip
58   local iface   local iface
59   local mac_address   local mac_address
60     local cmd
61    
62   control_server_ip=$(dns_to_ip ${MCORE_CONTROL_SERVER})   control_server_ip=$(dns_to_ip ${MCORE_CONTROL_SERVER})
63   iface_ip=$(iface_for_remote_addr ${control_server_ip})   iface_ip=$(iface_for_remote_addr ${control_server_ip})
64   iface=$(iface_for_ip ${iface_ip})   iface=$(iface_for_ip ${iface_ip})
65   mac_address=$(mac_for_iface ${iface})   mac_address=$(mac_for_iface ${iface})
66    
67   echo "DEBUG: MCORE_CONTROL_SERVER='${MCORE_CONTROL_SERVER}'"   decho "MCORE_CONTROL_SERVER='${MCORE_CONTROL_SERVER}'"
68   echo "DEBUG: iface_ip='${iface_ip}'"   decho "iface_ip='${iface_ip}'"
69   echo "DEBUG: iface='${iface}'"   decho "iface='${iface}'"
70   echo "DEBUG: mac_address='${mac_address}'"   decho "mac_address='${mac_address}'"
71    
72     decho "register '${mac_address}'"
73    
74     cmd+="quiet"
75     cmd+="register '${mac_address}' '${iface_ip}'"
76     nsslsay_fingerprint ${cmd}
77    }
78    
79    register_client_local()
80    {
81     local serial="$1"
82    
83     if [[ -z ${serial} ]]
84     then
85     eecho "No serial given"
86     return 1
87     fi
88    
89   echo "register '${mac_address}'"   CONFIG="${MCORE_CONFIG_PATH}/serial"
90     clearconfig
91     addconfig "CLIENT_SERIAL=\"${serial}\""
92  }  }

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