Magellan Linux

Annotation of /mcore-src/trunk/mcore-tools/src/mcored.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2479 - (hide annotations) (download)
Thu Sep 10 08:48:45 2015 UTC (8 years, 8 months ago) by niro
File size: 2422 byte(s)
-use 0/1 for bool values instead of mixed 0/1 and true/false settings
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 niro 2446 include ${MCORE_LIBDIR}/include/register.global.class
17 niro 2258 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 1248
25 niro 2479 # 0=false, 1=true
26 niro 1248 DEBUG=1
27 niro 2479 NOCOLORS=0
28     WEBCRLF=0
29     QUIET=0
30 niro 1248
31 niro 2269 # argvs are global variables - this fixes issues with whitespaces
32     # global argvs, the whole command line
33     export GLOBAL_ARGV
34     # class specific argvs which are given to the class as parameters
35     export CLASS_ARGV
36    
37 niro 1248 run=run
38     valid_session=no
39    
40 niro 2052 # tell what we are
41     echo "Connected to $(print_version)"
42    
43 niro 1248 while [[ ${run} = run ]]
44     do
45 niro 2335 # use an echo here not read -p '>' because sslsvd ignores the prompt pattern
46     echo -n '> '
47 niro 1248 read line
48 niro 2269 eval "GLOBAL_ARGV=( ${line} )"
49 niro 1248
50 niro 2269 case ${GLOBAL_ARGV[0]} in
51 niro 1248 quit) run=quit ;;
52    
53     # only react on the globals -> import|get|set|auth
54 niro 2269 import) run_class ;;
55     get) run_class ;;
56     set) run_class ;;
57     auth) validate_auth ${GLOBAL_ARGV[*]:1} ;;
58 niro 2423 certauth) validate_auth_certificate ${GLOBAL_ARGV[*]:1} ;;
59 niro 2442 register) valid_session && register_client_local ${GLOBAL_ARGV[*]:1} ;;
60 niro 1305 provide) valid_session && print_provide ;;
61     require) valid_session && verify_requirements ;;
62 niro 2303 reload) valid_session && mecho "reloading client classes ..." && load_classes client ;;
63 niro 1916 restart) valid_session && restart_service ;;
64 niro 2005 stop) valid_session && stop_service ;;
65 niro 2479 nocolors) export NOCOLORS=1 ;;
66     colors) export NOCOLORS=0 ;;
67     webcrlf) export WEBCRLF=1 ;;
68     quiet) export QUIET=1 ;;
69 niro 2044 # version does not need auth
70 niro 2052 version) print_version ;;
71 niro 2269 help)
72 niro 1305 if valid_session
73 niro 1248 then
74     if [[ ${line} = help ]]
75     then
76     help_topics
77     else
78     run_class ${line}
79     fi
80     else
81     mecho "You must authenticate yourself first!"
82     mecho " auth [username] [password]"
83 niro 2426 mecho "or"
84     mecho " certauth [certificate fingerprint]"
85 niro 1248 fi
86     ;;
87    
88     *)
89 niro 2243 mecho "Unknown command '${line}'"
90 niro 1248 mecho "Type 'help' for more information."
91 niro 1894 #echo "$line" >> /root/lala.log
92 niro 1248 ;;
93     esac
94 niro 2269
95     # unset argvs to be safe
96     unset GLOBAL_ARGS
97     unset CLASS_ARGS
98 niro 1248 done