Contents of /mcore-src/trunk/mcore-tools/src/mcore-controld.in
Parent Directory | Revision Log
Revision 2243 -
(show annotations)
(download)
(as text)
Mon Jan 13 09:27:41 2014 UTC (10 years, 8 months ago) by niro
Original Path: mcore-src/trunk/mcore-tools/daemon/control/control-daemon.sh
File MIME type: application/x-sh
File size: 2215 byte(s)
Mon Jan 13 09:27:41 2014 UTC (10 years, 8 months ago) by niro
Original Path: mcore-src/trunk/mcore-tools/daemon/control/control-daemon.sh
File MIME type: application/x-sh
File size: 2215 byte(s)
-fixed spelling - unkown -> unknown
1 | #!/bin/sh |
2 | |
3 | # globals |
4 | source include/daemon.global.class |
5 | source include/sessionauth.global.class |
6 | source include/mysqlfunctions.global.class |
7 | |
8 | # control specific |
9 | #source include/graphic.control.class |
10 | #source include/input.control.class |
11 | for i in include/*.control.class |
12 | do |
13 | source ${i} || echo "error loading ${i}" |
14 | done |
15 | |
16 | |
17 | SQL_USER=alx |
18 | SQL_PASS=@lx |
19 | SQL_HOST=localhost |
20 | SQL_DB=alx_web |
21 | |
22 | import_resource() |
23 | { |
24 | local table="$1" |
25 | local serial="$2" |
26 | local resource="$3" |
27 | local value="$4" |
28 | |
29 | if [[ ${DEBUG} = 1 ]] |
30 | then |
31 | echo "${table}->${resource}=${value}" >> /root/lala.log |
32 | echo "mysqldo \"update ${table} set ${resource}='${value}' where serial=${serial};\"" >> /root/lala.log |
33 | fi |
34 | |
35 | mysql_insert "${table}",serial="${serial}","${resource}"="${value}" |
36 | } |
37 | |
38 | run_class() |
39 | { |
40 | local method="$1" |
41 | local caller="$2" |
42 | local class |
43 | local cmd |
44 | local argv |
45 | |
46 | if validate_session |
47 | then |
48 | class="${caller%.*}" |
49 | cmd="${caller#*.}" |
50 | argv="${@/${caller}/}" # remove caller |
51 | argv="${argv/${method}/}" # remove method |
52 | |
53 | # echo "method=${method}" |
54 | # echo "caller=${caller}" |
55 | # echo "class=${class}" |
56 | # echo "cmd=${cmd}" |
57 | # echo "argv=${argv}" |
58 | |
59 | # check if class.cmd exist |
60 | if [[ ! -z $(typeset -f "${method}"_"${class}"_"${cmd}") ]] |
61 | then |
62 | "${method}"_"${class}"_"${cmd}" ${argv} |
63 | else |
64 | echo "unknown class.cmd" |
65 | fi |
66 | else |
67 | invalid_session |
68 | fi |
69 | } |
70 | |
71 | nsslsay() |
72 | { |
73 | nssl "${IP}" "${PORT}" << EOF |
74 | auth ${SSLSAY_USER} ${SSLSAY_PASS} |
75 | $@ |
76 | quit |
77 | EOF |
78 | } |
79 | |
80 | control_client() |
81 | { |
82 | local serial="$1" |
83 | local command="${@/$1/}" |
84 | local IP |
85 | |
86 | IP=$(mysqldo "select ip from state_connected where serial='${serial}'") |
87 | if [[ -z ${IP} ]] |
88 | then |
89 | echo "no ip found for client '${serial}'" |
90 | return 1 |
91 | fi |
92 | |
93 | nsslsay "${command}" |
94 | } |
95 | |
96 | |
97 | DEBUG=1 |
98 | #IP="192.168.0.6" |
99 | PORT="6666" |
100 | SSLSAY_USER="foo" |
101 | SSLSAY_PASS="bar" |
102 | |
103 | run=run |
104 | valid_session=no |
105 | |
106 | while [[ ${run} = run ]] |
107 | do |
108 | read line |
109 | |
110 | case ${line} in |
111 | quit) run=quit ;; |
112 | # only react on the globals -> import|get|set|auth|control |
113 | import*) run_class ${line} ;; |
114 | get*) run_class ${line} ;; |
115 | set*) run_class ${line} ;; |
116 | auth*) validate_auth ${line/auth /} ;; |
117 | # control client daemons |
118 | #control*) control_client ${line/control /} ;; |
119 | control*) run_class ${line} ;; |
120 | *) echo "$line" >> /root/lala.log ;; |
121 | esac |
122 | done |
123 |
Properties
Name | Value |
---|---|
svn:executable | * |