a guest Oct 9th, 2019 104 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. set -e
  2. sudo add-apt-repository universe
  3. sudo apt-get update
  4. sudo apt-get install -y python3-virtualenv build-essential python3-dev libevent-dev libpq-dev libjpeg8 libjpeg-dev libfreetype6 libfreetype6-dev postgresql postgresql-contrib postgis
  5. # make sure directory $1 doesn't exist
  6. if [[ -d $1 ]]; then
  7.     echo "Directory $1 exits already. Use a different name"
  8.     exit 1
  9. fi
  10. # make sure database $1 doesn't exist
  11. if sudo -i -u postgres psql -lqt | cut -d \| -f 1 | grep -qw $1; then
  12.     echo "Database $1 exits already. Use a different name"
  13.     exit 1
  14. fi
  15. VENV=venv-$1
  16. python3.6 -m virtualenv -p python3.6 $VENV
  17. $VENV/bin/pip install "Django>=1.11,<2.0"
  18. DB_USER=$1
  19. DB_PASS=$1
  20. DB_NAME=$1
  21. sudo -i -u postgres psql -c "CREATE USER $DB_USER WITH PASSWORD '$DB_PASS';"
  22. sudo -i -u postgres psql -c "ALTER ROLE $DB_USER SET client_encoding TO 'UTF8';"
  23. sudo -i -u postgres psql -c "ALTER ROLE $DB_USER SET default_transaction_isolation TO 'read committed';"
  24. sudo -i -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER;"
  25. sudo -i -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE $DB_NAME TO $DB_USER;"
  26. sudo -i -u postgres psql -d $DB_NAME -c "CREATE EXTENSION postgis;"
  27. sudo -i -u postgres psql -d $DB_NAME -c "CREATE EXTENSION postgis_topology;"
  28. sudo -i -u postgres psql -d $DB_NAME -c "CREATE EXTENSION fuzzystrmatch;"
  29. sudo -i -u postgres psql -d $DB_NAME -c "CREATE EXTENSION postgis_tiger_geocoder;"
  30. sudo -i -u postgres psql -d $DB_NAME -c "CREATE EXTENSION pg_stat_statements;"
  31. $VENV/bin/ startproject --template= $1
  32. cd $1
  33. mkdir themes/tendenci2018
  34. ../$VENV/bin/pip install psycopg2
  35. ../$VENV/bin/pip install --no-binary psycopg2 -r requirements/dev.txt --upgrade
  36. _SECRET_KEY=`../$VENV/bin/python -c 'from import utils; print(utils.get_random_secret_key())'`
  37. _SITE_SETTINGS_KEY=`../$VENV/bin/python -c 'from import utils; print(utils.get_random_secret_key())'`
  38. sed -i "s/^SECRET_KEY = ''$/SECRET_KEY = '$_SECRET_KEY'/g" conf/
  39. sed -i "s/^SITE_SETTINGS_KEY = ''$/SITE_SETTINGS_KEY = '$_SITE_SETTINGS_KEY'/g" conf/
  40. sed -i "s/^#DATABASES\['default'\]\['USER'\] = 'tendenci'$/DATABASES['default']['USER'] = '$1'/g" conf/
  41. sed -i "s/^#DATABASES\['default'\]\['PASSWORD'\] = 'tendenci'$/DATABASES['default']['PASSWORD'] = '$1'/g" conf/
  42. sed -i "s/^#DATABASES\['default'\]\['NAME'\] = 'tendenci'$/DATABASES['default']['NAME'] = '$1'/g" conf/
  43. sed -i "s|^TIME_ZONE = 'US/Central'$|TIME_ZONE = 'US/Eastern'|g" conf/
  44. sed -i "s/^#DEBUG = True$/DEBUG = True/g" conf/
  45. sed -i "s|^#set_app_log_filename('/var/log/mysite/app.log')$|set_app_log_filename('app.log')|g" conf/
  46. sed -i "s|^#set_debug_log_filename('/var/log/mysite/debug.log')$|set_debug_log_filename('debug.log')|g" conf/
  47. sed -i "s/^#enable_console_log()$/enable_console_log()/g" conf/
  48. sed -i "s/^#set_console_log_level('INFO')$/set_console_log_level('DEBUG')/g" conf/  #if error comment it
  49. cp -r ../$VENV/lib/python3.6/site-packages/tendenci/themes/t7-tendenci2018/* themes/tendenci2018
  50. ../$VENV/bin/python initial_migrate
  51. ../$VENV/bin/python deploy
  52. ../$VENV/bin/python update_dashboard_stats
  53. chmod -R -x+X media
  54. # XXX: remove?
  55. ../$VENV/bin/python load_tendenci2018_defaults #no needed
  56. ../$VENV/bin/python set_setting site global siteurl ''
  57. ../$VENV/bin/python createsuperuser --noinput --username=admin
  58. ../$VENV/bin/python shell -c "from django.contrib.auth.models import User; superuser = User.objects.get(username='admin'); superuser.set_password('admin');"
  59. ../$VENV/bin/python runserver
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!