diff options
Diffstat (limited to 'install.sh')
-rw-r--r-- | install.sh | 45 |
1 files changed, 45 insertions, 0 deletions
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 |