#!/bin/bash MCORE_LIBDIR="@@MCORE_LIBDIR@@" # respect system env (proxy settings etc) if [ -e @@SYSCONFDIR@@/profile ] then source @@SYSCONFDIR@@/profile fi # globals # include function comes with common.global class source ${MCORE_LIBDIR}/include/common.global.class include ${MCORE_LIBDIR}/include/daemon.global.class include ${MCORE_LIBDIR}/include/sessionauth.global.class include ${MCORE_LIBDIR}/include/register.global.class include ${MCORE_LIBDIR}/include/hwdetection.global.class # load client classes plugins load_classes client # config settings include @@SYSCONFDIR@@/mcore/mcore.conf # 0=false, 1=true DEBUG=1 NOCOLORS=0 WEBCRLF=0 QUIET=0 # daemon silent mode, read from env : ${SILENT=0} # argvs are global variables - this fixes issues with whitespaces # global argvs, the whole command line export GLOBAL_ARGV # class specific argvs which are given to the class as parameters export CLASS_ARGV run=run valid_session=no # tell what we are [[ ${SILENT} = 1 ]] || echo "Connected to $(print_version)" while [[ ${run} = run ]] do # use an echo here not read -p '>' because sslsvd ignores the prompt pattern [[ ${SILENT} = 1 ]] || echo -n '> ' read line eval "GLOBAL_ARGV=( ${line} )" case ${GLOBAL_ARGV[0]} in quit) run=quit ;; # only react on the globals -> import|get|set|auth import) run_class ;; get) run_class ;; set) run_class ;; auth) validate_auth ${GLOBAL_ARGV[*]:1} ;; certauth) validate_auth_certificate ${GLOBAL_ARGV[*]:1} ;; register) valid_session && register_client_local ${GLOBAL_ARGV[*]:1} ;; provide) valid_session && print_provide ;; require) valid_session && verify_requirements ;; reload) valid_session && mecho "reloading client classes ..." && load_classes client ;; restart) valid_session && restart_service ;; stop) valid_session && stop_service ;; nocolors) export NOCOLORS=1 ;; colors) export NOCOLORS=0 ;; webcrlf) export WEBCRLF=1 ;; quiet) export QUIET=1 ;; # 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]" mecho "or" mecho " certauth [certificate fingerprint]" fi ;; *) mecho "Unknown command '${line}'" mecho "Type 'help' for more information." #echo "$line" >> /root/lala.log ;; esac # unset argvs to be safe unset GLOBAL_ARGS unset CLASS_ARGS done