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 |
# # import_resource $table $serial $resource $value |
# # import_resource $table $serial $resource $value |
24 |
# import_resource() |
# import_resource() |
25 |
# { |
# { |
64 |
then |
then |
65 |
"${method}"_"${class}"_"${cmd}" ${argv} |
"${method}"_"${class}"_"${cmd}" ${argv} |
66 |
else |
else |
67 |
echo "unkown method '${method}' . class '${class}' . cmd '${cmd}'" |
eecho "unkown method '${method}' . class '${class}' . cmd '${cmd}'" |
68 |
fi |
fi |
69 |
else |
else |
70 |
invalid_session |
invalid_session |
78 |
|
|
79 |
topics=$(typeset -f | grep '^help_' | sed 's:help_\(.*\)\ .*():\1:' | sed 's:_:\.:' | sort) |
topics=$(typeset -f | grep '^help_' | sed 's:help_\(.*\)\ .*():\1:' | sed 's:_:\.:' | sort) |
80 |
mecho "Global commands:" |
mecho "Global commands:" |
81 |
mecho "\timport - import settings to database" |
mecho "\timport - import settings to database" |
82 |
mecho "\tget - shows current value for a settings" |
mecho "\tget - shows current value for a settings" |
83 |
mecho "\tset - sets value for a setting" |
mecho "\tset - sets value for a setting" |
84 |
mecho "\tauth - authenticate to the daemon" |
mecho "\tauth - authenticate to the daemon" |
85 |
mecho "\tprovide - shows provides of a system" |
mecho "\tprovide - shows provides of a system" |
86 |
mecho "\trequire - verify plugin requirements" |
mecho "\trequire - verify plugin requirements" |
87 |
|
mecho "\treload - reloads all client classes plugins" |
88 |
|
mecho "\trestart - restarts the daemon" |
89 |
mecho "\tnocolors - disable colors, useful for the webclient" |
mecho "\tnocolors - disable colors, useful for the webclient" |
90 |
mecho "\thelp - shows help" |
mecho "\tquiet - do not print any unecessary messages" |
91 |
mecho "\tquit - quits the connection to the server" |
mecho "\thelp - shows help" |
92 |
|
mecho "\tquit - quits the connection to the server" |
93 |
mecho |
mecho |
94 |
mecho "Help topics:" |
mecho "Help topics:" |
95 |
for i in ${topics} |
for i in ${topics} |
108 |
# 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 |
109 |
x11runas() |
x11runas() |
110 |
{ |
{ |
111 |
su - "${MCORE_UNPRIV_USER}" -c "DISPLAY=${MCORE_XORG_DISPLAY} $@" |
if [[ -n $(pidof X) ]] |
112 |
|
then |
113 |
|
su - "${MCORE_UNPRIV_USER}" -c "DISPLAY=${MCORE_XORG_DISPLAY} $@" |
114 |
|
fi |
115 |
} |
} |
116 |
|
|
117 |
addconfig() |
addconfig() |
120 |
|
|
121 |
if [[ -z ${CONFIG} ]] |
if [[ -z ${CONFIG} ]] |
122 |
then |
then |
123 |
echo "You must define \$CONFIG varibale first!" |
eecho "You must define \$CONFIG varibale first!" |
124 |
return 1 |
return 1 |
125 |
fi |
fi |
126 |
|
|
142 |
{ |
{ |
143 |
if [[ -z ${CONFIG} ]] |
if [[ -z ${CONFIG} ]] |
144 |
then |
then |
145 |
echo "You must define \$CONFIG varibale first!" |
eecho "You must define \$CONFIG varibale first!" |
146 |
return 1 |
return 1 |
147 |
fi |
fi |
148 |
|
|
180 |
then |
then |
181 |
export REQUIRE="${REQUIRE} ${i}" |
export REQUIRE="${REQUIRE} ${i}" |
182 |
else |
else |
183 |
[[ ${DEBUG} = 1 ]] && echo "duplicate provide '${i}' detected!" |
decho "duplicate provide '${i}' detected!" |
184 |
fi |
fi |
185 |
done |
done |
186 |
} |
} |
209 |
# show missing and set the right retval |
# show missing and set the right retval |
210 |
if [[ -z ${missing} ]] |
if [[ -z ${missing} ]] |
211 |
then |
then |
212 |
mecho "${sorted}" |
rvecho "${sorted}" |
213 |
return 0 |
return 0 |
214 |
else |
else |
215 |
for req in ${sorted} |
for req in ${sorted} |
217 |
if no_duplicate "${missing}" "$req" |
if no_duplicate "${missing}" "$req" |
218 |
then |
then |
219 |
# print normal |
# print normal |
220 |
mecho -n " ${req}" |
rvecho -n " ${req}" |
221 |
else |
else |
222 |
# print missing |
# print missing |
223 |
eecho -n " ${req}" |
eecho -n " ${req}" |
239 |
then |
then |
240 |
export PROVIDE="${PROVIDE} ${i}" |
export PROVIDE="${PROVIDE} ${i}" |
241 |
else |
else |
242 |
[[ ${DEBUG} = 1 ]] && echo "duplicate provide '${i}' detected!" |
decho "duplicate provide '${i}' detected!" |
243 |
fi |
fi |
244 |
done |
done |
245 |
} |
} |
251 |
# sort them alpabetically |
# sort them alpabetically |
252 |
sorted=$(for i in ${PROVIDE}; do echo "${i}"; done | sort) |
sorted=$(for i in ${PROVIDE}; do echo "${i}"; done | sort) |
253 |
# do not escape, or CRLFS get printed to screen too |
# do not escape, or CRLFS get printed to screen too |
254 |
mecho ${sorted} |
rvecho ${sorted} |
255 |
} |
} |
256 |
|
|
257 |
|
# message only echo | disabled in quiet mode |
258 |
mecho() |
mecho() |
259 |
{ |
{ |
260 |
local COLCYAN="\033[1;36m" |
local COLCYAN="\033[1;36m" |
262 |
local opts |
local opts |
263 |
local webcrlf |
local webcrlf |
264 |
|
|
265 |
|
# print nothing if quiet mode was requested |
266 |
|
[[ ${QUIET} = true ]] && return |
267 |
|
|
268 |
if [[ ${NOCOLORS} = true ]] |
if [[ ${NOCOLORS} = true ]] |
269 |
then |
then |
270 |
COLCYAN="" |
COLCYAN="" |
281 |
echo -e${opts} "${COLCYAN}$@${COLDEFAULT}${webcrlf}" |
echo -e${opts} "${COLCYAN}$@${COLDEFAULT}${webcrlf}" |
282 |
} |
} |
283 |
|
|
284 |
|
# prints error messages | enabled even in quiet mode |
285 |
eecho() |
eecho() |
286 |
{ |
{ |
287 |
local COLRED="\033[1;31m" |
local COLRED="\033[1;31m" |
305 |
echo -e${opts} "${COLRED}$@${COLDEFAULT}${webcrlf}" |
echo -e${opts} "${COLRED}$@${COLDEFAULT}${webcrlf}" |
306 |
} |
} |
307 |
|
|
308 |
|
# prints return values of get | enabled even in quiet mode |
309 |
|
rvecho() |
310 |
|
{ |
311 |
|
local COLPURPLE="\033[1;35m" |
312 |
|
local COLDEFAULT="\033[0m" |
313 |
|
local opts |
314 |
|
local webcrlf |
315 |
|
|
316 |
|
if [[ ${NOCOLORS} = true ]] |
317 |
|
then |
318 |
|
COLPURPLE="" |
319 |
|
COLDEFAULT="" |
320 |
|
fi |
321 |
|
|
322 |
|
[[ ${WEBCRLF} = true ]] && webcrlf="<br>" |
323 |
|
|
324 |
|
# respect -n |
325 |
|
case $1 in |
326 |
|
-n) shift; opts="n" ;; |
327 |
|
esac |
328 |
|
|
329 |
|
echo -e${opts} "${COLPURPLE}$@${COLDEFAULT}${webcrlf}" |
330 |
|
} |
331 |
|
|
332 |
|
# prints debug messages if requested | enabled even in quiet mode |
333 |
|
decho() |
334 |
|
{ |
335 |
|
# print nothing if debug mode was *not* requested |
336 |
|
[[ ${DEBUG} != 1 ]] && return |
337 |
|
|
338 |
|
eecho "DEBUG: ${@}" |
339 |
|
} |
340 |
|
|
341 |
path_not_empty() |
path_not_empty() |
342 |
{ |
{ |
343 |
local path="$1" |
local path="$1" |
344 |
[[ -z ${path} ]] && "path_not_empty(): no path given!" && return 1 |
[[ -z ${path} ]] && eecho "path_not_empty(): no path given!" && return 1 |
345 |
|
|
346 |
# return ERR if path does not exist |
# return ERR if path does not exist |
347 |
[[ ! -d ${path} ]] && return 1 |
[[ ! -d ${path} ]] && return 1 |