Magellan Linux

Diff of /mcore-src/trunk/mcore-tools/src/mcored.in

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2212 by niro, Fri Jan 10 23:19:49 2014 UTC revision 2479 by niro, Thu Sep 10 08:48:45 2015 UTC
# Line 9  then Line 9  then
9  fi  fi
10    
11  # globals  # globals
12    # include function comes with common.global class
13  source ${MCORE_LIBDIR}/include/common.global.class  source ${MCORE_LIBDIR}/include/common.global.class
14  source ${MCORE_LIBDIR}/include/daemon.global.class  include ${MCORE_LIBDIR}/include/daemon.global.class
15  source ${MCORE_LIBDIR}/include/sessionauth.global.class  include ${MCORE_LIBDIR}/include/sessionauth.global.class
16  #source ${MCORE_LIBDIR}/include/mysqlfunctions.global.class  include ${MCORE_LIBDIR}/include/register.global.class
17  source ${MCORE_LIBDIR}/include/hwdetection.global.class  include ${MCORE_LIBDIR}/include/hwdetection.global.class
18    
19  # load client classes plugins  # load client classes plugins
20  load_client_classes  load_classes client
21    
22  # config settings  # config settings
23  source @@SYSCONFDIR@@/mcore/mcore.conf  include @@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/;')  
 #  
 # }  
24    
25    # 0=false, 1=true
26  DEBUG=1  DEBUG=1
27  NOCOLORS="false"  NOCOLORS=0
28  WEBCRLF="false"  WEBCRLF=0
29  QUIET="false"  QUIET=0
30    
31    # argvs are global variables - this fixes issues with whitespaces
32    # global argvs, the whole command line
33    export GLOBAL_ARGV
34    # class specific argvs which are given to the class as parameters
35    export CLASS_ARGV
36    
37  run=run  run=run
38  valid_session=no  valid_session=no
# Line 64  echo "Connected to $(print_version)" Line 42  echo "Connected to $(print_version)"
42    
43  while [[ ${run} = run ]]  while [[ ${run} = run ]]
44  do  do
45     # use an echo here not read -p '>' because sslsvd ignores the prompt pattern
46     echo -n '> '
47   read line   read line
48     eval "GLOBAL_ARGV=( ${line} )"
49    
50   case ${line} in   case ${GLOBAL_ARGV[0]} in
51   quit) run=quit ;;   quit) run=quit ;;
52    
53   # only react on the globals -> import|get|set|auth   # only react on the globals -> import|get|set|auth
54   import*) run_class ${line} ;;   import) run_class ;;
55   get*) run_class ${line} ;;   get) run_class ;;
56   set*) run_class ${line} ;;   set) run_class ;;
57   auth*) validate_auth ${line/auth /} ;;   auth) validate_auth ${GLOBAL_ARGV[*]:1} ;;
58     certauth) validate_auth_certificate ${GLOBAL_ARGV[*]:1} ;;
59     register) valid_session && register_client_local ${GLOBAL_ARGV[*]:1} ;;
60   provide) valid_session && print_provide ;;   provide) valid_session && print_provide ;;
61   require) valid_session && verify_requirements ;;   require) valid_session && verify_requirements ;;
62   reload) valid_session && mecho "reloading client classes ..." && load_client_classes ;;   reload) valid_session && mecho "reloading client classes ..." && load_classes client ;;
63   restart) valid_session && restart_service ;;   restart) valid_session && restart_service ;;
64   stop) valid_session && stop_service ;;   stop) valid_session && stop_service ;;
65   nocolors) export NOCOLORS="true" ;;   nocolors) export NOCOLORS=1 ;;
66   colors) export NOCOLORS="false" ;;   colors) export NOCOLORS=0 ;;
67   webcrlf) export WEBCRLF="true" ;;   webcrlf) export WEBCRLF=1 ;;
68   quiet) export QUIET="true" ;;   quiet) export QUIET=1 ;;
69   # version does not need auth   # version does not need auth
70   version) print_version ;;   version) print_version ;;
71   help*)   help)
72   if valid_session   if valid_session
73   then   then
74   if [[ ${line} = help ]]   if [[ ${line} = help ]]
# Line 97  do Line 80  do
80   else   else
81   mecho "You must authenticate yourself first!"   mecho "You must authenticate yourself first!"
82   mecho "  auth [username] [password]"   mecho "  auth [username] [password]"
83     mecho "or"
84     mecho "  certauth [certificate fingerprint]"
85   fi   fi
86   ;;   ;;
87    
88   *)   *)
89   mecho "Unkown command '${line}'"   mecho "Unknown command '${line}'"
90   mecho "Type 'help' for more information."   mecho "Type 'help' for more information."
91   #echo "$line" >> /root/lala.log   #echo "$line" >> /root/lala.log
92   ;;   ;;
93   esac   esac
94    
95     # unset argvs to be safe
96     unset GLOBAL_ARGS
97     unset CLASS_ARGS
98  done  done

Legend:
Removed from v.2212  
changed lines
  Added in v.2479