Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2465 - (show annotations) (download)
Tue Sep 8 08:23:28 2015 UTC (8 years, 7 months ago) by niro
File size: 2916 byte(s)
-moved import_resource() to control.global.class
1 #!/bin/sh
2
3 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
12 # include function comes with common.global class
13 source ${MCORE_LIBDIR}/include/common.global.class
14 include ${MCORE_LIBDIR}/include/daemon.global.class
15 include ${MCORE_LIBDIR}/include/sessionauth.global.class
16 include ${MCORE_LIBDIR}/include/mysqlfunctions.global.class
17 include ${MCORE_LIBDIR}/include/register.global.class
18 #include ${MCORE_LIBDIR}/include/hwdetection.global.class
19
20 # load control classes plugins
21 load_classes control
22
23 # config settings
24 include @@SYSCONFDIR@@/mcore/mcore.conf
25
26 SQL_USER=alx_install
27 SQL_PASS=@lx
28 SQL_HOST=localhost
29 SQL_DB=alx_web
30
31 control_client()
32 {
33 local serial="$1"
34 local command="${@/$1/}"
35 local IP
36
37 IP=$(mysqldo "select ip from state_connected where serial='${serial}'")
38 if [[ -z ${IP} ]]
39 then
40 echo "no ip found for client '${serial}'"
41 return 1
42 fi
43
44 nsslsay "${command}"
45 }
46
47 #IP="192.168.0.6"
48 PORT="6666"
49 SSLSAY_USER="foo"
50 SSLSAY_PASS="bar"
51
52 DEBUG=1
53 NOCOLORS="false"
54 WEBCRLF="false"
55 QUIET="false"
56
57 # argvs are global variables - this fixes issues with whitespaces
58 # global argvs, the whole command line
59 export GLOBAL_ARGV
60 # class specific argvs which are given to the class as parameters
61 export CLASS_ARGV
62
63 run=run
64 valid_session=no
65
66 # tell what we are
67 echo "Connected to $(print_version)"
68
69 while [[ ${run} = run ]]
70 do
71 # use an echo here not read -p '>' because sslsvd ignores the prompt pattern
72 echo -n '> '
73 read line
74 eval "GLOBAL_ARGV=( ${line} )"
75
76 case ${GLOBAL_ARGV[0]} in
77 quit) run=quit ;;
78
79 # only react on the globals -> import|get|set|auth
80 import) run_class ;;
81 control) run_class ;;
82 get) run_class ;;
83 set) run_class ;;
84 auth) validate_auth ${GLOBAL_ARGV[*]:1} ;;
85 certauth) validate_auth_certificate ${GLOBAL_ARGV[*]:1} ;;
86 register) valid_session && validate_client ${GLOBAL_ARGV[*]:1} ;;
87 provide) valid_session && print_provide ;;
88 require) valid_session && verify_requirements ;;
89 reload) valid_session && mecho "reloading client classes ..." && load_classes client ;;
90 restart) valid_session && restart_service ;;
91 stop) valid_session && stop_service ;;
92 nocolors) export NOCOLORS="true" ;;
93 colors) export NOCOLORS="false" ;;
94 webcrlf) export WEBCRLF="true" ;;
95 quiet) export QUIET="true" ;;
96 # version does not need auth
97 version) print_version ;;
98 help)
99 if valid_session
100 then
101 if [[ ${line} = help ]]
102 then
103 help_topics
104 else
105 run_class ${line}
106 fi
107 else
108 mecho "You must authenticate yourself first!"
109 mecho " auth [username] [password]"
110 mecho "or"
111 mecho " certauth [certificate fingerprint]"
112 fi
113 ;;
114
115 *)
116 mecho "Unknown command '${line}'"
117 mecho "Type 'help' for more information."
118 #echo "$line" >> /root/lala.log
119 ;;
120 esac
121
122 # unset argvs to be safe
123 unset GLOBAL_ARGS
124 unset CLASS_ARGS
125 done

Properties

Name Value
svn:executable *