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 1925 by niro, Wed Nov 9 15:17:49 2011 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  # # import_resource $table $serial $resource $value  # # import_resource $table $serial $resource $value
24  # import_resource()  # import_resource()
25  # {  # {
# Line 44  run_class() Line 64  run_class()
64   then   then
65   "${method}"_"${class}"_"${cmd}" ${argv}   "${method}"_"${class}"_"${cmd}" ${argv}
66   else   else
67   echo "unkown method '${method}' . class '${class}' . cmd '${cmd}'"   eecho "unkown method '${method}' . class '${class}' . cmd '${cmd}'"
68   fi   fi
69   else   else
70   invalid_session   invalid_session
# Line 64  help_topics() Line 84  help_topics()
84   mecho "\tauth     - authenticate to the daemon"   mecho "\tauth     - authenticate to the daemon"
85   mecho "\tprovide  - shows provides of a system"   mecho "\tprovide  - shows provides of a system"
86   mecho "\trequire  - verify plugin requirements"   mecho "\trequire  - verify plugin requirements"
87     mecho "\treload   - reloads all client classes plugins"
88     mecho "\trestart  - restarts the daemon"
89   mecho "\tnocolors - disable colors, useful for the webclient"   mecho "\tnocolors - disable colors, useful for the webclient"
90     mecho "\tquiet    - do not print any unecessary messages"
91   mecho "\thelp     - shows help"   mecho "\thelp     - shows help"
92   mecho "\tquit     - quits the connection to the server"   mecho "\tquit     - quits the connection to the server"
93   mecho   mecho
# Line 85  help_topics() Line 108  help_topics()
108  # 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
109  x11runas()  x11runas()
110  {  {
111   su - "${MCORE_UNPRIV_USER}" -c "DISPLAY=${MCORE_XORG_DISPLAY} $@"   if [[ -n $(pidof X) ]]
112     then
113     su - "${MCORE_UNPRIV_USER}" -c "DISPLAY=${MCORE_XORG_DISPLAY} $@"
114     fi
115  }  }
116    
117  addconfig()  addconfig()
# Line 94  addconfig() Line 120  addconfig()
120    
121   if [[ -z ${CONFIG} ]]   if [[ -z ${CONFIG} ]]
122   then   then
123   echo "You must define \$CONFIG varibale first!"   eecho "You must define \$CONFIG varibale first!"
124   return 1   return 1
125   fi   fi
126    
# Line 116  clearconfig() Line 142  clearconfig()
142  {  {
143   if [[ -z ${CONFIG} ]]   if [[ -z ${CONFIG} ]]
144   then   then
145   echo "You must define \$CONFIG varibale first!"   eecho "You must define \$CONFIG varibale first!"
146   return 1   return 1
147   fi   fi
148    
# Line 154  require() Line 180  require()
180   then   then
181   export REQUIRE="${REQUIRE} ${i}"   export REQUIRE="${REQUIRE} ${i}"
182   else   else
183   [[ ${DEBUG} = 1 ]] && echo "duplicate provide '${i}' detected!"   decho "duplicate provide '${i}' detected!"
184   fi   fi
185   done   done
186  }  }
# Line 183  verify_requirements() Line 209  verify_requirements()
209   # show missing and set the right retval   # show missing and set the right retval
210   if [[ -z ${missing} ]]   if [[ -z ${missing} ]]
211   then   then
212   mecho "${sorted}"   rvecho "${sorted}"
213   return 0   return 0
214   else   else
215   for req in ${sorted}   for req in ${sorted}
# Line 191  verify_requirements() Line 217  verify_requirements()
217   if no_duplicate "${missing}" "$req"   if no_duplicate "${missing}" "$req"
218   then   then
219   # print normal   # print normal
220   mecho -n " ${req}"   rvecho -n " ${req}"
221   else   else
222   # print missing   # print missing
223   eecho -n " ${req}"   eecho -n " ${req}"
# Line 213  provide() Line 239  provide()
239   then   then
240   export PROVIDE="${PROVIDE} ${i}"   export PROVIDE="${PROVIDE} ${i}"
241   else   else
242   [[ ${DEBUG} = 1 ]] && echo "duplicate provide '${i}' detected!"   decho "duplicate provide '${i}' detected!"
243   fi   fi
244   done   done
245  }  }
# Line 225  print_provide() Line 251  print_provide()
251   # sort them alpabetically   # sort them alpabetically
252   sorted=$(for i in ${PROVIDE}; do echo "${i}"; done | sort)   sorted=$(for i in ${PROVIDE}; do echo "${i}"; done | sort)
253   # do not escape, or CRLFS get printed to screen too   # do not escape, or CRLFS get printed to screen too
254   mecho ${sorted}   rvecho ${sorted}
255  }  }
256    
257    # message only echo | disabled in quiet mode
258  mecho()  mecho()
259  {  {
260   local COLCYAN="\033[1;36m"   local COLCYAN="\033[1;36m"
# Line 235  mecho() Line 262  mecho()
262   local opts   local opts
263   local webcrlf   local webcrlf
264    
265     # print nothing if quiet mode was requested
266     [[ ${QUIET} = true ]] && return
267    
268   if [[ ${NOCOLORS} = true ]]   if [[ ${NOCOLORS} = true ]]
269   then   then
270   COLCYAN=""   COLCYAN=""
# Line 251  mecho() Line 281  mecho()
281   echo -e${opts} "${COLCYAN}$@${COLDEFAULT}${webcrlf}"   echo -e${opts} "${COLCYAN}$@${COLDEFAULT}${webcrlf}"
282  }  }
283    
284    # prints error messages | enabled even in quiet mode
285  eecho()  eecho()
286  {  {
287   local COLRED="\033[1;31m"   local COLRED="\033[1;31m"
# Line 274  eecho() Line 305  eecho()
305   echo -e${opts} "${COLRED}$@${COLDEFAULT}${webcrlf}"   echo -e${opts} "${COLRED}$@${COLDEFAULT}${webcrlf}"
306  }  }
307    
308    # prints return values of get | enabled even in quiet mode
309    rvecho()
310    {
311     local COLPURPLE="\033[1;35m"
312     local COLDEFAULT="\033[0m"
313     local opts
314     local webcrlf
315    
316     if [[ ${NOCOLORS} = true ]]
317     then
318     COLPURPLE=""
319     COLDEFAULT=""
320     fi
321    
322     [[ ${WEBCRLF} = true ]] && webcrlf="<br>"
323    
324     # respect -n
325     case $1 in
326     -n) shift; opts="n" ;;
327     esac
328    
329     echo -e${opts} "${COLPURPLE}$@${COLDEFAULT}${webcrlf}"
330    }
331    
332    # prints debug messages if requested | enabled even in quiet mode
333    decho()
334    {
335     # print nothing if debug mode was *not* requested
336     [[ ${DEBUG} != 1 ]] && return
337    
338     eecho "DEBUG: ${@}"
339    }
340    
341  path_not_empty()  path_not_empty()
342  {  {
343   local path="$1"   local path="$1"
344   [[ -z ${path} ]] && "path_not_empty(): no path given!" && return 1   [[ -z ${path} ]] && eecho "path_not_empty(): no path given!" && return 1
345    
346   # return ERR if path does not exist   # return ERR if path does not exist
347   [[ ! -d ${path} ]] && return 1   [[ ! -d ${path} ]] && return 1

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