Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *