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 1639 by niro, Thu Mar 10 18:08:47 2011 UTC revision 2044 by niro, Wed May 8 11:04:43 2013 UTC
# Line 1  Line 1 
1  # $Id$  # $Id$
2    
3    # loads client classes from $MCLIBDIR
4    load_client_classes()
5    {
6     local i
7    
8     # client specific
9     for i in $(find ${MCLIBDIR}/include -type f -name \*.client.class)
10     do
11     source ${i} || eecho "error loading ${i}"
12     done
13    }
14    
15    # restarts the whole service via remote cmd
16    restart_service()
17    {
18     local pid
19     for pid in $(pidof sslsvd)
20     do
21     kill -SIGHUP ${pid}
22     done
23    }
24    
25    # stops the whole service via remote cmd
26    stop_service()
27    {
28     local pid
29     for pid in $(pidof sslsvd)
30     do
31     kill -15 ${pid}
32     sleep 1
33     kill -9 ${pid}
34     done
35    }
36    
37  # # import_resource $table $serial $resource $value  # # import_resource $table $serial $resource $value
38  # import_resource()  # import_resource()
39  # {  # {
# Line 64  help_topics() Line 98  help_topics()
98   mecho "\tauth     - authenticate to the daemon"   mecho "\tauth     - authenticate to the daemon"
99   mecho "\tprovide  - shows provides of a system"   mecho "\tprovide  - shows provides of a system"
100   mecho "\trequire  - verify plugin requirements"   mecho "\trequire  - verify plugin requirements"
101     mecho "\treload   - reloads all client classes plugins"
102     mecho "\trestart  - restarts the daemon"
103     mecho "\tstop     - stops the daemon"
104   mecho "\tnocolors - disable colors, useful for the webclient"   mecho "\tnocolors - disable colors, useful for the webclient"
105     mecho "\tcolors   - enable colors"
106   mecho "\tquiet    - do not print any unecessary messages"   mecho "\tquiet    - do not print any unecessary messages"
107   mecho "\thelp     - shows help"   mecho "\thelp     - shows help"
108     mecho "\tversion  - prints version of the daemon"
109   mecho "\tquit     - quits the connection to the server"   mecho "\tquit     - quits the connection to the server"
110   mecho   mecho
111   mecho "Help topics:"   mecho "Help topics:"
# Line 86  help_topics() Line 125  help_topics()
125  # 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
126  x11runas()  x11runas()
127  {  {
128   if pidof X   if [[ -n $(pidof X) ]]
129   then   then
130   su - "${MCORE_UNPRIV_USER}" -c "DISPLAY=${MCORE_XORG_DISPLAY} $@"   su - "${MCORE_UNPRIV_USER}" -c "DISPLAY=${MCORE_XORG_DISPLAY} $@"
131   fi   fi
# Line 229  print_provide() Line 268  print_provide()
268   # sort them alpabetically   # sort them alpabetically
269   sorted=$(for i in ${PROVIDE}; do echo "${i}"; done | sort)   sorted=$(for i in ${PROVIDE}; do echo "${i}"; done | sort)
270   # do not escape, or CRLFS get printed to screen too   # do not escape, or CRLFS get printed to screen too
271   rvecho ${sorted}   rvecho ${sorted}
272  }  }
273    
274  # message only echo | disabled in quiet mode  # message only echo | disabled in quiet mode
# Line 329  path_not_empty() Line 368  path_not_empty()
368   # every thing went ok, directory not empty   # every thing went ok, directory not empty
369   return 0   return 0
370  }  }
371    
372    help_daemon_mroot()
373    {
374     mecho "get daemon.mroot"
375     mecho " Prints current MROOT variable."
376     mecho
377     mecho "set daemon.mroot [path]"
378     mecho " set MROOT variable to given path."
379    }
380    
381    get_daemon_mroot()
382    {
383     rvecho "${MROOT}"
384    }
385    
386    set_daemon_mroot()
387    {
388     local path=$1
389    
390     if [[ -d ${path} ]]
391     then
392     export MROOT="${path}"
393     decho "MROOT='${MROOT}' is set."
394     else
395     eecho "Path '${path}' does not exist. MROOT not set."
396     fi
397    }
398    
399    list_files_in_directory()
400    {
401     local i
402     local retval
403     local path
404     local opts
405     local type
406    
407     # basic getops
408     for i in $*
409     do
410     case $1 in
411     -mindepth) shift; opts+=" -mindepth $1" ;;
412     -maxdepth) shift; opts+=" -maxdepth $1" ;;
413     -type) shift; type="$1" ;;
414     '') continue ;;
415     *) path="$1" ;;
416     esac
417     shift
418     done
419    
420     if [[ -z ${path} ]]
421     then
422     eecho "No path given."
423     return 1
424     fi
425    
426     if [[ ! -d ${path} ]]
427     then
428     eecho "Directory '${path}' does not exist."
429     return 1
430     fi
431    
432     # default to files
433     [[ -z ${type} ]] && type=f
434    
435     for i in $(find ${path} ${opts} -type ${type} | sort)
436     do
437     if [[ -z ${retval} ]]
438     then
439     retval="$(basename ${i})"
440     else
441     retval="${retval} $(basename ${i})"
442     fi
443     done
444    
445     rvecho "${retval}"
446    }

Legend:
Removed from v.1639  
changed lines
  Added in v.2044