--- mcore-src/trunk/mcore-tools/daemon/include/daemon.global.class 2011/02/17 21:42:57 1350
+++ mcore-src/trunk/mcore-tools/src/include/daemon.global.class.in 2014/01/13 09:27:41 2243
@@ -1,5 +1,39 @@
# $Id$
+# loads client classes from $MCORE_LIBDIR
+load_client_classes()
+{
+ local i
+
+ # client specific
+ for i in $(find ${MCORE_LIBDIR}/include -type f -name \*.client.class)
+ do
+ source ${i} || eecho "error loading ${i}"
+ done
+}
+
+# restarts the whole service via remote cmd
+restart_service()
+{
+ local pid
+ for pid in $(pidof sslsvd)
+ do
+ kill -SIGHUP ${pid}
+ done
+}
+
+# stops the whole service via remote cmd
+stop_service()
+{
+ local pid
+ for pid in $(pidof sslsvd)
+ do
+ kill -15 ${pid}
+ sleep 1
+ kill -9 ${pid}
+ done
+}
+
# # import_resource $table $serial $resource $value
# import_resource()
# {
@@ -44,7 +78,7 @@
then
"${method}"_"${class}"_"${cmd}" ${argv}
else
- echo "unkown method '${method}' . class '${class}' . cmd '${cmd}'"
+ eecho "unknown method '${method}' . class '${class}' . cmd '${cmd}'"
fi
else
invalid_session
@@ -64,8 +98,14 @@
mecho "\tauth - authenticate to the daemon"
mecho "\tprovide - shows provides of a system"
mecho "\trequire - verify plugin requirements"
+ mecho "\treload - reloads all client classes plugins"
+ mecho "\trestart - restarts the daemon"
+ mecho "\tstop - stops the daemon"
mecho "\tnocolors - disable colors, useful for the webclient"
+ mecho "\tcolors - enable colors"
+ mecho "\tquiet - do not print any unecessary messages"
mecho "\thelp - shows help"
+ mecho "\tversion - prints version of the daemon"
mecho "\tquit - quits the connection to the server"
mecho
mecho "Help topics:"
@@ -82,66 +122,6 @@
mecho "Type 'help [topic]' for more information about every topic."
}
-# on newer xorg-servers root is not allowed to run progs in a user session
-x11runas()
-{
- su - "${MCORE_UNPRIV_USER}" -c "DISPLAY=${MCORE_XORG_DISPLAY} $@"
-}
-
-addconfig()
-{
- local opts
-
- if [[ -z ${CONFIG} ]]
- then
- echo "You must define \$CONFIG varibale first!"
- return 1
- fi
-
- if [[ ! -d $(dirname ${CONFIG}) ]]
- then
- install -d $(dirname ${CONFIG})
- fi
-
- # check for opts
- case $1 in
- -n) shift; opts=" -n" ;;
- -e) shift; opts=" -e" ;;
- esac
-
- echo ${opts} "$@" >> ${CONFIG}
-}
-
-clearconfig()
-{
- if [[ -z ${CONFIG} ]]
- then
- echo "You must define \$CONFIG varibale first!"
- return 1
- fi
-
- if [[ ! -d $(dirname ${CONFIG}) ]]
- then
- install -d $(dirname ${CONFIG})
- fi
- : > ${CONFIG}
-}
-
-# no_duplicate $list $item
-no_duplicate()
-{
- local i
- local list="$1"
- local item="$2"
-
- for i in ${list}
- do
- [[ ${i} = ${item} ]] && return 1
- done
-
- return 0
-}
-
require()
{
local requires="$@"
@@ -154,7 +134,7 @@
then
export REQUIRE="${REQUIRE} ${i}"
else
- [[ ${DEBUG} = 1 ]] && echo "duplicate provide '${i}' detected!"
+ decho "duplicate provide '${i}' detected!"
fi
done
}
@@ -183,7 +163,8 @@
# show missing and set the right retval
if [[ -z ${missing} ]]
then
- mecho "${sorted}"
+ # do not escape, or CRLFS get printed to screen too
+ rvecho ${sorted}
return 0
else
for req in ${sorted}
@@ -191,12 +172,14 @@
if no_duplicate "${missing}" "$req"
then
# print normal
- mecho -n " ${req}"
+ rvecho -n "${req} "
else
# print missing
- eecho -n " ${req}"
+ eecho -n "${req} "
fi
done
+ # print CRLF
+ echo
return 1
fi
}
@@ -213,7 +196,7 @@
then
export PROVIDE="${PROVIDE} ${i}"
else
- [[ ${DEBUG} = 1 ]] && echo "duplicate provide '${i}' detected!"
+ decho "duplicate provide '${i}' detected!"
fi
done
}
@@ -225,65 +208,37 @@
# sort them alpabetically
sorted=$(for i in ${PROVIDE}; do echo "${i}"; done | sort)
# do not escape, or CRLFS get printed to screen too
- mecho ${sorted}
+ rvecho ${sorted}
}
-mecho()
+help_daemon_mroot()
{
- local COLCYAN="\033[1;36m"
- local COLDEFAULT="\033[0m"
- local opts
- local webcrlf
-
- if [[ ${NOCOLORS} = true ]]
- then
- COLCYAN=""
- COLDEFAULT=""
- fi
-
- [[ ${WEBCRLF} = true ]] && webcrlf="
"
-
- # respect -n
- case $1 in
- -n) shift; opts="n" ;;
- esac
+ mecho "get daemon.mroot"
+ mecho " Prints current MROOT variable."
+ mecho
+ mecho "set daemon.mroot [path]"
+ mecho " set MROOT variable to given path."
+}
- echo -e${opts} "${COLCYAN}$@${COLDEFAULT}${webcrlf}"
+get_daemon_mroot()
+{
+ rvecho "${MROOT}"
}
-eecho()
+set_daemon_mroot()
{
- local COLRED="\033[1;31m"
- local COLDEFAULT="\033[0m"
- local opts
- local webcrlf
+ local path=$1
- if [[ ${NOCOLORS} = true ]]
+ if [[ -d ${path} ]]
then
- COLRED=""
- COLDEFAULT=""
+ export MROOT="${path}"
+ decho "MROOT='${MROOT}' is set."
+ else
+ eecho "Path '${path}' does not exist. MROOT not set."
fi
-
- [[ ${WEBCRLF} = true ]] && webcrlf="
"
-
- # respect -n
- case $1 in
- -n) shift; opts="n" ;;
- esac
-
- echo -e${opts} "${COLRED}$@${COLDEFAULT}${webcrlf}"
}
-path_not_empty()
+print_version()
{
- local path="$1"
- [[ -z ${path} ]] && "path_not_empty(): no path given!" && return 1
-
- # return ERR if path does not exist
- [[ ! -d ${path} ]] && return 1
- # return ERR if path empty
- [[ -z $(find "${path}" -mindepth 1 -maxdepth 1) ]] && return 1
-
- # every thing went ok, directory not empty
- return 0
+ echo "mcored-$(<${MCORE_LIBDIR}/VERSION)"
}