Force Expire

#*********************************************************
#* Manually set dirvish vaults to expire.                *
#*                                                       *
#* Set vault expire time to expire 'last year'           *
#*                                                       *
#* Created 2005-12-23                                    *
#*********************************************************

#*********************************************************
# Make sure there is a paramater
#*********************************************************

if [ "$1" = "" ] ; then
        echo "Oops, I need a parameter"
        echo "example:  $0 \*"
        echo "          $0 2005-10*"
        exit
fi

        #*********************************************************
        # Check to make sure that we are IN a vault directory
        #*********************************************************

        if [ ! -f dirvish/default.conf ] ; then
                echo "This does not appear to be a dirvish vault. exiting"
                exit
        fi

#*********************************************************
# Begin cycling through all of the directories in search
# of summary files.
#*********************************************************

for CYCLE in $@ ; do



        #*********************************************************
        # If the CYCLE evaluated is the first of a month. end this
        # CYCLE.
        #*********************************************************

        CYCLEDATE=`echo $CYCLE | cut -b 9-10`
        if [ "$CYCLEDATE" = "01" ] ; then
                echo "Skipping $CYCLE because it's a monthly"
                continue        #Skip to the next instance of CYCLE
        fi

        #*********************************************************
        # If the current CYCLE has a summary file, evaluate it
        # and pull out the current expire year
        #*********************************************************

        if [ -f $CYCLE/summary ] ; then

                #*********************************************************
                # Grab the current expire year, calculate new expire year
                #*********************************************************
                ORGYEAR=`grep Expire $CYCLE/summary | cut -f5 -d\ |cut -b 1-4`
                NEWYEAR=$ORGYEAR
                NEWYEAR=$[ NEWYEAR = $NEWYEAR - 1 ]

                #*********************************************************
                # Replace the ORGYEAR with NEWYEAR in the summary file
                #*********************************************************
                sed s/\=\=\ $ORGYEAR/\=\=\ $NEWYEAR/g < $CYCLE/summary >$CYCLE/summary.new 
               mv  $CYCLE/summary.new $CYCLE/summary

        fi

done

ForceExpire (last edited 2011-01-24 05:03:07 by KeithLofstrom)