Commit 349010cc authored by Michaël Paulon's avatar Michaël Paulon

minor fixes (it works... maybe)

parent 850f49a6
$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