Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


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