feat: Add variables Env for cron feature

This commit is contained in:
Guillaume Barreau
2024-01-25 07:09:30 -05:00
parent 735ae33392
commit 918c32c623
6 changed files with 56 additions and 25 deletions

View File

@@ -1,13 +1,11 @@
#!/bin/bash
printf "\e[0;34m***** RUNNING SCRIPTS backup.sh *****\e[0m\n"
DATE=$(date +"%Y-%m-%d_%H-%M-%S")
DESTINATION_PATH="/palworld/backups"
FILE_PATH="${DESTINATION_PATH}/backup_palworld_${DATE}.tar.gz"
if [ ! -f ${FILE_PATH} ]; then
printf "\e[0;32m***** CREATING BACKUPS FOLDER *****\e[0m\n"
echo "\e[0;32m***** CREATING BACKUPS FOLDER *****\e[0m\n"
mkdir -p "${DESTINATION_PATH}"
fi
@@ -16,4 +14,11 @@ cd /palworld/Pal/ || exit
tar -zcf "$FILE_PATH" "Saved/"
echo "backup created at $FILE_PATH"
find "${DESTINATION_PATH}" -type f -name "backup_palworld_*.tar.gz" -ctime +7 -exec rm -f {} \;
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."
fi

View File

@@ -1,7 +1,5 @@
#!/bin/bash
printf "\e[0;34m***** RUNNING SCRIPTS init.sh *****\e[0m\n"
if [[ ! "${PUID}" -eq 0 ]] && [[ ! "${PGID}" -eq 0 ]]; then
printf "\e[0;32m*****EXECUTING USERMOD*****\e[0m\n"
usermod -o -u "${PUID}" steam

View File

@@ -1,7 +1,5 @@
#!/bin/bash
printf "\e[0;34m***** RUNNING SCRIPTS start.sh *****\e[0m\n"
STARTCOMMAND="./PalServer.sh"
if [ -n "${PORT}" ]; then
@@ -69,6 +67,21 @@ 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
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}"
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
cat >~/.rcon-cli.yaml <<EOL
host: localhost