Magellan Linux

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

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

mcore-src/trunk/mcore-tools/daemon/client/mcored.sh revision 1248 by niro, Wed Feb 2 20:20:24 2011 UTC mcore-src/trunk/mcore-tools/src/mcored.in revision 2269 by niro, Tue Jan 14 10:34:57 2014 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
2    
3  MCLIBDIR="/usr/lib/mcored"  MCORE_LIBDIR="@@MCORE_LIBDIR@@"
4    
5    # respect system env (proxy settings etc)
6    if [ -e @@SYSCONFDIR@@/profile ]
7    then
8     source @@SYSCONFDIR@@/profile
9    fi
10    
11  # globals  # globals
12  source ${MCLIBDIR}/include/daemon.global.class  # include function comes with common.global class
13  source ${MCLIBDIR}/include/sessionauth.global.class  source ${MCORE_LIBDIR}/include/common.global.class
14  source ${MCLIBDIR}/include/mysqlfunctions.global.class  include ${MCORE_LIBDIR}/include/daemon.global.class
15  source ${MCLIBDIR}/include/hwdetection.global.class  include ${MCORE_LIBDIR}/include/sessionauth.global.class
16    #include ${MCORE_LIBDIR}/include/mysqlfunctions.global.class
17    include ${MCORE_LIBDIR}/include/hwdetection.global.class
18    
19  # client specific  # load client classes plugins
20  for i in ${MCLIBDIR}/include/*.client.class  load_client_classes
 do  
  source ${i} || echo "error loading ${i}"  
 done  
21    
22  # config settings  # config settings
23  source /etc/mcore/config.rc  include @@SYSCONFDIR@@/mcore/mcore.conf
24  source /etc/mcore/serial  #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  
25    
26  # if [[ ${DEBUG} = 1 ]]  # import_hardware_resource()
27  # then  # {
28  # echo "${resource}=${value}" >> /root/lala.log  # local resource="$1"
29  # echo "mysqldo \"update status set ${resource}='${value}' where serial=${ALX_SERIAL};\"" >> /root/lala.log  # local value
30  # fi  #
31  # mysql_insert status,serial="${ALX_SERIAL}","${resource}"="${value}"  # # special cases
32    # case ${resource} in
33   import_resource status "${ALX_SERIAL}" "${resource}" "${value}"  # gfxcard) value="$(get_x11_driver_modules)" ;;
34  }  # *) value="$(get_hwinfo --with-description ${resource})" ;;
35    # esac
36    #
37    # # if [[ ${DEBUG} = 1 ]]
38    # # then
39    # # echo "${resource}=${value}" >> /root/lala.log
40    # # echo "mysqldo \"update status set ${resource}='${value}' where serial=${ALX_SERIAL};\"" >> /root/lala.log
41    # # fi
42    # # mysql_insert status,serial="${ALX_SERIAL}","${resource}"="${value}"
43    #
44    # import_resource status "${ALX_SERIAL}" "${resource}" "${value}"
45    # }
46    
47    
48  # set_init_state()  # set_init_state()
# Line 48  import_hardware_resource() Line 53  import_hardware_resource()
53  # }  # }
54    
55  DEBUG=1  DEBUG=1
56    NOCOLORS="false"
57    WEBCRLF="false"
58    QUIET="false"
59    
60    # argvs are global variables - this fixes issues with whitespaces
61    # global argvs, the whole command line
62    export GLOBAL_ARGV
63    # class specific argvs which are given to the class as parameters
64    export CLASS_ARGV
65    
66  run=run  run=run
67  valid_session=no  valid_session=no
68    
69    # tell what we are
70    echo "Connected to $(print_version)"
71    
72  while [[ ${run} = run ]]  while [[ ${run} = run ]]
73  do  do
74   read line   read line
75     eval "GLOBAL_ARGV=( ${line} )"
76    
77   case ${line} in   case ${GLOBAL_ARGV[0]} in
78   quit) run=quit ;;   quit) run=quit ;;
79    
80   # only react on the globals -> import|get|set|auth   # only react on the globals -> import|get|set|auth
81   import*) run_class ${line} ;;   import) run_class ;;
82   get*) run_class ${line} ;;   get) run_class ;;
83   set*) run_class ${line} ;;   set) run_class ;;
84   auth*) validate_auth ${line/auth /} ;;   auth) validate_auth ${GLOBAL_ARGV[*]:1} ;;
85   provide) print_provide ;;   provide) valid_session && print_provide ;;
86   help*)   require) valid_session && verify_requirements ;;
87   if validate_session   reload) valid_session && mecho "reloading client classes ..." && load_client_classes ;;
88     restart) valid_session && restart_service ;;
89     stop) valid_session && stop_service ;;
90     nocolors) export NOCOLORS="true" ;;
91     colors) export NOCOLORS="false" ;;
92     webcrlf) export WEBCRLF="true" ;;
93     quiet) export QUIET="true" ;;
94     # version does not need auth
95     version) print_version ;;
96     help)
97     if valid_session
98   then   then
99   if [[ ${line} = help ]]   if [[ ${line} = help ]]
100   then   then
# Line 81  do Line 109  do
109   ;;   ;;
110    
111   *)   *)
112   mecho "Unkown command '${line}'"   mecho "Unknown command '${line}'"
113   mecho "Type 'help' for more information."   mecho "Type 'help' for more information."
114   echo "$line" >> /root/lala.log   #echo "$line" >> /root/lala.log
115   ;;   ;;
116   esac   esac
117    
118     # unset argvs to be safe
119     unset GLOBAL_ARGS
120     unset CLASS_ARGS
121  done  done

Legend:
Removed from v.1248  
changed lines
  Added in v.2269