13 |
source ${MCORE_LIBDIR}/include/common.global.class |
source ${MCORE_LIBDIR}/include/common.global.class |
14 |
include ${MCORE_LIBDIR}/include/daemon.global.class |
include ${MCORE_LIBDIR}/include/daemon.global.class |
15 |
include ${MCORE_LIBDIR}/include/sessionauth.global.class |
include ${MCORE_LIBDIR}/include/sessionauth.global.class |
16 |
#include ${MCORE_LIBDIR}/include/mysqlfunctions.global.class |
include ${MCORE_LIBDIR}/include/register.global.class |
17 |
include ${MCORE_LIBDIR}/include/hwdetection.global.class |
include ${MCORE_LIBDIR}/include/hwdetection.global.class |
18 |
|
|
19 |
# load client classes plugins |
# load client classes plugins |
20 |
load_client_classes |
load_classes client |
21 |
|
|
22 |
# config settings |
# config settings |
23 |
include @@SYSCONFDIR@@/mcore/mcore.conf |
include @@SYSCONFDIR@@/mcore/mcore.conf |
|
#source @@SYSCONFDIR@@/mcore/serial |
|
|
|
|
|
# import_hardware_resource() |
|
|
# { |
|
|
# local resource="$1" |
|
|
# local value |
|
|
# |
|
|
# # special cases |
|
|
# case ${resource} in |
|
|
# gfxcard) value="$(get_x11_driver_modules)" ;; |
|
|
# *) value="$(get_hwinfo --with-description ${resource})" ;; |
|
|
# esac |
|
|
# |
|
|
# # if [[ ${DEBUG} = 1 ]] |
|
|
# # then |
|
|
# # echo "${resource}=${value}" >> /root/lala.log |
|
|
# # echo "mysqldo \"update status set ${resource}='${value}' where serial=${ALX_SERIAL};\"" >> /root/lala.log |
|
|
# # fi |
|
|
# # mysql_insert status,serial="${ALX_SERIAL}","${resource}"="${value}" |
|
|
# |
|
|
# import_resource status "${ALX_SERIAL}" "${resource}" "${value}" |
|
|
# } |
|
|
|
|
|
|
|
|
# set_init_state() |
|
|
# { |
|
|
# local ip |
|
|
# ip=$(ifconfig | grep -A1 eth0 | grep inet | sed 's/.*inet\ addr:\(.*\) Bcast.*/\1/;') |
|
|
# |
|
|
# } |
|
24 |
|
|
25 |
DEBUG=1 |
DEBUG=1 |
26 |
NOCOLORS="false" |
NOCOLORS="false" |
27 |
WEBCRLF="false" |
WEBCRLF="false" |
28 |
QUIET="false" |
QUIET="false" |
29 |
|
|
30 |
|
# argvs are global variables - this fixes issues with whitespaces |
31 |
|
# global argvs, the whole command line |
32 |
|
export GLOBAL_ARGV |
33 |
|
# class specific argvs which are given to the class as parameters |
34 |
|
export CLASS_ARGV |
35 |
|
|
36 |
run=run |
run=run |
37 |
valid_session=no |
valid_session=no |
38 |
|
|
41 |
|
|
42 |
while [[ ${run} = run ]] |
while [[ ${run} = run ]] |
43 |
do |
do |
44 |
|
# use an echo here not read -p '>' because sslsvd ignores the prompt pattern |
45 |
|
echo -n '> ' |
46 |
read line |
read line |
47 |
|
eval "GLOBAL_ARGV=( ${line} )" |
48 |
|
|
49 |
case ${line} in |
case ${GLOBAL_ARGV[0]} in |
50 |
quit) run=quit ;; |
quit) run=quit ;; |
51 |
|
|
52 |
# only react on the globals -> import|get|set|auth |
# only react on the globals -> import|get|set|auth |
53 |
import*) run_class ${line} ;; |
import) run_class ;; |
54 |
get*) run_class ${line} ;; |
get) run_class ;; |
55 |
set*) run_class ${line} ;; |
set) run_class ;; |
56 |
auth*) validate_auth ${line/auth /} ;; |
auth) validate_auth ${GLOBAL_ARGV[*]:1} ;; |
57 |
|
certauth) validate_auth_certificate ${GLOBAL_ARGV[*]:1} ;; |
58 |
|
register) valid_session && register_client_local ${GLOBAL_ARGV[*]:1} ;; |
59 |
provide) valid_session && print_provide ;; |
provide) valid_session && print_provide ;; |
60 |
require) valid_session && verify_requirements ;; |
require) valid_session && verify_requirements ;; |
61 |
reload) valid_session && mecho "reloading client classes ..." && load_client_classes ;; |
reload) valid_session && mecho "reloading client classes ..." && load_classes client ;; |
62 |
restart) valid_session && restart_service ;; |
restart) valid_session && restart_service ;; |
63 |
stop) valid_session && stop_service ;; |
stop) valid_session && stop_service ;; |
64 |
nocolors) export NOCOLORS="true" ;; |
nocolors) export NOCOLORS="true" ;; |
67 |
quiet) export QUIET="true" ;; |
quiet) export QUIET="true" ;; |
68 |
# version does not need auth |
# version does not need auth |
69 |
version) print_version ;; |
version) print_version ;; |
70 |
help*) |
help) |
71 |
if valid_session |
if valid_session |
72 |
then |
then |
73 |
if [[ ${line} = help ]] |
if [[ ${line} = help ]] |
79 |
else |
else |
80 |
mecho "You must authenticate yourself first!" |
mecho "You must authenticate yourself first!" |
81 |
mecho " auth [username] [password]" |
mecho " auth [username] [password]" |
82 |
|
mecho "or" |
83 |
|
mecho " certauth [certificate fingerprint]" |
84 |
fi |
fi |
85 |
;; |
;; |
86 |
|
|
90 |
#echo "$line" >> /root/lala.log |
#echo "$line" >> /root/lala.log |
91 |
;; |
;; |
92 |
esac |
esac |
93 |
|
|
94 |
|
# unset argvs to be safe |
95 |
|
unset GLOBAL_ARGS |
96 |
|
unset CLASS_ARGS |
97 |
done |
done |