From d82cb9435d8e587f4cb199c6d6023e3b48838417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Sat, 1 Aug 2020 12:51:51 +0200 Subject: [PATCH] fix exit trap --- offgrid_pile.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/offgrid_pile.sh b/offgrid_pile.sh index 32950cf..51cbac5 100755 --- a/offgrid_pile.sh +++ b/offgrid_pile.sh @@ -1,6 +1,11 @@ #!/bin/bash set -e +function finish() { + echo "$(date) Cleaning up..." + kill "${SERVER_PID}" 2>/dev/null + rm -r "${TMP_DIR}" +} echo "$(date) Syncing database..." rsync -v sdbs:/var/www/sdbs-pile/db.sqlite3 . echo "$(date) Syncing /docs..." @@ -11,6 +16,8 @@ OUT_DIR="${TMP_DIR}/sdbs_pile" mkdir -p "${OUT_DIR}" echo "$(date) Will backup into ${OUT_DIR}" +trap finish EXIT + echo "$(date) Starting local pile server" source .venv/bin/activate STATIC=1 python manage.py runserver 4123 & @@ -29,10 +36,3 @@ kill "${SERVER_PID}" echo "$(date) Compressing archive..." 7z a sdbs_pile__$(date "+%Y-%m-%d__%H%M%S").7z "${OUT_DIR}" - -function finish() { - echo "$(date) Cleaning up..." - kill "${SERVER_PID}" 2>/dev/null - rm -r "${TMP_DIR}" -} -trap finish EXIT