From e2f285b7306aace9b1aea89ee5eb7ce7937efb36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20M=C3=BCnch?= Date: Fri, 19 Jun 2020 11:44:39 +0000 Subject: [PATCH] formatting, parameterising, add user safety check --- update | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/update b/update index b1fdba4..b1f31b5 100755 --- a/update +++ b/update @@ -2,19 +2,34 @@ set -e -echo "cloning ..." +web_user="www-data" +user="willipink" +path="/home/willipink/coinmanager" + +if [[ "$USER" != "$user" ]]; then + echo "You must be '$user' to run this file." + exit 1 +fi + +cd $path/coinmanager + +echo -n "fetching " git pull -q origin master >/dev/null +echo "..." -echo "collecting ..." -cd /home/willipink/coinmanager/coinmanager +echo -n "collecting " pipenv run python manage.py collectstatic --settings coinmanager.production_settings --no-input >/dev/null +echo "..." -echo "bumping ..." +echo -n "bumping " version=$(date +"%y%m%d") -sed -i "s/[0-9]\{6\}/$version/g" coinc/templates/footer.html +sed -i "s/[0-9]\{6\}/$version/g" coinc/templates/footer.html >/dev/null +echo "..." -echo "owning ..." -sudo chown -R willipink:www-data /home/willipink/coinmanager >/dev/null +echo -n "owning " +sudo chown -R $user:$web_user $path >/dev/null +echo "..." -echo "reloading ..." +echo -n "reloading " sudo systemctl reload apache2 >/dev/null +echo "..."