Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


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