⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shtool

📁 This program is a RADIUS RFC-compliant daemon, which is derived from original Livingston Enterprise
💻
📖 第 1 页 / 共 5 页
字号:
        #   make sure the source is reachable from the destination        if [ $dstisabs = 1 ]; then            if [ $srcisabs = 0 ]; then                if [ ".$srcdir" = . ]; then                    srcdir="`pwd | sed -e 's;/*$;;'`"                    srcisabs=1                    oneisabs=1                elif [ -d $srcdir ]; then                    srcdir="`cd $srcdir; pwd | sed -e 's;/*$;;'`"                    srcisabs=1                    oneisabs=1                fi            fi        fi        #   split away a common prefix        prefix=""        if [ ".$srcdir" = ".$dstdir" ] && [ ".$srcdir" != . ]; then            prefix="$srcdir/"            srcdir=""            dstdir=""        else            while [ ".$srcdir" != . ] && [ ".$dstdir" != . ]; do                presrc=`echo $srcdir | sed -e 's;^\([^/]*\)/.*;\1;'`                predst=`echo $dstdir | sed -e 's;^\([^/]*\)/.*;\1;'`                if [ ".$presrc" != ".$predst" ]; then                    break                fi                prefix="$prefix$presrc/"                srcdir=`echo $srcdir | sed -e 's;^[^/]*/*;;'`                dstdir=`echo $dstdir | sed -e 's;^[^/]*/*;;'`            done        fi        #   destination prefix is just the common prefix        dstpre="$prefix"        #   determine source prefix which is the reverse directory        #   step-up corresponding to the destination directory        srcpre=""        isroot=0        if [ ".$prefix" = . ] || [ ".$prefix" = ./ ]; then            isroot=1        fi        if [ $oneisabs = 0 ] || [ $isroot = 0 ]; then            pl="$dstdir/"            OIFS="$IFS"; IFS='/'            for pe in $pl; do                [ ".$pe" = .  ] && continue                [ ".$pe" = .. ] && continue                srcpre="../$srcpre"            done            IFS="$OIFS"        else            if [ $srcisabs = 1 ]; then                srcpre="$prefix"            fi        fi        #   determine destination symlink name        if [ ".$dstbase" = . ]; then            if [ ".$srcbase" != . ]; then                dstbase="$srcbase"            else                dstbase=`echo "$prefix$srcdir" | sed -e 's;/*$;;' -e 's;.*/\([^/]*\)$;\1;'`            fi        fi        #   now finalize source and destination directory paths        srcdir=`echo $srcdir | sed -e 's;\([^/]\)$;\1/;'`        dstdir=`echo $dstdir | sed -e 's;\([^/]\)$;\1/;'`        #   run the final link command        if [ ".$opt_t" = .yes ]; then            echo "ln$lnopt $srcpre$srcdir$srcbase $dstpre$dstdir$dstbase"        fi        eval ln$lnopt $srcpre$srcdir$srcbase $dstpre$dstdir$dstbase    done    shtool_exit 0    ;;mkshadow )    ##    ##  mkshadow -- Make a shadow tree through symbolic links    ##  Copyright (c) 1998-2004 Ralf S. Engelschall <rse@engelschall.com>    ##    #   source and destination directory    src=`echo "$1" | sed -e 's:/$::' -e 's:^\./\(.\):\1:'`    dst=`echo "$2" | sed -e 's:/$::' -e 's:^\./\(.\):\1:'`    #   check whether source exists    if [ ! -d $src ]; then        echo "$msgprefix:Error: source directory not found: \`$src'" 1>&2        shtool_exit 1    fi    #   determine if one of the paths is an absolute path,    #   because then we have to use an absolute symlink    oneisabs=0    case $src in        /* ) oneisabs=1 ;;    esac    case $dst in        /* ) oneisabs=1 ;;    esac    #   determine reverse directory for destination directory    dstrevdir=''    if [ $oneisabs = 0 ]; then        #   derive reverse path from forward path        pwd=`pwd`        OIFS="$IFS"; IFS='/'        for pe in $dst; do            if [ "x$pe" = "x.." ]; then                OIFS2="$IFS"; IFS="$DIFS"                eval `echo "$pwd" |\                      sed -e 's:\([^/]*\)$:; dir="\1":' \                          -e 's:^\(.*\)/[^/]*;:pwd="\1";:'\                          -e 's:^;:pwd="";:'`                dstrevdir="$dir/$dstrevdir"                IFS="$OIFS2"            else                dstrevdir="../$dstrevdir"            fi        done        IFS="$OIFS"    else        src="`cd $src; pwd`";    fi    #   create directory tree at destination    if [ ! -d $dst ]; then        if [ ".$opt_t" = .yes ]; then            echo "mkdir $dst" 1>&2        fi        mkdir $dst    fi    if [ ".$opt_a" = .yes ]; then        DIRS=`cd $src; find . -type d -print |\              sed -e '/^\.$/d' -e 's:^\./::'`    else        DIRS=`cd $src; find . -type d -print |\              sed -e '/\/CVS/d' -e '/^\.$/d' -e 's:^\./::'`    fi    for dir in $DIRS; do        if [ ".$opt_t" = .yes ]; then            echo "mkdir $dst/$dir" 1>&2        fi        mkdir $dst/$dir    done    #   fill directory tree with symlinks to files    if [ ".$opt_a" = .yes ]; then        FILES="`cd $src; find . -depth -print |\                sed -e 's/^\.\///'`"    else        FILES="`cd $src; find . -depth -print |\                sed -e '/\.o$/d' -e '/\.a$/d' -e '/\.so$/d' \                    -e '/\.cvsignore$/d' -e '/\/CVS/d' \                    -e '/\/\.#/d' -e '/\.orig$/d' \                    -e 's/^\.\///'`"    fi    for file in $FILES; do         #  don't use `-type f' above for find because of symlinks         if [ -d "$src/$file" ]; then             continue         fi         basename=`echo $file | sed -e 's:^.*/::'`         dir=`echo $file | sed -e 's:[^/]*$::' -e 's:/$::' -e 's:$:/:' -e 's:^/$::'`         from=`echo "$src/$file" | sed -e 's/^\.\///'`         to="$dst/$dir$basename"         if [ $oneisabs = 0 ]; then             if [ ".$dir" != . ]; then                 subdir=`echo $dir | sed -e 's:/$::'`                 #   derive reverse path from forward path                 revdir=''                 OIFS="$IFS"; IFS='/'                 for pe in $subdir; do                     revdir="../$revdir"                 done                 IFS="$OIFS"                 #   finalize from                 from="$revdir$from"             fi             from="$dstrevdir$from"         fi         if [ ".$opt_v" = .yes ]; then             echo "    $to" 1>&2         fi         if [ ".$opt_t" = .yes ]; then             echo "ln -s $from $to" 1>&2         fi         ln -s $from $to    done    shtool_exit 0    ;;fixperm )    ##    ##  fixperm -- Fix file permissions inside a source tree    ##  Copyright (c) 1996-2004 Ralf S. Engelschall <rse@engelschall.com>    ##    paths="$*"    #   check whether the test command supports the -x option    if [ -x /bin/sh ] 2>/dev/null; then        minusx="-x"    else        minusx="-r"    fi    #   iterate over paths    for p in $paths; do        for file in `find $p -depth -print`; do            if [ -f $file ]; then                if [ $minusx $file ]; then                    if [ ".$opt_v" = .yes ]; then                        echo "-rwxr-xr-x $file" 2>&1                    fi                    if [ ".$opt_t" = .yes ]; then                        echo "chmod 755 $file" 2>&1                    fi                    chmod 755 $file                else                    if [ ".$opt_v" = .yes ]; then                        echo "-rw-r--r-- $file" 2>&1                    fi                    if [ ".$opt_t" = .yes ]; then                        echo "chmod 644 $file" 2>&1                    fi                    chmod 644 $file                fi                continue            fi            if [ -d $file ]; then                if [ ".$opt_v" = .yes ]; then                    echo "drwxr-xr-x $file" 2>&1                fi                if [ ".$opt_t" = .yes ]; then                    echo "chmod 755 $file" 2>&1                fi                chmod 755 $file                continue            fi            if [ ".$opt_v" = .yes ]; then                echo "?????????? $file" 2>&1            fi        done    done    shtool_exit 0    ;;rotate )    ##    ##  rotate -- Logfile rotation    ##  Copyright (c) 2001-2004 Ralf S. Engelschall <rse@engelschall.com>    ##    #   make sure we have at least one file to rotate    if [ ".$opt_n" = .0 ]; then        echo "$msgprefix:Error: invalid argument \`$opt_n' to option -n." 1>&2        shtool_exit 1    fi    #   canonicalize -s option argument    if [ ".$opt_s" != . ]; then        if [ ".`expr $opt_s : '[0-9]*$'`" != .0 ]; then            :        elif [ ".`expr $opt_s : '[0-9]*[Kk]$'`" != .0 ]; then            opt_s=`expr $opt_s : '\([0-9]*\)[Kk]$'`            opt_s=`expr $opt_s \* 1024`        elif [ ".`expr $opt_s : '[0-9]*[Mm]$'`" != .0 ]; then            opt_s=`expr $opt_s : '\([0-9]*\)[Mm]$'`            opt_s=`expr $opt_s \* 1048576` # 1024*1024        elif [ ".`expr $opt_s : '[0-9]*[Gg]$'`" != .0 ]; then            opt_s=`expr $opt_s : '\([0-9]*\)[Gg]$'`            opt_s=`expr $opt_s \* 1073741824` # 1024*1024*1024        else            echo "$msgprefix:Error: invalid argument \`$opt_s' to option -s." 1>&2            shtool_exit 1        fi    fi    #   option -d/-z consistency    if [ ".$opt_d" = .yes ] && [ ".$opt_z" = . ]; then        echo "$msgprefix:Error: option -d requires option -z." 1>&2        shtool_exit 1    fi    #   make sure target directory exists    if [ ".$opt_a" != . ]; then        if [ ! -d $opt_a ]; then            if [ ".$opt_f" = .no ]; then                echo "$msgprefix:Error: archive directory \`$opt_a' does not exist." 1>&2                shtool_exit 1            fi            mkdir $opt_a || shtool_exit $?            chmod 755 $opt_a        fi        if [ ! -w $opt_a ]; then            echo "$msgprefix:Error: archive directory \`$opt_a' not writable." 1>&2            shtool_exit 1        fi    fi    #   determine compression approach    if [ ".$opt_z" != . ]; then        comp_lvl="$opt_z"        comp_prg=""        case $comp_lvl in            *:* ) eval `echo $comp_lvl |\                        sed -e 's%^\(.*\):\(.*\)$%comp_prg="\1"; comp_lvl="\2"%'` ;;        esac        #   compression level consistency        case $comp_lvl in            [0-9] )                ;;            * ) echo "$msgprefix:Error: invalid compression level \`$comp_lvl'" 1>&2                shtool_exit 1                ;;        esac        #   determine a suitable compression tool        if [ ".$comp_prg" = . ]; then            #   check whether the test command supports the -x option            if [ -x /bin/sh ] 2>/dev/null; then                minusx="-x"            else                minusx="-r"            fi            #   search for tools in $PATH            paths="`echo $PATH |\                    sed -e 's%/*:%:%g' -e 's%/*$%%' \                        -e 's/^:/.:/' -e 's/::/:.:/g' -e 's/:$/:./' \                        -e 's/:/ /g'`"            for prg in bzip2 gzip compress; do                for path in $paths; do                    if [ $minusx "$path/$prg" ] && [ ! -d "$path/$prg" ]; then                        comp_prg="$prg"                        break                    fi                done                if [ ".$comp_prg" != . ]; then                    break                fi            done            if [ ".$comp_prg" = . ]; then                echo "$msgprefix:Error: no suitable compression tool found in \$PATH" 1>&2                shtool_exit 1            fi        fi        #   determine standard compression extension        #   and make sure it is a known tool        case $comp_prg in            */bzip2    | bzip2    ) comp_ext="bz2" comp_lvl="-$comp_lvl" ;;            */gzip     | gzip     ) comp_ext="gz"  comp_lvl="-$comp_lvl" ;;            */compress | compress ) comp_ext="Z";  comp_lvl=""           ;;            * ) echo "$msgprefix:Error: tool \`$comp_prg' is not a known compression tool" 1>&2                shtool_exit 1                ;;        esac        comp_suf=".$comp_ext"    fi    #   iterate over all given logfile arguments    for file in $*; do        #   make sure the logfile exists        if [ ! -f $file ]; then            if [ ".$opt_f" = .yes ]; then                continue            fi            echo "$msgprefix:Error: logfile \`$file' not found" 1>&2            shtool_exit 1        fi        #   determine log directory (where original logfil

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -