Magellan Linux

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

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

revision 2421 by niro, Wed Sep 2 09:25:10 2015 UTC revision 2470 by niro, Tue Sep 8 08:30:10 2015 UTC
# Line 14  source ${MCORE_LIBDIR}/include/common.gl Line 14  source ${MCORE_LIBDIR}/include/common.gl
14  include ${MCORE_LIBDIR}/include/daemon.global.class  include ${MCORE_LIBDIR}/include/daemon.global.class
15  include ${MCORE_LIBDIR}/include/sessionauth.global.class  include ${MCORE_LIBDIR}/include/sessionauth.global.class
16  include ${MCORE_LIBDIR}/include/mysqlfunctions.global.class  include ${MCORE_LIBDIR}/include/mysqlfunctions.global.class
17    include ${MCORE_LIBDIR}/include/register.global.class
18    include ${MCORE_LIBDIR}/include/control.global.class
19  #include ${MCORE_LIBDIR}/include/hwdetection.global.class  #include ${MCORE_LIBDIR}/include/hwdetection.global.class
20    
21  # load control classes plugins  # load control classes plugins
22  load_classes control  load_classes control
23    
24  SQL_USER=alx  # config settings
25    include @@SYSCONFDIR@@/mcore/mcore.conf
26    
27    SQL_USER=alx_install
28  SQL_PASS=@lx  SQL_PASS=@lx
29  SQL_HOST=localhost  SQL_HOST=localhost
30  SQL_DB=alx_web  SQL_DB=alx_web
31    
 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}"  
 }  
   
 nsslsay()  
 {  
  nssl "${IP}" "${PORT}" << EOF  
 auth ${SSLSAY_USER} ${SSLSAY_PASS}  
 $@  
 quit  
 EOF  
 }  
   
 control_client()  
 {  
  local serial="$1"  
  local command="${@/$1/}"  
  local IP  
   
  IP=$(mysqldo "select ip from state_connected where serial='${serial}'")  
  if [[ -z ${IP} ]]  
  then  
  echo "no ip found for client '${serial}'"  
  return 1  
  fi  
   
  nsslsay "${command}"  
 }  
   
 #IP="192.168.0.6"  
 PORT="6666"  
 SSLSAY_USER="foo"  
 SSLSAY_PASS="bar"  
   
32  DEBUG=1  DEBUG=1
33  NOCOLORS="false"  NOCOLORS="false"
34  WEBCRLF="false"  WEBCRLF="false"
# Line 103  do Line 62  do
62   get) run_class ;;   get) run_class ;;
63   set) run_class ;;   set) run_class ;;
64   auth) validate_auth ${GLOBAL_ARGV[*]:1} ;;   auth) validate_auth ${GLOBAL_ARGV[*]:1} ;;
65     certauth) validate_auth_certificate ${GLOBAL_ARGV[*]:1} ;;
66     register) valid_session && validate_client ${GLOBAL_ARGV[*]:1} ;;
67   provide) valid_session && print_provide ;;   provide) valid_session && print_provide ;;
68   require) valid_session && verify_requirements ;;   require) valid_session && verify_requirements ;;
69   reload) valid_session && mecho "reloading client classes ..." && load_classes client ;;   reload) valid_session && mecho "reloading client classes ..." && load_classes client ;;
# Line 126  do Line 87  do
87   else   else
88   mecho "You must authenticate yourself first!"   mecho "You must authenticate yourself first!"
89   mecho "  auth [username] [password]"   mecho "  auth [username] [password]"
90     mecho "or"
91     mecho "  certauth [certificate fingerprint]"
92   fi   fi
93   ;;   ;;
94    

Legend:
Removed from v.2421  
changed lines
  Added in v.2470