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 2457 by niro, Thu Sep 3 14:42:38 2015 UTC revision 2719 by niro, Fri Dec 18 10:48:29 2015 UTC
# Line 7  validate_client() Line 7  validate_client()
7   local serial   local serial
8   local mtime   local mtime
9   local serial_id   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 26  validate_client() Line 29  validate_client()
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 54  validate_client() Line 58  validate_client()
58   mysqldo "insert into state_connected(serial,ip,mac,mtime) values('${serial}','${ip_address}','${mac_address}','${mtime}');"   mysqldo "insert into state_connected(serial,ip,mac,mtime) values('${serial}','${ip_address}','${mac_address}','${mtime}');"
59   fi   fi
60    
61     # get netboot state
62     nsslsay_queue_init
63     nsslsay_queue_add "nocolors"
64     nsslsay_queue_add "get version.netboot"
65     netboot=$(control_client "${serial}" run-queue)
66     # update netboot state
67     serial_id=$(mysqldo "select serial from state_connected where serial=${serial};")
68     if [[ -n ${serial_id} ]]
69     then
70     mysqldo "update state_connected set netboot='${netboot}' where serial=${serial};"
71     fi
72    
73     # update tools and os version info
74     nsslsay_queue_init
75     nsslsay_queue_add "nocolors"
76     nsslsay_queue_add "get version.os"
77     os=$(control_client "${serial}" run-queue)
78     import_resource client_version "${serial}" os "${os}"
79     nsslsay_queue_init
80     nsslsay_queue_add "nocolors"
81     nsslsay_queue_add "get version.tools"
82     tools=$(control_client "${serial}" run-queue)
83     import_resource client_version "${serial}" utils "${tools}"
84    
85     # run hardware detection
86     if is_provided hardware
87     then
88     run_hardware_detect "${serial}"
89     fi
90    
91   return 0   return 0
92   fi   fi
93  }  }
# Line 75  register_client() Line 109  register_client()
109   decho "iface='${iface}'"   decho "iface='${iface}'"
110   decho "mac_address='${mac_address}'"   decho "mac_address='${mac_address}'"
111    
112   decho "register '${mac_address}'"   decho "register '${mac_address}' '${iface_ip}'"
113   nsslsay_fingerprint "register '${mac_address}' '${iface_ip}'"   nsslsay_fingerprint "register '${mac_address}' '${iface_ip}'"
114  }  }
115    
# Line 89  register_client_local() Line 123  register_client_local()
123   return 1   return 1
124   fi   fi
125    
126     install -d "${MCORE_CONFIG_PATH}"
127   CONFIG="${MCORE_CONFIG_PATH}/serial"   CONFIG="${MCORE_CONFIG_PATH}/serial"
128   clearconfig   clearconfig
129   addconfig "CLIENT_SERIAL=\"${serial}\""   addconfig "CLIENT_SERIAL=\"${serial}\""

Legend:
Removed from v.2457  
changed lines
  Added in v.2719