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 2442 by niro, Thu Sep 3 13:28:24 2015 UTC revision 2699 by niro, Wed Dec 16 14:11:07 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 cmd   local serial_id
10     local os
11     local tools
12     local netboot
13    
14   if [[ -z ${mac_address} ]]   if [[ -z ${mac_address} ]]
15   then   then
# Line 21  validate_client() Line 24  validate_client()
24   fi   fi
25    
26   decho "registering mac_address='${mac_address}'"   decho "registering mac_address='${mac_address}'"
27     decho "registering ip_address='${ip_address}'"
28    
29   # first check if mac is registered   # first check if mac is registered
30   serial=$(mysqldo "select serial from client_serials where mac='${mac_address}'")   serial=$(mysqldo "select serial from client_serials where mac='${mac_address}'")
31    
32     # current mtime
33     mtime=$(date +%s)
34    
35   if [[ -z ${serial} ]]   if [[ -z ${serial} ]]
36   then   then
  mtime=$(date +%s)  
   
37   # 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)
38   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();")
39   fi   fi
# Line 40  validate_client() Line 45  validate_client()
45   decho "serial='${serial}'"   decho "serial='${serial}'"
46   rvecho "${serial}"   rvecho "${serial}"
47    
48   cmd+="quiet"   SSLSAY_IP="${ip_address}"
  cmd+="register '${serial}'"  
  SSLSAY_IP="${IP}"  
49   SSLSAY_PORT="6666"   SSLSAY_PORT="6666"
50   nsslsay_fingerprint "${cmd}"   nsslsay_fingerprint "register '${serial}'"
51    
52     # register the client as online
53     serial_id=$(mysqldo "select serial from state_connected where serial=${serial};")
54     if [[ -n ${serial_id} ]]
55     then
56     mysqldo "update state_connected set ip='${ip_address}', mac='${mac_address}', mtime='${mtime}' where serial=${serial};"
57     else
58     mysqldo "insert into state_connected(serial,ip,mac,mtime) values('${serial}','${ip_address}','${mac_address}','${mtime}');"
59     fi
60    
61     # update tools and os version info
62     nsslsay_queue_init
63     nsslsay_queue_add "nocolors"
64     nsslsay_queue_add "get version.os"
65     os=$(control_client "${serial}" run-queue)
66     import_resource client_version "${serial}" os "${os}"
67     nsslsay_queue_init
68     nsslsay_queue_add "nocolors"
69     nsslsay_queue_add "get version.tools"
70     tools=$(control_client "${serial}" run-queue)
71     import_resource client_version "${serial}" utils "${tools}"
72    
73     # update netboot state too
74     nsslsay_queue_init
75     nsslsay_queue_add "nocolors"
76     nsslsay_queue_add "get version.netboot"
77     netboot=$(control_client "${serial}" run-queue)
78     import_resource state_connected "${serial}" netboot "${netboot}"
79    
80     # run hardware detection
81     if is_provided hardware
82     then
83     run_hardware_detect "${serial}"
84     fi
85    
86   return 0   return 0
87   fi   fi
# Line 56  register_client() Line 93  register_client()
93   local iface_ip   local iface_ip
94   local iface   local iface
95   local mac_address   local mac_address
  local cmd  
96    
97   control_server_ip=$(dns_to_ip ${MCORE_CONTROL_SERVER})   control_server_ip=$(dns_to_ip ${MCORE_CONTROL_SERVER})
98   iface_ip=$(iface_for_remote_addr ${control_server_ip})   iface_ip=$(iface_for_remote_addr ${control_server_ip})
# Line 69  register_client() Line 105  register_client()
105   decho "mac_address='${mac_address}'"   decho "mac_address='${mac_address}'"
106    
107   decho "register '${mac_address}'"   decho "register '${mac_address}'"
108     nsslsay_fingerprint "register '${mac_address}' '${iface_ip}'"
  cmd+="quiet"  
  cmd+="register '${mac_address}' '${iface_ip}'"  
  nsslsay_fingerprint "${cmd}"  
109  }  }
110    
111  register_client_local()  register_client_local()
# Line 85  register_client_local() Line 118  register_client_local()
118   return 1   return 1
119   fi   fi
120    
121     install -d "${MCORE_CONFIG_PATH}"
122   CONFIG="${MCORE_CONFIG_PATH}/serial"   CONFIG="${MCORE_CONFIG_PATH}/serial"
123   clearconfig   clearconfig
124   addconfig "CLIENT_SERIAL=\"${serial}\""   addconfig "CLIENT_SERIAL=\"${serial}\""

Legend:
Removed from v.2442  
changed lines
  Added in v.2699