# $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() # { # local table="$1" # local serial="$2" # local resource="$3" # local value="$4" # # if [[ ${DEBUG} = 1 ]] # then # echo "${table}->${resource}=${value}" >> /root/lala.log # echo "mysqldo \"update ${table} set ${resource}='${value}' where serial=${serial};\"" >> /root/lala.log # fi # # mysql_insert "${table}",serial="${serial}","${resource}"="${value}" # } # run_class $method $caller $argv1 $argv2 ... $argvN run_class() { local method="$1" local caller="$2" local class local cmd local argv if valid_session then class="${caller%.*}" cmd="${caller#*.}" argv="${@/${caller}/}" # remove caller argv="${argv/${method}/}" # remove method # echo "method=${method}" # echo "caller=${caller}" # echo "class=${class}" # echo "cmd=${cmd}" # echo "argv=${argv}" # check if class.cmd exist if [[ ! -z $(typeset -f "${method}"_"${class}"_"${cmd}") ]] then "${method}"_"${class}"_"${cmd}" ${argv} else eecho "unkown method '${method}' . class '${class}' . cmd '${cmd}'" fi else invalid_session fi } help_topics() { local i local topics topics=$(typeset -f | grep '^help_' | sed 's:help_\(.*\)\ .*():\1:' | sed 's:_:\.:' | sort) mecho "Global commands:" mecho "\timport - import settings to database" mecho "\tget - shows current value for a settings" mecho "\tset - sets value for a setting" 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:" for i in ${topics} do # excludes case ${i} in help_topics|topics) continue ;; esac mecho "\t${i}" done mecho mecho "Type 'help [topic]' for more information about every topic." } require() { local requires="$@" local i for i in ${requires} do # check for duplicate provides if no_duplicate "${PROVIDE}" "${i}" then export REQUIRE="${REQUIRE} ${i}" else decho "duplicate provide '${i}' detected!" fi done } verify_requirements() { local req local prov local missing local sorted for req in ${REQUIRE} do # scan PROVIDE for dupes # if a dupe is found, then requirement is fullfilled # else add to missing if no_duplicate "${PROVIDE}" "${req}" then missing="${missing} ${req}" fi done # sort them alpabetically sorted=$(for i in ${REQUIRE}; do echo "${i}"; done | sort) # show missing and set the right retval if [[ -z ${missing} ]] then # do not escape, or CRLFS get printed to screen too rvecho ${sorted} return 0 else for req in ${sorted} do if no_duplicate "${missing}" "$req" then # print normal rvecho -n "${req} " else # print missing eecho -n "${req} " fi done # print CRLF echo return 1 fi } provide() { local provides="$@" local i for i in ${provides} do # check for duplicate provides if no_duplicate "${PROVIDE}" "${i}" then export PROVIDE="${PROVIDE} ${i}" else decho "duplicate provide '${i}' detected!" fi done } print_provide() { local sorted # sort them alpabetically sorted=$(for i in ${PROVIDE}; do echo "${i}"; done | sort) # do not escape, or CRLFS get printed to screen too rvecho ${sorted} } help_daemon_mroot() { mecho "get daemon.mroot" mecho " Prints current MROOT variable." mecho mecho "set daemon.mroot [path]" mecho " set MROOT variable to given path." } get_daemon_mroot() { rvecho "${MROOT}" } set_daemon_mroot() { local path=$1 if [[ -d ${path} ]] then export MROOT="${path}" decho "MROOT='${MROOT}' is set." else eecho "Path '${path}' does not exist. MROOT not set." fi } print_version() { echo "mcored-$(<${MCORE_LIBDIR}/VERSION)" }