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 2005 by niro, Mon Aug 13 09:38:21 2012 UTC revision 2083 by niro, Fri May 10 13:14:35 2013 UTC
# Line 3  Line 3 
3  # loads client classes from $MCLIBDIR  # loads client classes from $MCLIBDIR
4  load_client_classes()  load_client_classes()
5  {  {
6     local i
7    
8   # client specific   # client specific
9   for i in ${MCLIBDIR}/include/*.client.class   for i in $(find ${MCLIBDIR}/include -type f -name \*.client.class)
10   do   do
11   source ${i} || eecho "error loading ${i}"   source ${i} || eecho "error loading ${i}"
12   done   done
# Line 100  help_topics() Line 102  help_topics()
102   mecho "\trestart  - restarts the daemon"   mecho "\trestart  - restarts the daemon"
103   mecho "\tstop     - stops the daemon"   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 364  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     -name) shift; opts+="-name $1" ;;
415     '') continue ;;
416     *) path="$1" ;;
417     esac
418     shift
419     done
420    
421     if [[ -z ${path} ]]
422     then
423     eecho "No path given."
424     return 1
425     fi
426    
427     if [[ ! -d ${path} ]]
428     then
429     eecho "Directory '${path}' does not exist."
430     return 1
431     fi
432    
433     # default to files
434     [[ -z ${type} ]] && type=f
435    
436     for i in $(find ${path} ${opts} -type ${type} -print '%f\n' | sort)
437     do
438     if [[ -z ${retval} ]]
439     then
440     retval="${i}"
441     else
442     retval+=" ${i}"
443     fi
444     done
445    
446     rvecho "${retval}"
447    }
448    
449    print_version()
450    {
451     echo "mcored-$(<${MCLIBDIR}/VERSION)"
452    }
453    
454    system_chroot()
455    {
456     local cmd="$@"
457     if [[ -z ${MROOT} ]]
458     then
459     echo "system_chroot(): \$MROOT was not set, doing nothing!"
460     return 1
461     fi
462     if [ ! -d ${MROOT} ]
463     then
464     eecho "system_chroot(): MROOT='${MROOT}' does not exist."
465     return 1
466     fi
467    
468     chroot ${MROOT} ${cmd}
469    }
470    

Legend:
Removed from v.2005  
changed lines
  Added in v.2083