Skip to content
Snippets Groups Projects

block prune.sh if prune-after = never

Merged Hahn Axel (hahn) requested to merge block_prune_on_rest_append_only into master
1 file
+ 23
11
Compare changes
  • Side-by-side
  • Inline
+ 23
11
@@ -141,6 +141,7 @@ function _getFileAge(){
function setAction(){
local action=$1
local myfile=$2
local doforce=$3
local iLimit
iLimit=$(_j_getvar ${STORAGEFILE} "${action}-after")
@@ -154,16 +155,21 @@ function setAction(){
echo "Info: $action is ENABLED - no last $action detected"
doValue=1
else
typeset -i iLastDone
iLastDone=$( _getFileAge "${myfile}" )/60
typeset -i iLastDoneD=iLastDone/60/24
echo "Info: Last $action was $iLastDone min ago ($iLastDoneD days). Limit is $iLimit days."
if [ $iLastDoneD -ge $iLimit ]; then
echo "Info: $action is ENABLED - last $action is outdated"
if [ "$doforce" -eq "1" ]; then
echo "Force $action"
doValue=1
else
echo "Info: $action is not needed yet."
doValue=0
typeset -i iLastDone
iLastDone=$( _getFileAge "${myfile}" )/60
typeset -i iLastDoneD=iLastDone/60/24
echo "Info: Last $action was $iLastDone min ago ($iLastDoneD days). Limit is $iLimit days."
if [ $iLastDoneD -ge $iLimit ]; then
echo "Info: $action is ENABLED - last $action is outdated"
doValue=1
else
echo "Info: $action is not needed yet."
doValue=0
fi
fi
fi
}
@@ -193,8 +199,8 @@ function setAction(){
# set defaults for prune and verify
echo ">>> Detect default behaviour:"
setAction "prune" "$lastprunefile"; doPrune=$doValue
setAction "verify" "$lastverifyfile"; doVerify=$doValue
setAction "prune" "$lastprunefile" 0; doPrune=$doValue
setAction "verify" "$lastverifyfile" 0; doVerify=$doValue
echo
echo ">>> Check parameters"
@@ -202,7 +208,7 @@ function setAction(){
echo "Info: Forcing prune only by parameter."
ACTION=$1
doBackup=0
doPrune=1
setAction "prune" "$lastprunefile" 1; doPrune=$doValue
doVerify=0
transferlog="${DIR_LOGS}/prune-$(date +%Y%m%d-%H%M%S).log"
fi
@@ -214,6 +220,12 @@ function setAction(){
doVerify=1
transferlog="${DIR_LOGS}/verify-$(date +%Y%m%d-%H%M%S).log"
fi
if [ "${doBackup}${doPrune}${doVerify}" = "000" ]; then
echo "Nothing to do. Aborting."
exit 0
fi
exec 1> >( tee -a "$transferlog" ) 2>&1
echo "INFO: Start logging into $transferlog"
Loading