1 |
# $Id$ |
# $Id$ |
2 |
|
|
3 |
|
# loads client classes from $MCLIBDIR |
4 |
|
load_client_classes() |
5 |
|
{ |
6 |
|
# client specific |
7 |
|
for i in ${MCLIBDIR}/include/*.client.class |
8 |
|
do |
9 |
|
source ${i} || eecho "error loading ${i}" |
10 |
|
done |
11 |
|
} |
12 |
|
|
13 |
|
# restarts the whole service via remote cmd |
14 |
|
restart_service() |
15 |
|
{ |
16 |
|
local pid |
17 |
|
for pid in $(pidof sslsvd) |
18 |
|
do |
19 |
|
kill -SIGHUP ${pid} |
20 |
|
done |
21 |
|
} |
22 |
|
|
23 |
|
# stops the whole service via remote cmd |
24 |
|
stop_service() |
25 |
|
{ |
26 |
|
local pid |
27 |
|
for pid in $(pidof sslsvd) |
28 |
|
do |
29 |
|
kill -15 ${pid} |
30 |
|
sleep 1 |
31 |
|
kill -9 ${pid} |
32 |
|
done |
33 |
|
} |
34 |
|
|
35 |
# # import_resource $table $serial $resource $value |
# # import_resource $table $serial $resource $value |
36 |
# import_resource() |
# import_resource() |
37 |
# { |
# { |
76 |
then |
then |
77 |
"${method}"_"${class}"_"${cmd}" ${argv} |
"${method}"_"${class}"_"${cmd}" ${argv} |
78 |
else |
else |
79 |
echo "unkown method '${method}' . class '${class}' . cmd '${cmd}'" |
eecho "unkown method '${method}' . class '${class}' . cmd '${cmd}'" |
80 |
fi |
fi |
81 |
else |
else |
82 |
invalid_session |
invalid_session |
96 |
mecho "\tauth - authenticate to the daemon" |
mecho "\tauth - authenticate to the daemon" |
97 |
mecho "\tprovide - shows provides of a system" |
mecho "\tprovide - shows provides of a system" |
98 |
mecho "\trequire - verify plugin requirements" |
mecho "\trequire - verify plugin requirements" |
99 |
|
mecho "\treload - reloads all client classes plugins" |
100 |
|
mecho "\trestart - restarts the daemon" |
101 |
|
mecho "\tstop - stops the daemon" |
102 |
mecho "\tnocolors - disable colors, useful for the webclient" |
mecho "\tnocolors - disable colors, useful for the webclient" |
103 |
|
mecho "\tcolors - enable colors" |
104 |
|
mecho "\tquiet - do not print any unecessary messages" |
105 |
mecho "\thelp - shows help" |
mecho "\thelp - shows help" |
106 |
mecho "\tquit - quits the connection to the server" |
mecho "\tquit - quits the connection to the server" |
107 |
mecho |
mecho |
122 |
# on newer xorg-servers root is not allowed to run progs in a user session |
# on newer xorg-servers root is not allowed to run progs in a user session |
123 |
x11runas() |
x11runas() |
124 |
{ |
{ |
125 |
su - "${MCORE_UNPRIV_USER}" -c "DISPLAY=${MCORE_XORG_DISPLAY} $@" |
if [[ -n $(pidof X) ]] |
126 |
|
then |
127 |
|
su - "${MCORE_UNPRIV_USER}" -c "DISPLAY=${MCORE_XORG_DISPLAY} $@" |
128 |
|
fi |
129 |
} |
} |
130 |
|
|
131 |
addconfig() |
addconfig() |
134 |
|
|
135 |
if [[ -z ${CONFIG} ]] |
if [[ -z ${CONFIG} ]] |
136 |
then |
then |
137 |
echo "You must define \$CONFIG varibale first!" |
eecho "You must define \$CONFIG varibale first!" |
138 |
return 1 |
return 1 |
139 |
fi |
fi |
140 |
|
|
156 |
{ |
{ |
157 |
if [[ -z ${CONFIG} ]] |
if [[ -z ${CONFIG} ]] |
158 |
then |
then |
159 |
echo "You must define \$CONFIG varibale first!" |
eecho "You must define \$CONFIG varibale first!" |
160 |
return 1 |
return 1 |
161 |
fi |
fi |
162 |
|
|
194 |
then |
then |
195 |
export REQUIRE="${REQUIRE} ${i}" |
export REQUIRE="${REQUIRE} ${i}" |
196 |
else |
else |
197 |
[[ ${DEBUG} = 1 ]] && echo "duplicate provide '${i}' detected!" |
decho "duplicate provide '${i}' detected!" |
198 |
fi |
fi |
199 |
done |
done |
200 |
} |
} |
223 |
# show missing and set the right retval |
# show missing and set the right retval |
224 |
if [[ -z ${missing} ]] |
if [[ -z ${missing} ]] |
225 |
then |
then |
226 |
mecho "${sorted}" |
rvecho "${sorted}" |
227 |
return 0 |
return 0 |
228 |
else |
else |
229 |
for req in ${sorted} |
for req in ${sorted} |
231 |
if no_duplicate "${missing}" "$req" |
if no_duplicate "${missing}" "$req" |
232 |
then |
then |
233 |
# print normal |
# print normal |
234 |
mecho -n " ${req}" |
rvecho -n " ${req}" |
235 |
else |
else |
236 |
# print missing |
# print missing |
237 |
eecho -n " ${req}" |
eecho -n " ${req}" |
253 |
then |
then |
254 |
export PROVIDE="${PROVIDE} ${i}" |
export PROVIDE="${PROVIDE} ${i}" |
255 |
else |
else |
256 |
[[ ${DEBUG} = 1 ]] && echo "duplicate provide '${i}' detected!" |
decho "duplicate provide '${i}' detected!" |
257 |
fi |
fi |
258 |
done |
done |
259 |
} |
} |
265 |
# sort them alpabetically |
# sort them alpabetically |
266 |
sorted=$(for i in ${PROVIDE}; do echo "${i}"; done | sort) |
sorted=$(for i in ${PROVIDE}; do echo "${i}"; done | sort) |
267 |
# do not escape, or CRLFS get printed to screen too |
# do not escape, or CRLFS get printed to screen too |
268 |
mecho ${sorted} |
rvecho ${sorted} |
269 |
} |
} |
270 |
|
|
271 |
|
# message only echo | disabled in quiet mode |
272 |
mecho() |
mecho() |
273 |
{ |
{ |
274 |
local COLCYAN="\033[1;36m" |
local COLCYAN="\033[1;36m" |
276 |
local opts |
local opts |
277 |
local webcrlf |
local webcrlf |
278 |
|
|
279 |
|
# print nothing if quiet mode was requested |
280 |
|
[[ ${QUIET} = true ]] && return |
281 |
|
|
282 |
if [[ ${NOCOLORS} = true ]] |
if [[ ${NOCOLORS} = true ]] |
283 |
then |
then |
284 |
COLCYAN="" |
COLCYAN="" |
295 |
echo -e${opts} "${COLCYAN}$@${COLDEFAULT}${webcrlf}" |
echo -e${opts} "${COLCYAN}$@${COLDEFAULT}${webcrlf}" |
296 |
} |
} |
297 |
|
|
298 |
|
# prints error messages | enabled even in quiet mode |
299 |
eecho() |
eecho() |
300 |
{ |
{ |
301 |
local COLRED="\033[1;31m" |
local COLRED="\033[1;31m" |
319 |
echo -e${opts} "${COLRED}$@${COLDEFAULT}${webcrlf}" |
echo -e${opts} "${COLRED}$@${COLDEFAULT}${webcrlf}" |
320 |
} |
} |
321 |
|
|
322 |
|
# prints return values of get | enabled even in quiet mode |
323 |
|
rvecho() |
324 |
|
{ |
325 |
|
local COLPURPLE="\033[1;35m" |
326 |
|
local COLDEFAULT="\033[0m" |
327 |
|
local opts |
328 |
|
local webcrlf |
329 |
|
|
330 |
|
if [[ ${NOCOLORS} = true ]] |
331 |
|
then |
332 |
|
COLPURPLE="" |
333 |
|
COLDEFAULT="" |
334 |
|
fi |
335 |
|
|
336 |
|
[[ ${WEBCRLF} = true ]] && webcrlf="<br>" |
337 |
|
|
338 |
|
# respect -n |
339 |
|
case $1 in |
340 |
|
-n) shift; opts="n" ;; |
341 |
|
esac |
342 |
|
|
343 |
|
echo -e${opts} "${COLPURPLE}$@${COLDEFAULT}${webcrlf}" |
344 |
|
} |
345 |
|
|
346 |
|
# prints debug messages if requested | enabled even in quiet mode |
347 |
|
decho() |
348 |
|
{ |
349 |
|
# print nothing if debug mode was *not* requested |
350 |
|
[[ ${DEBUG} != 1 ]] && return |
351 |
|
|
352 |
|
eecho "DEBUG: ${@}" |
353 |
|
} |
354 |
|
|
355 |
path_not_empty() |
path_not_empty() |
356 |
{ |
{ |
357 |
local path="$1" |
local path="$1" |
358 |
[[ -z ${path} ]] && "path_not_empty(): no path given!" && return 1 |
[[ -z ${path} ]] && eecho "path_not_empty(): no path given!" && return 1 |
359 |
|
|
360 |
# return ERR if path does not exist |
# return ERR if path does not exist |
361 |
[[ ! -d ${path} ]] && return 1 |
[[ ! -d ${path} ]] && return 1 |
365 |
# every thing went ok, directory not empty |
# every thing went ok, directory not empty |
366 |
return 0 |
return 0 |
367 |
} |
} |
368 |
|
|
369 |
|
help_daemon_mroot() |
370 |
|
{ |
371 |
|
mecho "get daemon.mroot" |
372 |
|
mecho " Prints current MROOT variable." |
373 |
|
mecho |
374 |
|
mecho "set daemon.mroot [path]" |
375 |
|
mecho " set MROOT variable to given path." |
376 |
|
} |
377 |
|
|
378 |
|
get_daemon_mroot() |
379 |
|
{ |
380 |
|
rvecho "${MROOT}" |
381 |
|
} |
382 |
|
|
383 |
|
set_daemon_mroot() |
384 |
|
{ |
385 |
|
local path=$1 |
386 |
|
|
387 |
|
if [[ -d ${path} ]] |
388 |
|
then |
389 |
|
export MROOT="${path}" |
390 |
|
decho "MROOT='${MROOT}' is set." |
391 |
|
else |
392 |
|
eecho "Path '${path}' does not exist. MROOT not set." |
393 |
|
fi |
394 |
|
} |
395 |
|
|
396 |
|
list_files_in_directory() |
397 |
|
{ |
398 |
|
local i |
399 |
|
local retval |
400 |
|
local path |
401 |
|
local opts |
402 |
|
local type |
403 |
|
|
404 |
|
# basic getops |
405 |
|
for i in $* |
406 |
|
do |
407 |
|
case $1 in |
408 |
|
-mindepth) shift; opts+=" -mindepth $1" ;; |
409 |
|
-maxdepth) shift; opts+=" -maxdepth $1" ;; |
410 |
|
-type) shift; type="$1" ;; |
411 |
|
'') continue ;; |
412 |
|
*) path="$1" ;; |
413 |
|
esac |
414 |
|
shift |
415 |
|
done |
416 |
|
|
417 |
|
if [[ -z ${path} ]] |
418 |
|
then |
419 |
|
eecho "No path given." |
420 |
|
return 1 |
421 |
|
fi |
422 |
|
|
423 |
|
if [[ ! -d ${path} ]] |
424 |
|
then |
425 |
|
eecho "Directory '${path}' does not exist." |
426 |
|
return 1 |
427 |
|
fi |
428 |
|
|
429 |
|
# default to files |
430 |
|
[[ -z ${type} ]] && type=f |
431 |
|
|
432 |
|
for i in $(find ${path} ${opts} -type ${type} | sort) |
433 |
|
do |
434 |
|
if [[ -z ${retval} ]] |
435 |
|
then |
436 |
|
retval="$(basename ${i})" |
437 |
|
else |
438 |
|
retval="${retval} $(basename ${i})" |
439 |
|
fi |
440 |
|
done |
441 |
|
|
442 |
|
rvecho "${retval}" |
443 |
|
} |