Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2446 - (show annotations) (download)
Thu Sep 3 13:39:08 2015 UTC (8 years, 7 months ago) by niro
File size: 3271 byte(s)
-include register functions
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/mysqlfunctions.global.class
17 include ${MCORE_LIBDIR}/include/register.global.class
18 include ${MCORE_LIBDIR}/include/hwdetection.global.class
19
20 # load client classes plugins
21 load_classes client
22
23 # config settings
24 include @@SYSCONFDIR@@/mcore/mcore.conf
25 #source @@SYSCONFDIR@@/mcore/serial
26
27 # 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
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 NOCOLORS="false"
58 WEBCRLF="false"
59 QUIET="false"
60
61 # 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 run=run
68 valid_session=no
69
70 # tell what we are
71 echo "Connected to $(print_version)"
72
73 while [[ ${run} = run ]]
74 do
75 # use an echo here not read -p '>' because sslsvd ignores the prompt pattern
76 echo -n '> '
77 read line
78 eval "GLOBAL_ARGV=( ${line} )"
79
80 case ${GLOBAL_ARGV[0]} in
81 quit) run=quit ;;
82
83 # only react on the globals -> import|get|set|auth
84 import) run_class ;;
85 get) run_class ;;
86 set) run_class ;;
87 auth) validate_auth ${GLOBAL_ARGV[*]:1} ;;
88 certauth) validate_auth_certificate ${GLOBAL_ARGV[*]:1} ;;
89 register) valid_session && register_client_local ${GLOBAL_ARGV[*]:1} ;;
90 provide) valid_session && print_provide ;;
91 require) valid_session && verify_requirements ;;
92 reload) valid_session && mecho "reloading client classes ..." && load_classes client ;;
93 restart) valid_session && restart_service ;;
94 stop) valid_session && stop_service ;;
95 nocolors) export NOCOLORS="true" ;;
96 colors) export NOCOLORS="false" ;;
97 webcrlf) export WEBCRLF="true" ;;
98 quiet) export QUIET="true" ;;
99 # version does not need auth
100 version) print_version ;;
101 help)
102 if valid_session
103 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 mecho "or"
114 mecho " certauth [certificate fingerprint]"
115 fi
116 ;;
117
118 *)
119 mecho "Unknown command '${line}'"
120 mecho "Type 'help' for more information."
121 #echo "$line" >> /root/lala.log
122 ;;
123 esac
124
125 # unset argvs to be safe
126 unset GLOBAL_ARGS
127 unset CLASS_ARGS
128 done