Annotation of /mcore-src/trunk/mcore-tools/src/mcored.in
Parent Directory | Revision Log
Revision 2426 -
(hide annotations)
(download)
Thu Sep 3 07:54:18 2015 UTC (9 years ago) by niro
File size: 3143 byte(s)
Thu Sep 3 07:54:18 2015 UTC (9 years ago) by niro
File size: 3143 byte(s)
-inform the user about the fingerprint authentication method too
1 | niro | 1248 | #!/bin/bash |
2 | |||
3 | niro | 2137 | MCORE_LIBDIR="@@MCORE_LIBDIR@@" |
4 | niro | 1248 | |
5 | niro | 2095 | # respect system env (proxy settings etc) |
6 | niro | 2137 | if [ -e @@SYSCONFDIR@@/profile ] |
7 | niro | 2095 | then |
8 | niro | 2137 | source @@SYSCONFDIR@@/profile |
9 | niro | 2095 | fi |
10 | |||
11 | niro | 1248 | # globals |
12 | niro | 2258 | # include function comes with common.global class |
13 | niro | 2140 | source ${MCORE_LIBDIR}/include/common.global.class |
14 | niro | 2258 | 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 | niro | 1248 | |
19 | niro | 1916 | # load client classes plugins |
20 | niro | 2303 | load_classes client |
21 | niro | 1248 | |
22 | # config settings | ||
23 | niro | 2258 | include @@SYSCONFDIR@@/mcore/mcore.conf |
24 | niro | 2137 | #source @@SYSCONFDIR@@/mcore/serial |
25 | niro | 1248 | |
26 | niro | 1251 | # 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 | niro | 1248 | |
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 | niro | 1638 | NOCOLORS="false" |
57 | WEBCRLF="false" | ||
58 | QUIET="false" | ||
59 | niro | 1248 | |
60 | niro | 2269 | # 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 | niro | 1248 | run=run |
67 | valid_session=no | ||
68 | |||
69 | niro | 2052 | # tell what we are |
70 | echo "Connected to $(print_version)" | ||
71 | |||
72 | niro | 1248 | while [[ ${run} = run ]] |
73 | do | ||
74 | niro | 2335 | # use an echo here not read -p '>' because sslsvd ignores the prompt pattern |
75 | echo -n '> ' | ||
76 | niro | 1248 | read line |
77 | niro | 2269 | eval "GLOBAL_ARGV=( ${line} )" |
78 | niro | 1248 | |
79 | niro | 2269 | case ${GLOBAL_ARGV[0]} in |
80 | niro | 1248 | quit) run=quit ;; |
81 | |||
82 | # only react on the globals -> import|get|set|auth | ||
83 | niro | 2269 | import) run_class ;; |
84 | get) run_class ;; | ||
85 | set) run_class ;; | ||
86 | auth) validate_auth ${GLOBAL_ARGV[*]:1} ;; | ||
87 | niro | 2423 | certauth) validate_auth_certificate ${GLOBAL_ARGV[*]:1} ;; |
88 | niro | 1305 | provide) valid_session && print_provide ;; |
89 | require) valid_session && verify_requirements ;; | ||
90 | niro | 2303 | reload) valid_session && mecho "reloading client classes ..." && load_classes client ;; |
91 | niro | 1916 | restart) valid_session && restart_service ;; |
92 | niro | 2005 | stop) valid_session && stop_service ;; |
93 | niro | 1305 | nocolors) export NOCOLORS="true" ;; |
94 | niro | 2006 | colors) export NOCOLORS="false" ;; |
95 | niro | 1305 | webcrlf) export WEBCRLF="true" ;; |
96 | niro | 1638 | quiet) export QUIET="true" ;; |
97 | niro | 2044 | # version does not need auth |
98 | niro | 2052 | version) print_version ;; |
99 | niro | 2269 | help) |
100 | niro | 1305 | if valid_session |
101 | niro | 1248 | then |
102 | if [[ ${line} = help ]] | ||
103 | then | ||
104 | help_topics | ||
105 | else | ||
106 | run_class ${line} | ||
107 | fi | ||
108 | else | ||
109 | mecho "You must authenticate yourself first!" | ||
110 | mecho " auth [username] [password]" | ||
111 | niro | 2426 | mecho "or" |
112 | mecho " certauth [certificate fingerprint]" | ||
113 | niro | 1248 | fi |
114 | ;; | ||
115 | |||
116 | *) | ||
117 | niro | 2243 | mecho "Unknown command '${line}'" |
118 | niro | 1248 | mecho "Type 'help' for more information." |
119 | niro | 1894 | #echo "$line" >> /root/lala.log |
120 | niro | 1248 | ;; |
121 | esac | ||
122 | niro | 2269 | |
123 | # unset argvs to be safe | ||
124 | unset GLOBAL_ARGS | ||
125 | unset CLASS_ARGS | ||
126 | niro | 1248 | done |