7 |
local serial |
local serial |
8 |
local mtime |
local mtime |
9 |
local serial_id |
local serial_id |
10 |
|
local os |
11 |
|
local tools |
12 |
|
|
13 |
if [[ -z ${mac_address} ]] |
if [[ -z ${mac_address} ]] |
14 |
then |
then |
28 |
# first check if mac is registered |
# first check if mac is registered |
29 |
serial=$(mysqldo "select serial from client_serials where mac='${mac_address}'") |
serial=$(mysqldo "select serial from client_serials where mac='${mac_address}'") |
30 |
|
|
31 |
|
# current mtime |
32 |
|
mtime=$(date +%s) |
33 |
|
|
34 |
if [[ -z ${serial} ]] |
if [[ -z ${serial} ]] |
35 |
then |
then |
|
mtime=$(date +%s) |
|
|
|
|
36 |
# 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) |
37 |
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();") |
38 |
fi |
fi |
57 |
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}');" |
58 |
fi |
fi |
59 |
|
|
60 |
|
# update tools and os version info |
61 |
|
nsslsay_queue_init |
62 |
|
nsslsay_queue_add "nocolors" |
63 |
|
nsslsay_queue_add "get version.os" |
64 |
|
os=$(control_client "${serial}" run-queue) |
65 |
|
import_resource client_version "${serial}" os "${os}" |
66 |
|
nsslsay_queue_init |
67 |
|
nsslsay_queue_add "nocolors" |
68 |
|
nsslsay_queue_add "get version.tools" |
69 |
|
os=$(control_client "${serial}" run-queue) |
70 |
|
import_resource client_version "${serial}" utils "${tools}" |
71 |
|
|
72 |
|
# run hardware detection |
73 |
|
if is_provided hardware |
74 |
|
then |
75 |
|
run_hardware_detect "${serial}" |
76 |
|
fi |
77 |
|
|
78 |
return 0 |
return 0 |
79 |
fi |
fi |
80 |
} |
} |
110 |
return 1 |
return 1 |
111 |
fi |
fi |
112 |
|
|
113 |
|
install -d "${MCORE_CONFIG_PATH}" |
114 |
CONFIG="${MCORE_CONFIG_PATH}/serial" |
CONFIG="${MCORE_CONFIG_PATH}/serial" |
115 |
clearconfig |
clearconfig |
116 |
addconfig "CLIENT_SERIAL=\"${serial}\"" |
addconfig "CLIENT_SERIAL=\"${serial}\"" |