Skip to content

Instantly share code, notes, and snippets.

@sevenearths
Last active May 12, 2020 09:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sevenearths/098d35616d4c4d05dd28a813b609fd36 to your computer and use it in GitHub Desktop.
Save sevenearths/098d35616d4c4d05dd28a813b609fd36 to your computer and use it in GitHub Desktop.
A script for helping update a Django (https://www.djangoproject.com/) site
#!/bin/bash
if [[ "$EUID" = 0 ]]; then
echo "Do not run this script as root"
exit 0
else
sudo -k
if sudo true; then
sudo service apache2 stop
cd /var/www/
source venv/bin/activate 2>&1
cd django
GIT_BRANCH="$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')"
git pull origin ${GIT_BRANCH} 2>&1
pip install -r requirements.txt 2>&1
python crazyfacts/manage.py compilescss 2>&1
python crazyfacts/manage.py collectstatic 2>&1
python crazyfacts/manage.py makemigrations 2>&1
python crazyfacts/manage.py migrate 2>&1
deactivate 2>&1
sudo service apache2 start 2>&1
exit 1
else
echo "Password incorrect. Script not executed"
exit 0
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment