#!/bin/bash MCORE_LIBDIR="@@MCORE_LIBDIR@@" # respect system env (proxy settings etc) if [ -e @@SYSCONFDIR@@/profile ] then source @@SYSCONFDIR@@/profile fi # globals source ${MCORE_LIBDIR}/include/common.global.class source ${MCORE_LIBDIR}/include/daemon.global.class source ${MCORE_LIBDIR}/include/sessionauth.global.class #source ${MCORE_LIBDIR}/include/mysqlfunctions.global.class source ${MCORE_LIBDIR}/include/hwdetection.global.class # load client classes plugins load_client_classes # config settings source @@SYSCONFDIR@@/mcore/mcore.conf #source @@SYSCONFDIR@@/mcore/serial # import_hardware_resource() # { # local resource="$1" # local value # # # special cases # case ${resource} in # gfxcard) value="$(get_x11_driver_modules)" ;; # *) value="$(get_hwinfo --with-description ${resource})" ;; # esac # # # if [[ ${DEBUG} = 1 ]] # # then # # echo "${resource}=${value}" >> /root/lala.log # # echo "mysqldo \"update status set ${resource}='${value}' where serial=${ALX_SERIAL};\"" >> /root/lala.log # # fi # # mysql_insert status,serial="${ALX_SERIAL}","${resource}"="${value}" # # import_resource status "${ALX_SERIAL}" "${resource}" "${value}" # } # set_init_state() # { # local ip # ip=$(ifconfig | grep -A1 eth0 | grep inet | sed 's/.*inet\ addr:\(.*\) Bcast.*/\1/;') # # } DEBUG=1 NOCOLORS="false" WEBCRLF="false" QUIET="false" run=run valid_session=no # tell what we are echo "Connected to $(print_version)" while [[ ${run} = run ]] do read line case ${line} in quit) run=quit ;; # only react on the globals -> import|get|set|auth import*) run_class ${line} ;; get*) run_class ${line} ;; set*) run_class ${line} ;; auth*) validate_auth ${line/auth /} ;; provide) valid_session && print_provide ;; require) valid_session && verify_requirements ;; reload) valid_session && mecho "reloading client classes ..." && load_client_classes ;; restart) valid_session && restart_service ;; stop) valid_session && stop_service ;; nocolors) export NOCOLORS="true" ;; colors) export NOCOLORS="false" ;; webcrlf) export WEBCRLF="true" ;; quiet) export QUIET="true" ;; # version does not need auth version) print_version ;; help*) if valid_session then if [[ ${line} = help ]] then help_topics else run_class ${line} fi else mecho "You must authenticate yourself first!" mecho " auth [username] [password]" fi ;; *) mecho "Unknown command '${line}'" mecho "Type 'help' for more information." #echo "$line" >> /root/lala.log ;; esac done