Skip to content

Commit

Permalink
Merge pull request #248 from Dashboy1998/wait-for-backups
Browse files Browse the repository at this point in the history
Added waiting for backups to complete before stopping
  • Loading branch information
thijsvanloef authored Feb 1, 2024
2 parents 689674b + 9c8b6f8 commit b90c41c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions scripts/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ DATE=$(date +"%Y-%m-%d_%H-%M-%S")
FILE_PATH="/palworld/backups/palworld-save-${DATE}.tar.gz"
cd /palworld/Pal/ || exit

echo "Creating backup"
tar -zcf "$FILE_PATH" "Saved/"

if [ "$(id -u)" -eq 0 ]; then
Expand Down
12 changes: 10 additions & 2 deletions scripts/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,20 @@ term_handler() {
else # Does not save
kill -SIGTERM "$(pidof PalServer-Linux-Test)"
fi
tail --pid=$killpid -f 2>/dev/null
tail --pid="$killpid" -f 2>/dev/null
}

trap 'term_handler' SIGTERM

su steam -c ./start.sh &
# Process ID of su
killpid="$!"
wait $killpid
wait "$killpid"

mapfile -t backup_pids < <(pgrep backup)
if [ "${#backup_pids[@]}" -ne 0 ]; then
echo "Waiting for backup to finish"
for pid in "${backup_pids[@]}"; do
tail --pid="$pid" -f 2>/dev/null
done
fi

0 comments on commit b90c41c

Please sign in to comment.