Skip to content
Snippets Groups Projects
Commit 771a4759 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

block prune.sh if prune-after = never

parent 86ee8dfd
No related branches found
No related tags found
1 merge request!125block prune.sh if prune-after = never
...@@ -141,6 +141,7 @@ function _getFileAge(){ ...@@ -141,6 +141,7 @@ function _getFileAge(){
function setAction(){ function setAction(){
local action=$1 local action=$1
local myfile=$2 local myfile=$2
local doforce=$3
local iLimit local iLimit
iLimit=$(_j_getvar ${STORAGEFILE} "${action}-after") iLimit=$(_j_getvar ${STORAGEFILE} "${action}-after")
...@@ -154,16 +155,21 @@ function setAction(){ ...@@ -154,16 +155,21 @@ function setAction(){
echo "Info: $action is ENABLED - no last $action detected" echo "Info: $action is ENABLED - no last $action detected"
doValue=1 doValue=1
else else
typeset -i iLastDone if [ "$doforce" -eq "1" ]; then
iLastDone=$( _getFileAge "${myfile}" )/60 echo "Force $action"
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 doValue=1
else else
echo "Info: $action is not needed yet." typeset -i iLastDone
doValue=0 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
fi fi
} }
...@@ -193,8 +199,8 @@ function setAction(){ ...@@ -193,8 +199,8 @@ function setAction(){
# set defaults for prune and verify # set defaults for prune and verify
echo ">>> Detect default behaviour:" echo ">>> Detect default behaviour:"
setAction "prune" "$lastprunefile"; doPrune=$doValue setAction "prune" "$lastprunefile" 0; doPrune=$doValue
setAction "verify" "$lastverifyfile"; doVerify=$doValue setAction "verify" "$lastverifyfile" 0; doVerify=$doValue
echo echo
echo ">>> Check parameters" echo ">>> Check parameters"
...@@ -202,7 +208,7 @@ function setAction(){ ...@@ -202,7 +208,7 @@ function setAction(){
echo "Info: Forcing prune only by parameter." echo "Info: Forcing prune only by parameter."
ACTION=$1 ACTION=$1
doBackup=0 doBackup=0
doPrune=1 setAction "prune" "$lastprunefile" 1; doPrune=$doValue
doVerify=0 doVerify=0
transferlog="${DIR_LOGS}/prune-$(date +%Y%m%d-%H%M%S).log" transferlog="${DIR_LOGS}/prune-$(date +%Y%m%d-%H%M%S).log"
fi fi
...@@ -214,6 +220,12 @@ function setAction(){ ...@@ -214,6 +220,12 @@ function setAction(){
doVerify=1 doVerify=1
transferlog="${DIR_LOGS}/verify-$(date +%Y%m%d-%H%M%S).log" transferlog="${DIR_LOGS}/verify-$(date +%Y%m%d-%H%M%S).log"
fi fi
if [ "${doBackup}${doPrune}${doVerify}" = "000" ]; then
echo "Nothing to do. Aborting."
exit 0
fi
exec 1> >( tee -a "$transferlog" ) 2>&1 exec 1> >( tee -a "$transferlog" ) 2>&1
echo "INFO: Start logging into $transferlog" echo "INFO: Start logging into $transferlog"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment