From 61b42619a7037da4e03c817caa032d0f9b494758 Mon Sep 17 00:00:00 2001 From: Cameron Hyde Date: Fri, 4 Oct 2024 08:58:11 +1000 Subject: [PATCH] Fix ansible update.sh.j2 template --- .../galaxy_media_site/templates/update.sh.j2 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/deploy/ansible/roles/galaxy_media_site/templates/update.sh.j2 b/deploy/ansible/roles/galaxy_media_site/templates/update.sh.j2 index 0d12c7f..3c2f43a 100644 --- a/deploy/ansible/roles/galaxy_media_site/templates/update.sh.j2 +++ b/deploy/ansible/roles/galaxy_media_site/templates/update.sh.j2 @@ -4,31 +4,31 @@ set -e -# Make sure this isn't being run as root -if [[ $EUID = 0 ]]; then - echo "Don't run this as root - ubuntu is fine!" +# Ensure run as root +if [[ $EUID != 0 ]]; then + echo "Must be run as root - use sudo" exit 0 fi # Source virtual environment and git pull -cd galaxy-content-site +cd {{ project_root }} source '{{ venv_root }}/bin/activate' git pull python -m pip install -r requirements.txt -cd webapp +cd {{ django_root }} # Collect any new static files for Nginx if neccessary python manage.py collectstatic --noinput # Migrate the database (if necessary) -python manage.py migrate +sudo -u www-data python manage.py migrate # Update file ownership to allow www-data to write logs/media -sudo chown -R www-data:www-data webapp/logs -sudo chown -R www-data:www-data webapp/media +chown -R www-data:www-data webapp/logs +chown -R www-data:www-data webapp/media # Restart the GMS web service -sudo service gms restart +service gms restart echo "" echo "~~~ Restarted Galaxy Media Site ~~~"