Magellan Linux

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

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

revision 1308 by niro, Sun Feb 6 23:48:20 2011 UTC revision 1915 by niro, Wed Nov 9 13:24:00 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 58  help_topics() Line 78  help_topics()
78    
79   topics=$(typeset -f | grep '^help_' | sed 's:help_\(.*\)\ .*():\1:' | sed 's:_:\.:' | sort)   topics=$(typeset -f | grep '^help_' | sed 's:help_\(.*\)\ .*():\1:' | sed 's:_:\.:' | sort)
80   mecho "Global commands:"   mecho "Global commands:"
81   mecho "\timport  - import settings to database"   mecho "\timport   - import settings to database"
82   mecho "\tget     - shows current value for a settings"   mecho "\tget      - shows current value for a settings"
83   mecho "\tset     - sets value for a setting"   mecho "\tset      - sets value for a setting"
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 "\nocolors - disable colors, useful for the webclient"   mecho "\tnocolors - disable colors, useful for the webclient"
88   mecho "\thelp    - shows help"   mecho "\tquiet    - do not print any unecessary messages"
89   mecho "\tquit    - quits the connection to the server"   mecho "\thelp     - shows help"
90     mecho "\tquit     - quits the connection to the server"
91   mecho   mecho
92   mecho "Help topics:"   mecho "Help topics:"
93   for i in ${topics}   for i in ${topics}
# Line 85  help_topics() Line 106  help_topics()
106  # 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
107  x11runas()  x11runas()
108  {  {
109   su - "${MCORE_UNPRIV_USER}" -c "DISPLAY=${MCORE_XORG_DISPLAY} $@"   if [[ -n $(pidof X) ]]
110     then
111     su - "${MCORE_UNPRIV_USER}" -c "DISPLAY=${MCORE_XORG_DISPLAY} $@"
112     fi
113  }  }
114    
115  addconfig()  addconfig()
# Line 94  addconfig() Line 118  addconfig()
118    
119   if [[ -z ${CONFIG} ]]   if [[ -z ${CONFIG} ]]
120   then   then
121   echo "You must define \$CONFIG varibale first!"   eecho "You must define \$CONFIG varibale first!"
122   return 1   return 1
123   fi   fi
124    
# Line 116  clearconfig() Line 140  clearconfig()
140  {  {
141   if [[ -z ${CONFIG} ]]   if [[ -z ${CONFIG} ]]
142   then   then
143   echo "You must define \$CONFIG varibale first!"   eecho "You must define \$CONFIG varibale first!"
144   return 1   return 1
145   fi   fi
146    
# Line 154  require() Line 178  require()
178   then   then
179   export REQUIRE="${REQUIRE} ${i}"   export REQUIRE="${REQUIRE} ${i}"
180   else   else
181   [[ ${DEBUG} = 1 ]] && echo "duplicate provide '${i}' detected!"   decho "duplicate provide '${i}' detected!"
182   fi   fi
183   done   done
184  }  }
# Line 183  verify_requirements() Line 207  verify_requirements()
207   # show missing and set the right retval   # show missing and set the right retval
208   if [[ -z ${missing} ]]   if [[ -z ${missing} ]]
209   then   then
210   mecho "${sorted}"   rvecho "${sorted}"
211   return 0   return 0
212   else   else
213   for req in ${sorted}   for req in ${sorted}
# Line 191  verify_requirements() Line 215  verify_requirements()
215   if no_duplicate "${missing}" "$req"   if no_duplicate "${missing}" "$req"
216   then   then
217   # print normal   # print normal
218   mecho -n " ${req}"   rvecho -n " ${req}"
219   else   else
220   # print missing   # print missing
221   eecho -n " ${req}"   eecho -n " ${req}"
# Line 213  provide() Line 237  provide()
237   then   then
238   export PROVIDE="${PROVIDE} ${i}"   export PROVIDE="${PROVIDE} ${i}"
239   else   else
240   [[ ${DEBUG} = 1 ]] && echo "duplicate provide '${i}' detected!"   decho "duplicate provide '${i}' detected!"
241   fi   fi
242   done   done
243  }  }
# Line 225  print_provide() Line 249  print_provide()
249   # sort them alpabetically   # sort them alpabetically
250   sorted=$(for i in ${PROVIDE}; do echo "${i}"; done | sort)   sorted=$(for i in ${PROVIDE}; do echo "${i}"; done | sort)
251   # do not escape, or CRLFS get printed to screen too   # do not escape, or CRLFS get printed to screen too
252   mecho ${sorted}   rvecho ${sorted}
253  }  }
254    
255    # message only echo | disabled in quiet mode
256  mecho()  mecho()
257  {  {
258   local COLCYAN="\033[1;36m"   local COLCYAN="\033[1;36m"
# Line 235  mecho() Line 260  mecho()
260   local opts   local opts
261   local webcrlf   local webcrlf
262    
263     # print nothing if quiet mode was requested
264     [[ ${QUIET} = true ]] && return
265    
266   if [[ ${NOCOLORS} = true ]]   if [[ ${NOCOLORS} = true ]]
267   then   then
268   COLCYAN=""   COLCYAN=""
# Line 251  mecho() Line 279  mecho()
279   echo -e${opts} "${COLCYAN}$@${COLDEFAULT}${webcrlf}"   echo -e${opts} "${COLCYAN}$@${COLDEFAULT}${webcrlf}"
280  }  }
281    
282    # prints error messages | enabled even in quiet mode
283  eecho()  eecho()
284  {  {
285   local COLRED="\033[1;31m"   local COLRED="\033[1;31m"
# Line 274  eecho() Line 303  eecho()
303   echo -e${opts} "${COLRED}$@${COLDEFAULT}${webcrlf}"   echo -e${opts} "${COLRED}$@${COLDEFAULT}${webcrlf}"
304  }  }
305    
306    # prints return values of get | enabled even in quiet mode
307    rvecho()
308    {
309     local COLPURPLE="\033[1;35m"
310     local COLDEFAULT="\033[0m"
311     local opts
312     local webcrlf
313    
314     if [[ ${NOCOLORS} = true ]]
315     then
316     COLPURPLE=""
317     COLDEFAULT=""
318     fi
319    
320     [[ ${WEBCRLF} = true ]] && webcrlf="<br>"
321    
322     # respect -n
323     case $1 in
324     -n) shift; opts="n" ;;
325     esac
326    
327     echo -e${opts} "${COLPURPLE}$@${COLDEFAULT}${webcrlf}"
328    }
329    
330    # prints debug messages if requested | enabled even in quiet mode
331    decho()
332    {
333     # print nothing if debug mode was *not* requested
334     [[ ${DEBUG} != 1 ]] && return
335    
336     eecho "DEBUG: ${@}"
337    }
338    
339  path_not_empty()  path_not_empty()
340  {  {
341   local path="$1"   local path="$1"
342   [[ -z ${path} ]] && "path_not_empty(): no path given!" && return 1   [[ -z ${path} ]] && eecho "path_not_empty(): no path given!" && return 1
343    
344   # return ERR if path does not exist   # return ERR if path does not exist
345   [[ ! -d ${path} ]] && return 1   [[ ! -d ${path} ]] && return 1

Legend:
Removed from v.1308  
changed lines
  Added in v.1915