Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.88 KB | None | 0 0
  1. set -e
  2. sudo apt-get update
  3. sudo apt-get install -y curl build-essential python-dev libevent-dev libpq-dev libjpeg8 libjpeg-dev libfreetype6 libfreetype6-dev virtualenv postgresql postgresql-contrib postgis
  4. # make sure directory $1 doesn't exist
  5. if [[ -d $1 ]]; then
  6.     echo "Directory $1 exits already. Use a different name"
  7.     exit 1
  8. fi
  9. # make sure database $1 doesn't exist
  10. if sudo -i -u postgres psql -lqt | cut -d \| -f 1 | grep -qw $1; then
  11.     echo "Database $1 exits already. Use a different name"
  12.     exit 1
  13. fi
  14. VENV=venv-$1
  15. virtualenv --python=python2.7 $VENV
  16. $VENV/bin/pip install "Django>=1.8,<1.9"
  17. # XXX: django-debug-toolbar doesn't work in Django 1.8
  18. $VENV/bin/pip install "django-debug-toolbar==1.9.1"
  19. DB_USER=$1
  20. DB_PASS=$1
  21. DB_NAME=$1
  22. sudo -i -u postgres psql -c "CREATE USER $DB_USER WITH PASSWORD '$DB_PASS';"
  23. sudo -i -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER;"
  24. sudo -i -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE $DB_NAME TO $DB_USER;"
  25. sudo -i -u postgres psql -d $DB_NAME -c "CREATE EXTENSION postgis;"
  26. sudo -i -u postgres psql -d $DB_NAME -c "CREATE EXTENSION postgis_topology;"
  27. sudo -i -u postgres psql -d $DB_NAME -c "CREATE EXTENSION fuzzystrmatch;"
  28. sudo -i -u postgres psql -d $DB_NAME -c "CREATE EXTENSION postgis_tiger_geocoder;"
  29. sudo -i -u postgres psql -d $DB_NAME -c "CREATE EXTENSION pg_stat_statements;"
  30. $VENV/bin/django-admin.py startproject --template=https://github.com/tendenci/tendenci-project-template/archive/tendenci7.zip $1
  31. cd $1
  32. ../$VENV/bin/pip install -r requirements/dev.txt
  33. curl https://gist.githubusercontent.com/jennyq/45de71a93cff774c593d/raw/30ede14eb133de66cc839cc0458a1e915368534e/setup_keys.sh | bash
  34. sed -i "s/<DB_NAME>/$1/g" conf/local_settings.py
  35. sed -i "s/<DB_USER>/$1/g" conf/local_settings.py
  36. sed -i "s/<DB_PASS>/$1/g" conf/local_settings.py
  37. UBUNTU_VERSION=`lsb_release -r | awk '{print $2}'`
  38. if [ "$UBUNTU_VERSION" == "18.04" ]; then
  39.     # https://stackoverflow.com/questions/18643998/geodjango-geosexception-error
  40.     sed -i "s/ver = geos_version().decode()/ver = geos_version().decode().split(' ')[0]/g" ../$VENV/lib/python2.7/site-packages/django/contrib/gis/geos/libgeos.py
  41. fi
  42. ../$VENV/bin/python manage.py migrate --noinput
  43. ../$VENV/bin/python manage.py collectstatic --noinput
  44. ../$VENV/bin/python manage.py update_settings
  45. ../$VENV/bin/python manage.py clear_theme_cache
  46. ../$VENV/bin/python manage.py populate_default_entity
  47. ../$VENV/bin/python manage.py populate_entity_and_auth_group_columns
  48. ../$VENV/bin/python manage.py load_creative_defaults
  49. chmod -R -x+X media
  50. ../$VENV/bin/python manage.py createsuperuser --noinput --username=admin --email=admin@example.com
  51. echo "from django.contrib.auth.models import User; superuser = User.objects.get(username='admin'); superuser.set_password('admin'); superuser.save()" | ../$VENV/bin/python manage.py shell
  52. ../$VENV/bin/python manage.py runserver
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement