Contents of /mcore-src/trunk/mcore-tools/src/mcored.in
Parent Directory | Revision Log
Revision 2335 -
(show annotations)
(download)
Mon Jul 14 07:48:13 2014 UTC (10 years, 2 months ago) by niro
File size: 3018 byte(s)
Mon Jul 14 07:48:13 2014 UTC (10 years, 2 months ago) by niro
File size: 3018 byte(s)
-add an prompt pattern to mcored cmdline
1 | #!/bin/bash |
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/hwdetection.global.class |
18 | |
19 | # load client classes plugins |
20 | load_classes client |
21 | |
22 | # config settings |
23 | include @@SYSCONFDIR@@/mcore/mcore.conf |
24 | #source @@SYSCONFDIR@@/mcore/serial |
25 | |
26 | # import_hardware_resource() |
27 | # { |
28 | # local resource="$1" |
29 | # local value |
30 | # |
31 | # # special cases |
32 | # case ${resource} in |
33 | # 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() |
49 | # { |
50 | # local ip |
51 | # ip=$(ifconfig | grep -A1 eth0 | grep inet | sed 's/.*inet\ addr:\(.*\) Bcast.*/\1/;') |
52 | # |
53 | # } |
54 | |
55 | 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 |
67 | valid_session=no |
68 | |
69 | # tell what we are |
70 | echo "Connected to $(print_version)" |
71 | |
72 | while [[ ${run} = run ]] |
73 | do |
74 | # use an echo here not read -p '>' because sslsvd ignores the prompt pattern |
75 | echo -n '> ' |
76 | read line |
77 | eval "GLOBAL_ARGV=( ${line} )" |
78 | |
79 | case ${GLOBAL_ARGV[0]} in |
80 | quit) run=quit ;; |
81 | |
82 | # only react on the globals -> import|get|set|auth |
83 | import) run_class ;; |
84 | get) run_class ;; |
85 | set) run_class ;; |
86 | auth) validate_auth ${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 | fi |
111 | ;; |
112 | |
113 | *) |
114 | mecho "Unknown command '${line}'" |
115 | mecho "Type 'help' for more information." |
116 | #echo "$line" >> /root/lala.log |
117 | ;; |
118 | esac |
119 | |
120 | # unset argvs to be safe |
121 | unset GLOBAL_ARGS |
122 | unset CLASS_ARGS |
123 | done |