diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | commonnet/local_settings.py.sample | 2 | ||||
-rw-r--r-- | conf/nginx.conf.template | 6 | ||||
-rw-r--r-- | conf/uwsgi.ini.template | 2 | ||||
-rw-r--r-- | install.sh | 45 |
6 files changed, 54 insertions, 5 deletions
@@ -10,3 +10,5 @@ local_settings.py result.json data_src collected_static/* +conf/uwsgi.ini +conf/nginx.conf @@ -27,6 +27,8 @@ migrate: ## apply DB migrations collectstatic: ## web - collect static files to serve $(PYTHON) manage.py collectstatic --no-input +update: collectstatic compilemessages migrate ## update + echo "OK" regenerate_all: migrate ## regenerate all the database $(PYTHON) manage.py createsuperuser diff --git a/commonnet/local_settings.py.sample b/commonnet/local_settings.py.sample index 8c59516..24c10ab 100644 --- a/commonnet/local_settings.py.sample +++ b/commonnet/local_settings.py.sample @@ -11,7 +11,7 @@ DATABASES = { 'ENGINE': 'django.contrib.gis.db.backends.postgis', 'NAME': 'commonnet', 'USER': 'commonnet', - 'PASSWORD': '', + 'PASSWORD': '#PASSWORD#', 'HOST': '127.0.0.1', 'PORT': '5432', } diff --git a/conf/nginx.conf.template b/conf/nginx.conf.template index 703699f..cafac58 100644 --- a/conf/nginx.conf.template +++ b/conf/nginx.conf.template @@ -1,7 +1,7 @@ server { listen 80; server_name #URL#; - root /srv/commonnet/; # install path + root /srv/comm-on-net/; # install path access_log /var/log/django/commonnet-access.log; error_log /var/log/django/commonnet-error.log; @@ -16,12 +16,12 @@ server { client_max_body_size 200M; location /static/ { # STATIC_URL - alias /srv/commonnet/collected_static/; # STATIC_ROOT + alias /srv/comm-on-net/collected_static/; # STATIC_ROOT expires 30d; } location /media/ { # MEDIA_URL - alias /srv/commonnet/media/; # MEDIA_ROOT + alias /srv/comm-on-net/media/; # MEDIA_ROOT expires 30d; } diff --git a/conf/uwsgi.ini.template b/conf/uwsgi.ini.template index 089c952..653dc70 100644 --- a/conf/uwsgi.ini.template +++ b/conf/uwsgi.ini.template @@ -2,7 +2,7 @@ # variables projectname = commonnet projectdomain = #URL# # ex: commonnet.myorganization.net -base = /srv/commonnet/ # install path +base = /srv/comm-on-net/ # install path # config plugins = python diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..480e0f5 --- /dev/null +++ b/install.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +# edit +URL=commonnet.myorganization.net +# stop edit + +echo " * Install dependencies" + +apt install git python3 python3-pip nginx uwsgi-plugin-python3 postgresql apg sed + +PASSWORD=`apg -n 1 -a 1 -m 24 -M CLN` +PWD=`pwd` +DB_NAME=commonnet + +echo " * Creating conf files" + +mkdir -p /var/lib/uwsgi/run +chwow -R www-data:www-data /var/lib/uwsgi/run + +sed -s "s|#PASSWORD#|$PASSWORD|g;" commonnet/local_settings.py.sample \ + conf/local_settings.py +ln -s "$PWD"/conf/local_settings.py commonnet/ + +sed -s "s|#URL#|$URL|g;" conf/uwsgi.ini.template \ + conf/uwsgi.ini +ln -s "$PWD"/conf/uwsgi.ini /etc/uwsgi/apps-enabled/ + +sed -s "s|#URL#|$URL|g;" conf/nginx.conf.template \ + conf/nginx.conf +ln -s "$PWD"/conf/nginx.conf /etc/nginx/sites-enabled/ + +echo " * Checking database $DB_NAME" +if ! psql -l | grep -qs "$DB_NAME"; then + echo " - not present, creating" + createuser --echo --adduser --createdb --encrypted $DB_NAME + psql --command "ALTER USER \""$DB_NAME"\" with password '"$PASSWORD"';" +else + echo " - already present" +fi + +make update + +python3 manage.py createsuperuser + +systemctl restart uwsgi nginx |