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 |
# { |
# { |
46 |
local cmd |
local cmd |
47 |
local argv |
local argv |
48 |
|
|
49 |
if validate_session |
if valid_session |
50 |
then |
then |
51 |
class="${caller%.*}" |
class="${caller%.*}" |
52 |
cmd="${caller#*.}" |
cmd="${caller#*.}" |
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 "\thelp - shows help" |
mecho "\trequire - verify plugin requirements" |
87 |
mecho "\tquit - quits the connection to the server" |
mecho "\tnocolors - disable colors, useful for the webclient" |
88 |
|
mecho "\tquiet - do not print any unecessary messages" |
89 |
|
mecho "\thelp - shows help" |
90 |
|
mecho "\tquit - quits the connection to the server" |
91 |
mecho |
mecho |
92 |
mecho "Help topics:" |
mecho "Help topics:" |
93 |
for i in ${topics} |
for i in ${topics} |
106 |
# 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 |
107 |
x11runas() |
x11runas() |
108 |
{ |
{ |
109 |
su - "${MCORE_UNPRIV_USER}" -c "DISPLAY=${MCORE_XORG_DISPLAY} $@" |
if [[ -n $(pidof X) ]] |
110 |
|
then |
111 |
|
su - "${MCORE_UNPRIV_USER}" -c "DISPLAY=${MCORE_XORG_DISPLAY} $@" |
112 |
|
fi |
113 |
} |
} |
114 |
|
|
115 |
addconfig() |
addconfig() |
116 |
{ |
{ |
117 |
|
local opts |
118 |
|
|
119 |
if [[ -z ${CONFIG} ]] |
if [[ -z ${CONFIG} ]] |
120 |
then |
then |
121 |
echo "You must define \$CONFIG varibale first!" |
eecho "You must define \$CONFIG varibale first!" |
122 |
return 1 |
return 1 |
123 |
fi |
fi |
124 |
|
|
126 |
then |
then |
127 |
install -d $(dirname ${CONFIG}) |
install -d $(dirname ${CONFIG}) |
128 |
fi |
fi |
129 |
echo "$@" >> ${CONFIG} |
|
130 |
|
# check for opts |
131 |
|
case $1 in |
132 |
|
-n) shift; opts=" -n" ;; |
133 |
|
-e) shift; opts=" -e" ;; |
134 |
|
esac |
135 |
|
|
136 |
|
echo ${opts} "$@" >> ${CONFIG} |
137 |
} |
} |
138 |
|
|
139 |
clearconfig() |
clearconfig() |
140 |
{ |
{ |
141 |
if [[ -z ${CONFIG} ]] |
if [[ -z ${CONFIG} ]] |
142 |
then |
then |
143 |
echo "You must define \$CONFIG varibale first!" |
eecho "You must define \$CONFIG varibale first!" |
144 |
return 1 |
return 1 |
145 |
fi |
fi |
146 |
|
|
178 |
then |
then |
179 |
export REQUIRE="${REQUIRE} ${i}" |
export REQUIRE="${REQUIRE} ${i}" |
180 |
else |
else |
181 |
[[ ${DEBUG} = 1 ]] && echo "duplicate provide '${i}' detected!" |
decho "duplicate provide '${i}' detected!" |
182 |
fi |
fi |
183 |
done |
done |
184 |
} |
} |
207 |
# show missing and set the right retval |
# show missing and set the right retval |
208 |
if [[ -z ${missing} ]] |
if [[ -z ${missing} ]] |
209 |
then |
then |
210 |
mecho "${sorted}" |
rvecho "${sorted}" |
211 |
return 0 |
return 0 |
212 |
else |
else |
213 |
for req in ${sorted} |
for req in ${sorted} |
215 |
if no_duplicate "${missing}" "$req" |
if no_duplicate "${missing}" "$req" |
216 |
then |
then |
217 |
# print normal |
# print normal |
218 |
mecho -n " ${req}" |
rvecho -n " ${req}" |
219 |
else |
else |
220 |
# print missing |
# print missing |
221 |
eecho -n " ${req}" |
eecho -n " ${req}" |
237 |
then |
then |
238 |
export PROVIDE="${PROVIDE} ${i}" |
export PROVIDE="${PROVIDE} ${i}" |
239 |
else |
else |
240 |
[[ ${DEBUG} = 1 ]] && echo "duplicate provide '${i}' detected!" |
decho "duplicate provide '${i}' detected!" |
241 |
fi |
fi |
242 |
done |
done |
243 |
} |
} |
249 |
# sort them alpabetically |
# sort them alpabetically |
250 |
sorted=$(for i in ${PROVIDE}; do echo "${i}"; done | sort) |
sorted=$(for i in ${PROVIDE}; do echo "${i}"; done | sort) |
251 |
# do not escape, or CRLFS get printed to screen too |
# do not escape, or CRLFS get printed to screen too |
252 |
mecho ${sorted} |
rvecho ${sorted} |
253 |
} |
} |
254 |
|
|
255 |
|
# message only echo | disabled in quiet mode |
256 |
mecho() |
mecho() |
257 |
{ |
{ |
258 |
local COLCYAN="\033[1;36m" |
local COLCYAN="\033[1;36m" |
259 |
local COLDEFAULT="\033[0m" |
local COLDEFAULT="\033[0m" |
260 |
local opts |
local opts |
261 |
|
local webcrlf |
262 |
|
|
263 |
|
# print nothing if quiet mode was requested |
264 |
|
[[ ${QUIET} = true ]] && return |
265 |
|
|
266 |
if [[ ${NOCOLORS} = true ]] |
if [[ ${NOCOLORS} = true ]] |
267 |
then |
then |
269 |
COLDEFAULT="" |
COLDEFAULT="" |
270 |
fi |
fi |
271 |
|
|
272 |
|
[[ ${WEBCRLF} = true ]] && webcrlf="<br>" |
273 |
|
|
274 |
# respect -n |
# respect -n |
275 |
case $1 in |
case $1 in |
276 |
-n) shift; opts="n" ;; |
-n) shift; opts="n" ;; |
277 |
esac |
esac |
278 |
|
|
279 |
echo -e${opts} "${COLCYAN}$@${COLDEFAULT}" |
echo -e${opts} "${COLCYAN}$@${COLDEFAULT}${webcrlf}" |
280 |
} |
} |
281 |
|
|
282 |
|
# prints error messages | enabled even in quiet mode |
283 |
eecho() |
eecho() |
284 |
{ |
{ |
285 |
local COLRED="\033[1;31m" |
local COLRED="\033[1;31m" |
286 |
local COLDEFAULT="\033[0m" |
local COLDEFAULT="\033[0m" |
287 |
local opts |
local opts |
288 |
|
local webcrlf |
289 |
|
|
290 |
if [[ ${NOCOLORS} = true ]] |
if [[ ${NOCOLORS} = true ]] |
291 |
then |
then |
293 |
COLDEFAULT="" |
COLDEFAULT="" |
294 |
fi |
fi |
295 |
|
|
296 |
|
[[ ${WEBCRLF} = true ]] && webcrlf="<br>" |
297 |
|
|
298 |
|
# respect -n |
299 |
|
case $1 in |
300 |
|
-n) shift; opts="n" ;; |
301 |
|
esac |
302 |
|
|
303 |
|
echo -e${opts} "${COLRED}$@${COLDEFAULT}${webcrlf}" |
304 |
|
} |
305 |
|
|
306 |
|
# prints return values of get | enabled even in quiet mode |
307 |
|
rvecho() |
308 |
|
{ |
309 |
|
local COLPURPLE="\033[1;35m" |
310 |
|
local COLDEFAULT="\033[0m" |
311 |
|
local opts |
312 |
|
local webcrlf |
313 |
|
|
314 |
|
if [[ ${NOCOLORS} = true ]] |
315 |
|
then |
316 |
|
COLPURPLE="" |
317 |
|
COLDEFAULT="" |
318 |
|
fi |
319 |
|
|
320 |
|
[[ ${WEBCRLF} = true ]] && webcrlf="<br>" |
321 |
|
|
322 |
# respect -n |
# respect -n |
323 |
case $1 in |
case $1 in |
324 |
-n) shift; opts="n" ;; |
-n) shift; opts="n" ;; |
325 |
esac |
esac |
326 |
|
|
327 |
echo -e${opts} "${COLRED}$@${COLDEFAULT}" |
echo -e${opts} "${COLPURPLE}$@${COLDEFAULT}${webcrlf}" |
328 |
|
} |
329 |
|
|
330 |
|
# prints debug messages if requested | enabled even in quiet mode |
331 |
|
decho() |
332 |
|
{ |
333 |
|
# print nothing if debug mode was *not* requested |
334 |
|
[[ ${DEBUG} != 1 ]] && return |
335 |
|
|
336 |
|
eecho "DEBUG: ${@}" |
337 |
} |
} |
338 |
|
|
339 |
path_not_empty() |
path_not_empty() |
340 |
{ |
{ |
341 |
local path="$1" |
local path="$1" |
342 |
[[ -z ${path} ]] && "path_not_empty(): no path given!" && return 1 |
[[ -z ${path} ]] && eecho "path_not_empty(): no path given!" && return 1 |
343 |
|
|
344 |
# return ERR if path does not exist |
# return ERR if path does not exist |
345 |
[[ ! -d ${path} ]] && return 1 |
[[ ! -d ${path} ]] && return 1 |