Annotation of /mcore-src/trunk/mcore-tools/src/mcore-controld.in
Parent Directory | Revision Log
Revision 2444 -
(hide annotations)
(download)
Thu Sep 3 13:33:30 2015 UTC (9 years ago) by niro
File size: 3376 byte(s)
Thu Sep 3 13:33:30 2015 UTC (9 years ago) by niro
File size: 3376 byte(s)
-fixed sql_user
1 | niro | 2051 | #!/bin/sh |
2 | |||
3 | niro | 2304 | 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 | niro | 2051 | # globals |
12 | niro | 2304 | # 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 | niro | 2440 | include ${MCORE_LIBDIR}/include/register.global.class |
18 | niro | 2304 | #include ${MCORE_LIBDIR}/include/hwdetection.global.class |
19 | niro | 2051 | |
20 | niro | 2304 | # load control classes plugins |
21 | load_classes control | ||
22 | niro | 2051 | |
23 | niro | 2438 | # config settings |
24 | include @@SYSCONFDIR@@/mcore/mcore.conf | ||
25 | |||
26 | niro | 2444 | SQL_USER=alx_install |
27 | niro | 2051 | SQL_PASS=@lx |
28 | SQL_HOST=localhost | ||
29 | SQL_DB=alx_web | ||
30 | |||
31 | import_resource() | ||
32 | { | ||
33 | local table="$1" | ||
34 | local serial="$2" | ||
35 | local resource="$3" | ||
36 | local value="$4" | ||
37 | |||
38 | if [[ ${DEBUG} = 1 ]] | ||
39 | then | ||
40 | echo "${table}->${resource}=${value}" >> /root/lala.log | ||
41 | echo "mysqldo \"update ${table} set ${resource}='${value}' where serial=${serial};\"" >> /root/lala.log | ||
42 | fi | ||
43 | |||
44 | mysql_insert "${table}",serial="${serial}","${resource}"="${value}" | ||
45 | } | ||
46 | |||
47 | nsslsay() | ||
48 | { | ||
49 | nssl "${IP}" "${PORT}" << EOF | ||
50 | auth ${SSLSAY_USER} ${SSLSAY_PASS} | ||
51 | $@ | ||
52 | quit | ||
53 | EOF | ||
54 | } | ||
55 | |||
56 | control_client() | ||
57 | { | ||
58 | local serial="$1" | ||
59 | local command="${@/$1/}" | ||
60 | local IP | ||
61 | |||
62 | IP=$(mysqldo "select ip from state_connected where serial='${serial}'") | ||
63 | if [[ -z ${IP} ]] | ||
64 | then | ||
65 | echo "no ip found for client '${serial}'" | ||
66 | return 1 | ||
67 | fi | ||
68 | |||
69 | nsslsay "${command}" | ||
70 | } | ||
71 | |||
72 | #IP="192.168.0.6" | ||
73 | PORT="6666" | ||
74 | SSLSAY_USER="foo" | ||
75 | SSLSAY_PASS="bar" | ||
76 | |||
77 | niro | 2304 | DEBUG=1 |
78 | NOCOLORS="false" | ||
79 | WEBCRLF="false" | ||
80 | QUIET="false" | ||
81 | |||
82 | # argvs are global variables - this fixes issues with whitespaces | ||
83 | # global argvs, the whole command line | ||
84 | export GLOBAL_ARGV | ||
85 | # class specific argvs which are given to the class as parameters | ||
86 | export CLASS_ARGV | ||
87 | |||
88 | niro | 2051 | run=run |
89 | valid_session=no | ||
90 | |||
91 | niro | 2304 | # tell what we are |
92 | echo "Connected to $(print_version)" | ||
93 | |||
94 | niro | 2051 | while [[ ${run} = run ]] |
95 | do | ||
96 | niro | 2421 | # use an echo here not read -p '>' because sslsvd ignores the prompt pattern |
97 | echo -n '> ' | ||
98 | niro | 2051 | read line |
99 | niro | 2304 | eval "GLOBAL_ARGV=( ${line} )" |
100 | niro | 2051 | |
101 | niro | 2304 | case ${GLOBAL_ARGV[0]} in |
102 | niro | 2051 | quit) run=quit ;; |
103 | niro | 2304 | |
104 | # only react on the globals -> import|get|set|auth | ||
105 | import) run_class ;; | ||
106 | control) run_class ;; | ||
107 | get) run_class ;; | ||
108 | set) run_class ;; | ||
109 | auth) validate_auth ${GLOBAL_ARGV[*]:1} ;; | ||
110 | niro | 2423 | certauth) validate_auth_certificate ${GLOBAL_ARGV[*]:1} ;; |
111 | niro | 2432 | register) valid_session && validate_client ${GLOBAL_ARGV[*]:1} ;; |
112 | niro | 2304 | provide) valid_session && print_provide ;; |
113 | require) valid_session && verify_requirements ;; | ||
114 | reload) valid_session && mecho "reloading client classes ..." && load_classes client ;; | ||
115 | restart) valid_session && restart_service ;; | ||
116 | stop) valid_session && stop_service ;; | ||
117 | nocolors) export NOCOLORS="true" ;; | ||
118 | colors) export NOCOLORS="false" ;; | ||
119 | webcrlf) export WEBCRLF="true" ;; | ||
120 | quiet) export QUIET="true" ;; | ||
121 | # version does not need auth | ||
122 | version) print_version ;; | ||
123 | help) | ||
124 | if valid_session | ||
125 | then | ||
126 | if [[ ${line} = help ]] | ||
127 | then | ||
128 | help_topics | ||
129 | else | ||
130 | run_class ${line} | ||
131 | fi | ||
132 | else | ||
133 | mecho "You must authenticate yourself first!" | ||
134 | mecho " auth [username] [password]" | ||
135 | niro | 2426 | mecho "or" |
136 | mecho " certauth [certificate fingerprint]" | ||
137 | niro | 2304 | fi |
138 | ;; | ||
139 | |||
140 | *) | ||
141 | mecho "Unknown command '${line}'" | ||
142 | mecho "Type 'help' for more information." | ||
143 | #echo "$line" >> /root/lala.log | ||
144 | ;; | ||
145 | niro | 2051 | esac |
146 | niro | 2304 | |
147 | # unset argvs to be safe | ||
148 | unset GLOBAL_ARGS | ||
149 | unset CLASS_ARGS | ||
150 | niro | 2051 | done |
Properties
Name | Value |
---|---|
svn:executable | * |