refactor: 🔥 Update main branch

This commit is contained in:
Guillaume Barreau
2024-01-26 23:57:07 -05:00
parent 00468ace96
commit 2a13366498
5 changed files with 21 additions and 21 deletions

View File

@@ -5,7 +5,7 @@ DESTINATION_PATH="/palworld/backups"
FILE_PATH="${DESTINATION_PATH}/backup_palworld_${DATE}.tar.gz"
if [ ! -f ${FILE_PATH} ]; then
echo "\e[0;32m***** CREATING BACKUPS FOLDER *****\e[0m\n"
printf "\e[0;32m***** CREATING BACKUPS FOLDER *****\e[0m\n"
mkdir -p "${DESTINATION_PATH}"
fi
@@ -16,9 +16,11 @@ echo "backup created at $FILE_PATH"
if [[ -n "${DAYS_TO_KEEP}" && "${DAYS_TO_KEEP}" =~ ^[0-9]+$ ]]; then
echo "DAYS_TO_KEEP=${DAYS_TO_KEEP}"
find "${DESTINATION_PATH}" -type f -mtime +"${DAYS_TO_KEEP}" -exec rm {} \;
else
echo "DAYS_TO_KEEP is not a valid number."
if [[ "${DAYS_TO_KEEP}" -gt 0 ]]; then
find "${DESTINATION_PATH}" -type f -mtime +"${DAYS_TO_KEEP}" -exec rm {} \;
else
echo "DAYS_TO_KEEP is zero. No files will be removed."
fi
fi

View File

@@ -67,19 +67,16 @@ if [ -n "${RCON_PORT}" ]; then
sed -i "s/RCONPort=[0-9]*/RCONPort=$RCON_PORT/" /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
fi
if [[ -n "${BACKUP_ENABLED}" ]]; then
if [[ -n $BACKUP_ENABLED ]]; then
echo "BACKUP_ENABLED=${BACKUP_ENABLED}"
if [[ -z "${BACKUP_CRON_EXPRESSION}" ]]; then
printf "\e[0;31m***** BACKUP_CRON_EXPRESSION NOT SET *****\e[0m\n"
exit 1
else
echo "BACKUP_CRON_EXPRESSION=${BACKUP_CRON_EXPRESSION}"
if [[ $BACKUP_ENABLED == true ]]; then
CRON_EXPRESSION=$([[ -n $BACKUP_CRON_EXPRESSION ]] && echo "$BACKUP_CRON_EXPRESSION" || echo "0 0 * * *")
echo "CRON_EXPRESSION=${CRON_EXPRESSION}"
echo "${CRON_EXPRESSION} root bash /usr/loca/bin/backup" > /etc/cron.d/backups-cron
chmod 0644 /etc/cron.d/backups-cron
cron /etc/cron.d/backups-cron
fi
echo "${BACKUP_CRON_EXPRESSION} root bash /usr/local/bin/backup" > /etc/cron.d/backups-cron
chmod 0644 /etc/cron.d/backups-cron
cron /etc/cron.d/backups-cron
fi
# Configure RCON settings