Magellan Linux

Diff of /mcore-src/trunk/mcore-tools/daemon/include/daemon.global.class

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1350 by niro, Thu Feb 17 21:42:57 2011 UTC revision 2006 by niro, Mon Aug 13 09:40:07 2012 UTC
# Line 1  Line 1 
1  # $Id$  # $Id$
2    
3    # loads client classes from $MCLIBDIR
4    load_client_classes()
5    {
6     # client specific
7     for i in ${MCLIBDIR}/include/*.client.class
8     do
9     source ${i} || eecho "error loading ${i}"
10     done
11    }
12    
13    # restarts the whole service via remote cmd
14    restart_service()
15    {
16     local pid
17     for pid in $(pidof sslsvd)
18     do
19     kill -SIGHUP ${pid}
20     done
21    }
22    
23    # stops the whole service via remote cmd
24    stop_service()
25    {
26     local pid
27     for pid in $(pidof sslsvd)
28     do
29     kill -15 ${pid}
30     sleep 1
31     kill -9 ${pid}
32     done
33    }
34    
35  # # import_resource $table $serial $resource $value  # # import_resource $table $serial $resource $value
36  # import_resource()  # import_resource()
37  # {  # {
# Line 44  run_class() Line 76  run_class()
76   then   then
77   "${method}"_"${class}"_"${cmd}" ${argv}   "${method}"_"${class}"_"${cmd}" ${argv}
78   else   else
79   echo "unkown method '${method}' . class '${class}' . cmd '${cmd}'"   eecho "unkown method '${method}' . class '${class}' . cmd '${cmd}'"
80   fi   fi
81   else   else
82   invalid_session   invalid_session
# Line 64  help_topics() Line 96  help_topics()
96   mecho "\tauth     - authenticate to the daemon"   mecho "\tauth     - authenticate to the daemon"
97   mecho "\tprovide  - shows provides of a system"   mecho "\tprovide  - shows provides of a system"
98   mecho "\trequire  - verify plugin requirements"   mecho "\trequire  - verify plugin requirements"
99     mecho "\treload   - reloads all client classes plugins"
100     mecho "\trestart  - restarts the daemon"
101     mecho "\tstop     - stops the daemon"
102   mecho "\tnocolors - disable colors, useful for the webclient"   mecho "\tnocolors - disable colors, useful for the webclient"
103     mecho "\tcolors   - enable colors"
104     mecho "\tquiet    - do not print any unecessary messages"
105   mecho "\thelp     - shows help"   mecho "\thelp     - shows help"
106   mecho "\tquit     - quits the connection to the server"   mecho "\tquit     - quits the connection to the server"
107   mecho   mecho
# Line 85  help_topics() Line 122  help_topics()
122  # on newer xorg-servers root is not allowed to run progs in a user session  # on newer xorg-servers root is not allowed to run progs in a user session
123  x11runas()  x11runas()
124  {  {
125   su - "${MCORE_UNPRIV_USER}" -c "DISPLAY=${MCORE_XORG_DISPLAY} $@"   if [[ -n $(pidof X) ]]
126     then
127     su - "${MCORE_UNPRIV_USER}" -c "DISPLAY=${MCORE_XORG_DISPLAY} $@"
128     fi
129  }  }
130    
131  addconfig()  addconfig()
# Line 94  addconfig() Line 134  addconfig()
134    
135   if [[ -z ${CONFIG} ]]   if [[ -z ${CONFIG} ]]
136   then   then
137   echo "You must define \$CONFIG varibale first!"   eecho "You must define \$CONFIG varibale first!"
138   return 1   return 1
139   fi   fi
140    
# Line 116  clearconfig() Line 156  clearconfig()
156  {  {
157   if [[ -z ${CONFIG} ]]   if [[ -z ${CONFIG} ]]
158   then   then
159   echo "You must define \$CONFIG varibale first!"   eecho "You must define \$CONFIG varibale first!"
160   return 1   return 1
161   fi   fi
162    
# Line 154  require() Line 194  require()
194   then   then
195   export REQUIRE="${REQUIRE} ${i}"   export REQUIRE="${REQUIRE} ${i}"
196   else   else
197   [[ ${DEBUG} = 1 ]] && echo "duplicate provide '${i}' detected!"   decho "duplicate provide '${i}' detected!"
198   fi   fi
199   done   done
200  }  }
# Line 183  verify_requirements() Line 223  verify_requirements()
223   # show missing and set the right retval   # show missing and set the right retval
224   if [[ -z ${missing} ]]   if [[ -z ${missing} ]]
225   then   then
226   mecho "${sorted}"   rvecho "${sorted}"
227   return 0   return 0
228   else   else
229   for req in ${sorted}   for req in ${sorted}
# Line 191  verify_requirements() Line 231  verify_requirements()
231   if no_duplicate "${missing}" "$req"   if no_duplicate "${missing}" "$req"
232   then   then
233   # print normal   # print normal
234   mecho -n " ${req}"   rvecho -n " ${req}"
235   else   else
236   # print missing   # print missing
237   eecho -n " ${req}"   eecho -n " ${req}"
# Line 213  provide() Line 253  provide()
253   then   then
254   export PROVIDE="${PROVIDE} ${i}"   export PROVIDE="${PROVIDE} ${i}"
255   else   else
256   [[ ${DEBUG} = 1 ]] && echo "duplicate provide '${i}' detected!"   decho "duplicate provide '${i}' detected!"
257   fi   fi
258   done   done
259  }  }
# Line 225  print_provide() Line 265  print_provide()
265   # sort them alpabetically   # sort them alpabetically
266   sorted=$(for i in ${PROVIDE}; do echo "${i}"; done | sort)   sorted=$(for i in ${PROVIDE}; do echo "${i}"; done | sort)
267   # do not escape, or CRLFS get printed to screen too   # do not escape, or CRLFS get printed to screen too
268   mecho ${sorted}   rvecho ${sorted}
269  }  }
270    
271    # message only echo | disabled in quiet mode
272  mecho()  mecho()
273  {  {
274   local COLCYAN="\033[1;36m"   local COLCYAN="\033[1;36m"
# Line 235  mecho() Line 276  mecho()
276   local opts   local opts
277   local webcrlf   local webcrlf
278    
279     # print nothing if quiet mode was requested
280     [[ ${QUIET} = true ]] && return
281    
282   if [[ ${NOCOLORS} = true ]]   if [[ ${NOCOLORS} = true ]]
283   then   then
284   COLCYAN=""   COLCYAN=""
# Line 251  mecho() Line 295  mecho()
295   echo -e${opts} "${COLCYAN}$@${COLDEFAULT}${webcrlf}"   echo -e${opts} "${COLCYAN}$@${COLDEFAULT}${webcrlf}"
296  }  }
297    
298    # prints error messages | enabled even in quiet mode
299  eecho()  eecho()
300  {  {
301   local COLRED="\033[1;31m"   local COLRED="\033[1;31m"
# Line 274  eecho() Line 319  eecho()
319   echo -e${opts} "${COLRED}$@${COLDEFAULT}${webcrlf}"   echo -e${opts} "${COLRED}$@${COLDEFAULT}${webcrlf}"
320  }  }
321    
322    # prints return values of get | enabled even in quiet mode
323    rvecho()
324    {
325     local COLPURPLE="\033[1;35m"
326     local COLDEFAULT="\033[0m"
327     local opts
328     local webcrlf
329    
330     if [[ ${NOCOLORS} = true ]]
331     then
332     COLPURPLE=""
333     COLDEFAULT=""
334     fi
335    
336     [[ ${WEBCRLF} = true ]] && webcrlf="<br>"
337    
338     # respect -n
339     case $1 in
340     -n) shift; opts="n" ;;
341     esac
342    
343     echo -e${opts} "${COLPURPLE}$@${COLDEFAULT}${webcrlf}"
344    }
345    
346    # prints debug messages if requested | enabled even in quiet mode
347    decho()
348    {
349     # print nothing if debug mode was *not* requested
350     [[ ${DEBUG} != 1 ]] && return
351    
352     eecho "DEBUG: ${@}"
353    }
354    
355  path_not_empty()  path_not_empty()
356  {  {
357   local path="$1"   local path="$1"
358   [[ -z ${path} ]] && "path_not_empty(): no path given!" && return 1   [[ -z ${path} ]] && eecho "path_not_empty(): no path given!" && return 1
359    
360   # return ERR if path does not exist   # return ERR if path does not exist
361   [[ ! -d ${path} ]] && return 1   [[ ! -d ${path} ]] && return 1

Legend:
Removed from v.1350  
changed lines
  Added in v.2006