Annotation of /mcore-src/trunk/mcore-tools/src/mcored.in
Parent Directory | Revision Log
Revision 2446 -
(hide annotations)
(download)
Thu Sep 3 13:39:08 2015 UTC (8 years, 9 months ago) by niro
File size: 3271 byte(s)
Thu Sep 3 13:39:08 2015 UTC (8 years, 9 months ago) by niro
File size: 3271 byte(s)
-include register functions
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 | niro | 2446 | include ${MCORE_LIBDIR}/include/register.global.class |
18 | niro | 2258 | include ${MCORE_LIBDIR}/include/hwdetection.global.class |
19 | niro | 1248 | |
20 | niro | 1916 | # load client classes plugins |
21 | niro | 2303 | load_classes client |
22 | niro | 1248 | |
23 | # config settings | ||
24 | niro | 2258 | include @@SYSCONFDIR@@/mcore/mcore.conf |
25 | niro | 2137 | #source @@SYSCONFDIR@@/mcore/serial |
26 | niro | 1248 | |
27 | niro | 1251 | # import_hardware_resource() |
28 | # { | ||
29 | # local resource="$1" | ||
30 | # local value | ||
31 | # | ||
32 | # # special cases | ||
33 | # case ${resource} in | ||
34 | # gfxcard) value="$(get_x11_driver_modules)" ;; | ||
35 | # *) value="$(get_hwinfo --with-description ${resource})" ;; | ||
36 | # esac | ||
37 | # | ||
38 | # # if [[ ${DEBUG} = 1 ]] | ||
39 | # # then | ||
40 | # # echo "${resource}=${value}" >> /root/lala.log | ||
41 | # # echo "mysqldo \"update status set ${resource}='${value}' where serial=${ALX_SERIAL};\"" >> /root/lala.log | ||
42 | # # fi | ||
43 | # # mysql_insert status,serial="${ALX_SERIAL}","${resource}"="${value}" | ||
44 | # | ||
45 | # import_resource status "${ALX_SERIAL}" "${resource}" "${value}" | ||
46 | # } | ||
47 | niro | 1248 | |
48 | |||
49 | # set_init_state() | ||
50 | # { | ||
51 | # local ip | ||
52 | # ip=$(ifconfig | grep -A1 eth0 | grep inet | sed 's/.*inet\ addr:\(.*\) Bcast.*/\1/;') | ||
53 | # | ||
54 | # } | ||
55 | |||
56 | DEBUG=1 | ||
57 | niro | 1638 | NOCOLORS="false" |
58 | WEBCRLF="false" | ||
59 | QUIET="false" | ||
60 | niro | 1248 | |
61 | niro | 2269 | # argvs are global variables - this fixes issues with whitespaces |
62 | # global argvs, the whole command line | ||
63 | export GLOBAL_ARGV | ||
64 | # class specific argvs which are given to the class as parameters | ||
65 | export CLASS_ARGV | ||
66 | |||
67 | niro | 1248 | run=run |
68 | valid_session=no | ||
69 | |||
70 | niro | 2052 | # tell what we are |
71 | echo "Connected to $(print_version)" | ||
72 | |||
73 | niro | 1248 | while [[ ${run} = run ]] |
74 | do | ||
75 | niro | 2335 | # use an echo here not read -p '>' because sslsvd ignores the prompt pattern |
76 | echo -n '> ' | ||
77 | niro | 1248 | read line |
78 | niro | 2269 | eval "GLOBAL_ARGV=( ${line} )" |
79 | niro | 1248 | |
80 | niro | 2269 | case ${GLOBAL_ARGV[0]} in |
81 | niro | 1248 | quit) run=quit ;; |
82 | |||
83 | # only react on the globals -> import|get|set|auth | ||
84 | niro | 2269 | import) run_class ;; |
85 | get) run_class ;; | ||
86 | set) run_class ;; | ||
87 | auth) validate_auth ${GLOBAL_ARGV[*]:1} ;; | ||
88 | niro | 2423 | certauth) validate_auth_certificate ${GLOBAL_ARGV[*]:1} ;; |
89 | niro | 2442 | register) valid_session && register_client_local ${GLOBAL_ARGV[*]:1} ;; |
90 | niro | 1305 | provide) valid_session && print_provide ;; |
91 | require) valid_session && verify_requirements ;; | ||
92 | niro | 2303 | reload) valid_session && mecho "reloading client classes ..." && load_classes client ;; |
93 | niro | 1916 | restart) valid_session && restart_service ;; |
94 | niro | 2005 | stop) valid_session && stop_service ;; |
95 | niro | 1305 | nocolors) export NOCOLORS="true" ;; |
96 | niro | 2006 | colors) export NOCOLORS="false" ;; |
97 | niro | 1305 | webcrlf) export WEBCRLF="true" ;; |
98 | niro | 1638 | quiet) export QUIET="true" ;; |
99 | niro | 2044 | # version does not need auth |
100 | niro | 2052 | version) print_version ;; |
101 | niro | 2269 | help) |
102 | niro | 1305 | if valid_session |
103 | niro | 1248 | then |
104 | if [[ ${line} = help ]] | ||
105 | then | ||
106 | help_topics | ||
107 | else | ||
108 | run_class ${line} | ||
109 | fi | ||
110 | else | ||
111 | mecho "You must authenticate yourself first!" | ||
112 | mecho " auth [username] [password]" | ||
113 | niro | 2426 | mecho "or" |
114 | mecho " certauth [certificate fingerprint]" | ||
115 | niro | 1248 | fi |
116 | ;; | ||
117 | |||
118 | *) | ||
119 | niro | 2243 | mecho "Unknown command '${line}'" |
120 | niro | 1248 | mecho "Type 'help' for more information." |
121 | niro | 1894 | #echo "$line" >> /root/lala.log |
122 | niro | 1248 | ;; |
123 | esac | ||
124 | niro | 2269 | |
125 | # unset argvs to be safe | ||
126 | unset GLOBAL_ARGS | ||
127 | unset CLASS_ARGS | ||
128 | niro | 1248 | done |