44 |
then |
then |
45 |
"${method}"_"${class}"_"${cmd}" ${argv} |
"${method}"_"${class}"_"${cmd}" ${argv} |
46 |
else |
else |
47 |
echo "unkown method '${method}' . class '${class}' . cmd '${cmd}'" |
eecho "unkown method '${method}' . class '${class}' . cmd '${cmd}'" |
48 |
fi |
fi |
49 |
else |
else |
50 |
invalid_session |
invalid_session |
58 |
|
|
59 |
topics=$(typeset -f | grep '^help_' | sed 's:help_\(.*\)\ .*():\1:' | sed 's:_:\.:' | sort) |
topics=$(typeset -f | grep '^help_' | sed 's:help_\(.*\)\ .*():\1:' | sed 's:_:\.:' | sort) |
60 |
mecho "Global commands:" |
mecho "Global commands:" |
61 |
mecho "\timport - import settings to database" |
mecho "\timport - import settings to database" |
62 |
mecho "\tget - shows current value for a settings" |
mecho "\tget - shows current value for a settings" |
63 |
mecho "\tset - sets value for a setting" |
mecho "\tset - sets value for a setting" |
64 |
mecho "\tauth - authenticate to the daemon" |
mecho "\tauth - authenticate to the daemon" |
65 |
mecho "\tprovide - shows provides of a system" |
mecho "\tprovide - shows provides of a system" |
66 |
mecho "\trequire - verify plugin requirements" |
mecho "\trequire - verify plugin requirements" |
67 |
mecho "\tnocolors - disable colors, useful for the webclient" |
mecho "\tnocolors - disable colors, useful for the webclient" |
68 |
mecho "\thelp - shows help" |
mecho "\tquiet - do not print any unecessary messages" |
69 |
mecho "\tquit - quits the connection to the server" |
mecho "\thelp - shows help" |
70 |
|
mecho "\tquit - quits the connection to the server" |
71 |
mecho |
mecho |
72 |
mecho "Help topics:" |
mecho "Help topics:" |
73 |
for i in ${topics} |
for i in ${topics} |
86 |
# 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 |
87 |
x11runas() |
x11runas() |
88 |
{ |
{ |
89 |
su - "${MCORE_UNPRIV_USER}" -c "DISPLAY=${MCORE_XORG_DISPLAY} $@" |
if [[ -n $(pidof X) ]] |
90 |
|
then |
91 |
|
su - "${MCORE_UNPRIV_USER}" -c "DISPLAY=${MCORE_XORG_DISPLAY} $@" |
92 |
|
fi |
93 |
} |
} |
94 |
|
|
95 |
addconfig() |
addconfig() |
98 |
|
|
99 |
if [[ -z ${CONFIG} ]] |
if [[ -z ${CONFIG} ]] |
100 |
then |
then |
101 |
echo "You must define \$CONFIG varibale first!" |
eecho "You must define \$CONFIG varibale first!" |
102 |
return 1 |
return 1 |
103 |
fi |
fi |
104 |
|
|
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 |
|
|
158 |
then |
then |
159 |
export REQUIRE="${REQUIRE} ${i}" |
export REQUIRE="${REQUIRE} ${i}" |
160 |
else |
else |
161 |
[[ ${DEBUG} = 1 ]] && echo "duplicate provide '${i}' detected!" |
decho "duplicate provide '${i}' detected!" |
162 |
fi |
fi |
163 |
done |
done |
164 |
} |
} |
187 |
# show missing and set the right retval |
# show missing and set the right retval |
188 |
if [[ -z ${missing} ]] |
if [[ -z ${missing} ]] |
189 |
then |
then |
190 |
mecho "${sorted}" |
rvecho "${sorted}" |
191 |
return 0 |
return 0 |
192 |
else |
else |
193 |
for req in ${sorted} |
for req in ${sorted} |
195 |
if no_duplicate "${missing}" "$req" |
if no_duplicate "${missing}" "$req" |
196 |
then |
then |
197 |
# print normal |
# print normal |
198 |
mecho -n " ${req}" |
rvecho -n " ${req}" |
199 |
else |
else |
200 |
# print missing |
# print missing |
201 |
eecho -n " ${req}" |
eecho -n " ${req}" |
217 |
then |
then |
218 |
export PROVIDE="${PROVIDE} ${i}" |
export PROVIDE="${PROVIDE} ${i}" |
219 |
else |
else |
220 |
[[ ${DEBUG} = 1 ]] && echo "duplicate provide '${i}' detected!" |
decho "duplicate provide '${i}' detected!" |
221 |
fi |
fi |
222 |
done |
done |
223 |
} |
} |
229 |
# sort them alpabetically |
# sort them alpabetically |
230 |
sorted=$(for i in ${PROVIDE}; do echo "${i}"; done | sort) |
sorted=$(for i in ${PROVIDE}; do echo "${i}"; done | sort) |
231 |
# do not escape, or CRLFS get printed to screen too |
# do not escape, or CRLFS get printed to screen too |
232 |
mecho ${sorted} |
rvecho ${sorted} |
233 |
} |
} |
234 |
|
|
235 |
|
# message only echo | disabled in quiet mode |
236 |
mecho() |
mecho() |
237 |
{ |
{ |
238 |
local COLCYAN="\033[1;36m" |
local COLCYAN="\033[1;36m" |
240 |
local opts |
local opts |
241 |
local webcrlf |
local webcrlf |
242 |
|
|
243 |
|
# print nothing if quiet mode was requested |
244 |
|
[[ ${QUIET} = true ]] && return |
245 |
|
|
246 |
if [[ ${NOCOLORS} = true ]] |
if [[ ${NOCOLORS} = true ]] |
247 |
then |
then |
248 |
COLCYAN="" |
COLCYAN="" |
259 |
echo -e${opts} "${COLCYAN}$@${COLDEFAULT}${webcrlf}" |
echo -e${opts} "${COLCYAN}$@${COLDEFAULT}${webcrlf}" |
260 |
} |
} |
261 |
|
|
262 |
|
# prints error messages | enabled even in quiet mode |
263 |
eecho() |
eecho() |
264 |
{ |
{ |
265 |
local COLRED="\033[1;31m" |
local COLRED="\033[1;31m" |
283 |
echo -e${opts} "${COLRED}$@${COLDEFAULT}${webcrlf}" |
echo -e${opts} "${COLRED}$@${COLDEFAULT}${webcrlf}" |
284 |
} |
} |
285 |
|
|
286 |
|
# prints return values of get | enabled even in quiet mode |
287 |
|
rvecho() |
288 |
|
{ |
289 |
|
local COLPURPLE="\033[1;35m" |
290 |
|
local COLDEFAULT="\033[0m" |
291 |
|
local opts |
292 |
|
local webcrlf |
293 |
|
|
294 |
|
if [[ ${NOCOLORS} = true ]] |
295 |
|
then |
296 |
|
COLPURPLE="" |
297 |
|
COLDEFAULT="" |
298 |
|
fi |
299 |
|
|
300 |
|
[[ ${WEBCRLF} = true ]] && webcrlf="<br>" |
301 |
|
|
302 |
|
# respect -n |
303 |
|
case $1 in |
304 |
|
-n) shift; opts="n" ;; |
305 |
|
esac |
306 |
|
|
307 |
|
echo -e${opts} "${COLPURPLE}$@${COLDEFAULT}${webcrlf}" |
308 |
|
} |
309 |
|
|
310 |
|
# prints debug messages if requested | enabled even in quiet mode |
311 |
|
decho() |
312 |
|
{ |
313 |
|
# print nothing if debug mode was *not* requested |
314 |
|
[[ ${DEBUG} != 1 ]] && return |
315 |
|
|
316 |
|
eecho "DEBUG: ${@}" |
317 |
|
} |
318 |
|
|
319 |
path_not_empty() |
path_not_empty() |
320 |
{ |
{ |
321 |
local path="$1" |
local path="$1" |
322 |
[[ -z ${path} ]] && "path_not_empty(): no path given!" && return 1 |
[[ -z ${path} ]] && eecho "path_not_empty(): no path given!" && return 1 |
323 |
|
|
324 |
# return ERR if path does not exist |
# return ERR if path does not exist |
325 |
[[ ! -d ${path} ]] && return 1 |
[[ ! -d ${path} ]] && return 1 |