@ -28,7 +28,7 @@ if [ "${status}" != "0" ] && [ "${function_selfname}" == "command_start.sh" ] &&
fi
# Log manager will start the cleanup if it finds logs older than "${logdays}"
if [ $( find " ${ script logdir} " / -type f -mtime +" ${ logdays } " | wc -l) -ne "0" ] ; then
if [ $( find " ${ lgsm logdir} " / -type f -mtime +" ${ logdays } " | wc -l) -ne "0" ] ; then
fn_print_dots "Starting"
# Set common logs directories
commonlogs = " ${ systemdir } /logs "
@ -46,29 +46,29 @@ if [ $(find "${scriptlogdir}"/ -type f -mtime +"${logdays}"|wc -l) -ne "0" ]; th
fn_script_log_info "Removing logs older than " ${ logdays } " days"
# Logging logfiles to be removed according to "${logdays}", counting and removing them
# Script logfiles
find " ${ script logdir} " / -type f -mtime +" ${ logdays } " | tee >> " ${ script log} "
scriptcount = $( find " ${ script logdir} " / -type f -mtime +" ${ logdays } " | wc -l)
find " ${ script logdir} " / -mtime +" ${ logdays } " -type f -exec rm -f { } \;
find " ${ lgsm logdir} " / -type f -mtime +" ${ logdays } " | tee >> " ${ lgsm log} "
scriptcount = $( find " ${ lgsm logdir} " / -type f -mtime +" ${ logdays } " | wc -l)
find " ${ lgsm logdir} " / -mtime +" ${ logdays } " -type f -exec rm -f { } \;
# SRCDS and unreal logfiles
if [ " ${ engine } " = = "unreal2" ] || [ " ${ engine } " = = "source" ] ; then
find " ${ gamelogdir } " / -type f -mtime +" ${ logdays } " | tee >> " ${ script log} "
find " ${ gamelogdir } " / -type f -mtime +" ${ logdays } " | tee >> " ${ lgsm log} "
gamecount = $( find " ${ gamelogdir } " / -type f -mtime +" ${ logdays } " | wc -l)
find " ${ gamelogdir } " / -mtime +" ${ logdays } " -type f -exec rm -f { } \;
fi
# Console logfiles
if [ -n " ${ consolelog } " ] ; then
find " ${ consolelogdir } " / -type f -mtime +" ${ logdays } " | tee >> " ${ script log} "
find " ${ consolelogdir } " / -type f -mtime +" ${ logdays } " | tee >> " ${ lgsm log} "
consolecount = $( find " ${ consolelogdir } " / -type f -mtime +" ${ logdays } " | wc -l)
find " ${ consolelogdir } " / -mtime +" ${ logdays } " -type f -exec rm -f { } \;
fi
# Common logfiles
if [ -d ${ commonlogs } ] ; then
find " ${ commonlogs } " / -type f -mtime +" ${ logdays } " | tee >> " ${ script log} "
if [ -d " ${ commonlogs } " ] ; then
find " ${ commonlogs } " / -type f -mtime +" ${ logdays } " | tee >> " ${ lgsm log} "
smcount = $( find " ${ commonlogs } " / -type f -mtime +" ${ logdays } " | wc -l)
find " ${ commonlogs } " / -mtime +" ${ logdays } " -type f -exec rm -f { } \;
fi
if [ -d ${ commonsourcelogs } ] ; then
find " ${ commonsourcelogs } " /* -type f -mtime +" ${ logdays } " | tee >> " ${ script log} "
find " ${ commonsourcelogs } " /* -type f -mtime +" ${ logdays } " | tee >> " ${ lgsm log} "
smcount = $( find " ${ commonsourcelogs } " /* -type f -mtime +" ${ logdays } " | wc -l)
find " ${ commonsourcelogs } " /* -mtime +" ${ logdays } " -type f -exec rm -f { } \;
fi
@ -76,7 +76,7 @@ if [ $(find "${scriptlogdir}"/ -type f -mtime +"${logdays}"|wc -l) -ne "0" ]; th
if [ " ${ engine } " = = "source" ] ; then
# SourceMod logfiles
if [ -d " ${ sourcemodlogdir } " ] ; then
find " ${ sourcemodlogdir } " / -type f -mtime +" ${ logdays } " | tee >> " ${ script log} "
find " ${ sourcemodlogdir } " / -type f -mtime +" ${ logdays } " | tee >> " ${ lgsm log} "
smcount = $( find " ${ sourcemodlogdir } " / -type f -mtime +" ${ logdays } " | wc -l)
find " ${ sourcemodlogdir } " / -mtime +" ${ logdays } " -type f -exec rm -f { } \;
fi
@ -84,28 +84,22 @@ if [ $(find "${scriptlogdir}"/ -type f -mtime +"${logdays}"|wc -l) -ne "0" ]; th
if [ " ${ gamename } " = = "Garry's Mod" ] ; then
# ULX logfiles
if [ -d " ${ ulxlogdir } " ] ; then
find " ${ ulxlogdir } " / -type f -mtime +" ${ logdays } " | tee >> " ${ script log} "
find " ${ ulxlogdir } " / -type f -mtime +" ${ logdays } " | tee >> " ${ lgsm log} "
ulxcount = $( find " ${ ulxlogdir } " / -type f -mtime +" ${ logdays } " | wc -l)
find " ${ ulxlogdir } " / -mtime +" ${ logdays } " -type f -exec rm -f { } \;
fi
# DarkRP logfiles
if [ -d " ${ darkrplogdir } " ] ; then
find " ${ darkrplogdir } " / -type f -mtime +" ${ logdays } " | tee >> " ${ script log} "
find " ${ darkrplogdir } " / -type f -mtime +" ${ logdays } " | tee >> " ${ lgsm log} "
darkrpcount = $( find " ${ darkrplogdir } " / -type f -mtime +" ${ logdays } " | wc -l)
find " ${ darkrplogdir } " / -mtime +" ${ logdays } " -type f -exec rm -f { } \;
fi
fi
fi
# Legacy support
if [ -d " ${ legacyserverlogdir } " ] ; then
find " ${ legacyserverlogdir } " / -type f -mtime +" ${ logdays } " | tee >> " ${ scriptlog } "
legacycount = $( find " ${ legacyserverlogdir } " / -type f -mtime +" ${ logdays } " | wc -l)
find " ${ legacyserverlogdir } " / -mtime +" ${ logdays } " -type f -exec rm -f { } \;
fi
# Count total amount of files removed
count = $(( ${ scriptcount } + ${ consolecount } + ${ gamecount } + ${ srcdscount } + ${ smcount } + ${ ulxcount } + ${ darkrpcount } + ${ legacy count } ))
countlogs = $(( ${ scriptcount } + ${ consolecount } + ${ gamecount } + ${ srcdscount } + ${ smcount } + ${ ulxcount } + ${ darkrpcount } ))
# Job done
fn_print_ok_nl " Removed ${ count } log files "
fn_script_log " Removed ${ count } log files "
fn_print_ok_nl " Removed ${ countlogs } log files "
fn_script_log " Removed ${ countlogs } log files "
fi