mirror of
https://github.com/telekom-security/tpotce.git
synced 2025-07-02 01:27:27 -04:00
add TPOT_PERSISTENCE_CYCLES setting
- makes logrotate cycles configurable, instead of static 30 days - adjust .env / env.example for setting cycles - adjust tpotinit dockerfile to include envsubst - add logrotate.template - add checks / validations
This commit is contained in:
17
docker/tpotinit/dist/bin/clean.sh
vendored
17
docker/tpotinit/dist/bin/clean.sh
vendored
@ -10,6 +10,9 @@ myPIGZ=$(which pigz)
|
||||
|
||||
# Set persistence
|
||||
myPERSISTENCE=$1
|
||||
myPERSISTENCE_CYCLES=$2
|
||||
myPERSISTENCE_CYCLES="${myPERSISTENCE_CYCLES:=30}"
|
||||
export myPERSISTENCE_CYCLES
|
||||
|
||||
# Let's create a function to check if folder is empty
|
||||
fuEMPTY () {
|
||||
@ -18,6 +21,15 @@ fuEMPTY () {
|
||||
echo $(ls $myFOLDER | wc -l)
|
||||
}
|
||||
|
||||
# Let's create a function to setup logrotate config
|
||||
fuLOGROTATECONF () {
|
||||
local myLOGROTATECONF="/opt/tpot/etc/logrotate/logrotate.conf"
|
||||
local myLOGROTATETEMP="/opt/tpot/etc/logrotate/logrotate.template"
|
||||
envsubst < $myLOGROTATETEMP > $myLOGROTATECONF
|
||||
chown root:root $myLOGROTATECONF
|
||||
chmod 0600 $myLOGROTATECONF
|
||||
}
|
||||
|
||||
# Let's create a function to rotate and compress logs
|
||||
fuLOGROTATE () {
|
||||
local mySTATUS="/data/tpot/etc/logrotate/status"
|
||||
@ -43,6 +55,9 @@ fuLOGROTATE () {
|
||||
local myTANNERF="/data/tanner/files/"
|
||||
local myTANNERFTGZ="/data/tanner/files.tgz"
|
||||
|
||||
# Setup logrotate config
|
||||
fuLOGROTATECONF
|
||||
|
||||
# Ensure correct permissions and ownerships for logrotate to run without issues
|
||||
chmod 770 /data/ -R
|
||||
chown tpot:tpot /data -R
|
||||
@ -408,7 +423,7 @@ fi
|
||||
# Check persistence, if enabled compress and rotate logs
|
||||
if [ "$myPERSISTENCE" = "on" ];
|
||||
then
|
||||
echo "Persistence enabled, now rotating and compressing logs."
|
||||
echo "Persistence enabled for $myPERSISTENCE_CYCLES cycles, now rotating and compressing logs."
|
||||
fuLOGROTATE
|
||||
fi
|
||||
|
||||
|
Reference in New Issue
Block a user