Commit 23f4360d authored by Michaël Paulon's avatar Michaël Paulon

Merge branch 'mikachu_django_2' into 'master'

Scripts and profile crash fix

See merge request !1
parents a6bf7376 23cdd110
......@@ -255,7 +255,6 @@ $("#idCompteStatus").click(function () {
} else {
activate = true;
}
xhr('{{ url("api:comptes:adherent-status", kwargs={"pk" : object.pk}) }}', 'PATCH', {'is_active' : activate}, changeStatus, showError);
});
// Ajout/Suppression d'aliases
......
......@@ -5,7 +5,7 @@ upstream note-kfet {
server {
listen 80;
listen [::]:80;
server_name note.paulon.org;
server_name ouilagueguerre.paulon.org note.dev.kfet.fr lhcb.kataclist.fr miaouss.paulon.org;
server_tokens off;
return 301 https://$http_host$request_uri;
......@@ -14,14 +14,14 @@ server {
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name note.paulon.org;
server_name ouilagueguerre.paulon.org note.dev.kfet.fr lhcb.kataclist.fr miaouss.paulon.org;
server_tokens off;
keepalive_timeout 70;
ssl_protocols TLSv1.1 TLSv1.2;
ssl_certificate /usr/certs/paulon.org_fullchain.pem;
ssl_certificate_key /usr/certs/paulon.org_privkey.pem;
ssl_certificate /var/www/note-kfet/certs/note.crt;
ssl_certificate_key /var/www/note-kfet/certs/note.key;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
......
$NOTEREPO="/var/www/note-kfet"
$PGVERSION="9.6"
NOTEREPO="/var/www/note-kfet"
PGVERSION="9.6"
echo "Hostname: "
read HOSTNAME
......@@ -9,7 +9,7 @@ read HOSTNAME
echo "Installing apt packages ... "
sudo apt install virtualenv postgresql-$PGVERSION postgresql-plpython-$PGVERSION nginx uwsgi uwsgi-plugin-python3
sudo apt install virtualenv postgresql-$PGVERSION postgresql-plpython3-$PGVERSION nginx uwsgi uwsgi-plugin-python3
echo "DONE\n"
echo "Creating user note ... "
......@@ -20,40 +20,39 @@ sudo find $NOTEREPO -type d -exec chmod g+s {} \;
echo "DONE\n"
echo "Virtualenv setup ... "
virtualenv -p python3 $NOTEREPO/.env
sudo chown -R note:note $NOTEREPO/.env
sudo -u note sh -c "source $NOTEREPO/.env/bin/activate; pip3 install django psycopg2 jinja2 django-filter djangorestframework drf-nested-routers pillow"
sudo -u note virtualenv -p python3 $NOTEREPO/.env
sudo -u note sh -c "$NOTEREPO/.env/bin/pip3 install django psycopg2 jinja2 django-filter djangorestframework drf-nested-routers pillow"
echo "DONE\n"
echo "Creating database ... "
sudo -u postgres psql -c "CREATE USER note;"
sudo -u postgres psql -c "CREATE DATABASE note_kfet OWNER note;"
echo "local\tnote_kfet\tnote\ttrust" | sudo tee --append /etc/postgresql/9.6/main/pg_hba.conf
sudo sed -i -e "$a local\tnote_kfet\tnote\ttrust" /etc/postgresql/9.6/main/pg_hba.conf
sudo systemctl reload postgresql
echo "DONE\n"
echo "secrets.py and settings.py setup ..."
sudo -u note cp $NOTEREPO/note_kfet/settings.py.example $NOTEREPO/note_kfet/settings.py
sudo -u note cp $NOTEREPO/note_kfet/secrets.py.example $NOTEREPO/note_kfet/secrets.py
SECRET_KEY=$(python3 -c 'import random; result = "".join([random.choice("abcdefghijklmnopqrstuvwxyz0123456789") for i in range(50)]); print(result)')
sudo -u note sed -i -e "s/'\s*Mettez la clef secrete de votre projet ici\s*'/'$SECRET_KEY'/" $NOTEREPO/note_kfet/secrets.py
sudo -u note sed -i -e "s/SITE_DOMAIN = None/SITE_DOMAIN = '$HOSTNAME'/" $NOTEREPO/note_kfet/settings.py
echo "DONE\n"
echo "Database setup ... "
sudo -u note $NOTEREPO/manage.py migrate
sudo -u note $NOTEREPO/note_kfet/triggers.py
sudo -u note $NOTEREPO/note_kfet/db_initial.py
sudo -u note sh -c "$NOTEREPO/.env/bin/python3 $NOTEREPO/manage.py migrate"
sudo -u postgres sh -c "$NOTEREPO/.env/bin/python3 $NOTEREPO/note_kfet/triggers.py"
sudo -u note sh -c "$NOTEREPO/.env/bin/python3 $NOTEREPO/note_kfet/db_initial.py"
echo "DONE\n"
echo "Uwsgi setup ... "
sudo ln -s $NOTEREPO/note_kfet/note.uwsgi /etc/uwsgi/apps-available/note.ini
sudo cp $NOTEREPO/note_kfet/note.uwsgi /etc/uwsgi/apps-available/note.ini
sudo ln -s ../apps-available/note.ini /etc/uwsgi/apps-enabled/note.ini
sudo service uwsgi reload
sudo service uwsgi restart
echo "DONE\n"
echo "Nginx setup ... "
sudo ln -s $NOTEREPO/note_kfet/note.nginx /etc/nginx/sites-available/note
sudo ln -s ../sites-available/note.ini /etc/nginx/sites-enabled/note
sudo service nginx reload
echo "DONE"
echo "secrets.py and settings.py setup ..."
cp $NOTEREPO/note_kfet/settings.py.example $NOTEREPO/note_kfet/settings.py
cp $NOTEREPO/note_kfet/secrets.py.example $NOTEREPO/note_kfet/secrets.py
SECRET_KEY=$(python -c 'import random; result = "".join([random.choice("abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)") for i in range(50)]); print(result)')
sed -e "s/SECRET_KEY = ' Mettez la clef secrete de votre projet ici '/SECRET_KEY = '$SECRET_KEY'/" $NOTEREPO/note_kfet/secrets.py
sed -e "s/SITE_DOMAIN = Note/SITE_DOMAIN = '$HOSTNAME'/" $NOTEREPO/note_kfet/settings.py
sudo cp $NOTEREPO/note_kfet/note.nginx /etc/nginx/sites-available/note
sudo ln -s ../sites-available/note /etc/nginx/sites-enabled/note
sudo service nginx restart
echo "DONE\n"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment