1 |
#!/bin/sh |
#!/bin/sh |
2 |
|
|
3 |
|
MCORE_LIBDIR="@@MCORE_LIBDIR@@" |
4 |
|
|
5 |
|
# respect system env (proxy settings etc) |
6 |
|
if [ -e @@SYSCONFDIR@@/profile ] |
7 |
|
then |
8 |
|
source @@SYSCONFDIR@@/profile |
9 |
|
fi |
10 |
|
|
11 |
# globals |
# globals |
12 |
source include/daemon.global.class |
# include function comes with common.global class |
13 |
source include/sessionauth.global.class |
source ${MCORE_LIBDIR}/include/common.global.class |
14 |
source include/mysqlfunctions.global.class |
include ${MCORE_LIBDIR}/include/daemon.global.class |
15 |
|
include ${MCORE_LIBDIR}/include/sessionauth.global.class |
16 |
# control specific |
include ${MCORE_LIBDIR}/include/mysqlfunctions.global.class |
17 |
#source include/graphic.control.class |
#include ${MCORE_LIBDIR}/include/hwdetection.global.class |
|
#source include/input.control.class |
|
|
for i in include/*.control.class |
|
|
do |
|
|
source ${i} || echo "error loading ${i}" |
|
|
done |
|
18 |
|
|
19 |
|
# load control classes plugins |
20 |
|
load_classes control |
21 |
|
|
22 |
SQL_USER=alx |
SQL_USER=alx |
23 |
SQL_PASS=@lx |
SQL_PASS=@lx |
40 |
mysql_insert "${table}",serial="${serial}","${resource}"="${value}" |
mysql_insert "${table}",serial="${serial}","${resource}"="${value}" |
41 |
} |
} |
42 |
|
|
|
run_class() |
|
|
{ |
|
|
local method="$1" |
|
|
local caller="$2" |
|
|
local class |
|
|
local cmd |
|
|
local argv |
|
|
|
|
|
if validate_session |
|
|
then |
|
|
class="${caller%.*}" |
|
|
cmd="${caller#*.}" |
|
|
argv="${@/${caller}/}" # remove caller |
|
|
argv="${argv/${method}/}" # remove method |
|
|
|
|
|
# echo "method=${method}" |
|
|
# echo "caller=${caller}" |
|
|
# echo "class=${class}" |
|
|
# echo "cmd=${cmd}" |
|
|
# echo "argv=${argv}" |
|
|
|
|
|
# check if class.cmd exist |
|
|
if [[ ! -z $(typeset -f "${method}"_"${class}"_"${cmd}") ]] |
|
|
then |
|
|
"${method}"_"${class}"_"${cmd}" ${argv} |
|
|
else |
|
|
echo "unknown class.cmd" |
|
|
fi |
|
|
else |
|
|
invalid_session |
|
|
fi |
|
|
} |
|
|
|
|
43 |
nsslsay() |
nsslsay() |
44 |
{ |
{ |
45 |
nssl "${IP}" "${PORT}" << EOF |
nssl "${IP}" "${PORT}" << EOF |
65 |
nsslsay "${command}" |
nsslsay "${command}" |
66 |
} |
} |
67 |
|
|
|
|
|
|
DEBUG=1 |
|
68 |
#IP="192.168.0.6" |
#IP="192.168.0.6" |
69 |
PORT="6666" |
PORT="6666" |
70 |
SSLSAY_USER="foo" |
SSLSAY_USER="foo" |
71 |
SSLSAY_PASS="bar" |
SSLSAY_PASS="bar" |
72 |
|
|
73 |
|
DEBUG=1 |
74 |
|
NOCOLORS="false" |
75 |
|
WEBCRLF="false" |
76 |
|
QUIET="false" |
77 |
|
|
78 |
|
# argvs are global variables - this fixes issues with whitespaces |
79 |
|
# global argvs, the whole command line |
80 |
|
export GLOBAL_ARGV |
81 |
|
# class specific argvs which are given to the class as parameters |
82 |
|
export CLASS_ARGV |
83 |
|
|
84 |
run=run |
run=run |
85 |
valid_session=no |
valid_session=no |
86 |
|
|
87 |
|
# tell what we are |
88 |
|
echo "Connected to $(print_version)" |
89 |
|
|
90 |
while [[ ${run} = run ]] |
while [[ ${run} = run ]] |
91 |
do |
do |
92 |
read line |
read line |
93 |
|
eval "GLOBAL_ARGV=( ${line} )" |
94 |
|
|
95 |
case ${line} in |
case ${GLOBAL_ARGV[0]} in |
96 |
quit) run=quit ;; |
quit) run=quit ;; |
97 |
# only react on the globals -> import|get|set|auth|control |
|
98 |
import*) run_class ${line} ;; |
# only react on the globals -> import|get|set|auth |
99 |
get*) run_class ${line} ;; |
import) run_class ;; |
100 |
set*) run_class ${line} ;; |
control) run_class ;; |
101 |
auth*) validate_auth ${line/auth /} ;; |
get) run_class ;; |
102 |
# control client daemons |
set) run_class ;; |
103 |
#control*) control_client ${line/control /} ;; |
auth) validate_auth ${GLOBAL_ARGV[*]:1} ;; |
104 |
control*) run_class ${line} ;; |
provide) valid_session && print_provide ;; |
105 |
*) echo "$line" >> /root/lala.log ;; |
require) valid_session && verify_requirements ;; |
106 |
|
reload) valid_session && mecho "reloading client classes ..." && load_classes client ;; |
107 |
|
restart) valid_session && restart_service ;; |
108 |
|
stop) valid_session && stop_service ;; |
109 |
|
nocolors) export NOCOLORS="true" ;; |
110 |
|
colors) export NOCOLORS="false" ;; |
111 |
|
webcrlf) export WEBCRLF="true" ;; |
112 |
|
quiet) export QUIET="true" ;; |
113 |
|
# version does not need auth |
114 |
|
version) print_version ;; |
115 |
|
help) |
116 |
|
if valid_session |
117 |
|
then |
118 |
|
if [[ ${line} = help ]] |
119 |
|
then |
120 |
|
help_topics |
121 |
|
else |
122 |
|
run_class ${line} |
123 |
|
fi |
124 |
|
else |
125 |
|
mecho "You must authenticate yourself first!" |
126 |
|
mecho " auth [username] [password]" |
127 |
|
fi |
128 |
|
;; |
129 |
|
|
130 |
|
*) |
131 |
|
mecho "Unknown command '${line}'" |
132 |
|
mecho "Type 'help' for more information." |
133 |
|
#echo "$line" >> /root/lala.log |
134 |
|
;; |
135 |
esac |
esac |
|
done |
|
136 |
|
|
137 |
|
# unset argvs to be safe |
138 |
|
unset GLOBAL_ARGS |
139 |
|
unset CLASS_ARGS |
140 |
|
done |