Commit 2d575c25 authored by Michaël Paulon's avatar Michaël Paulon

premier essai de script

parent b39f2939
$NOTEREPO="/var/www/note-kfet"
$PGVERSION="9.6"
echo "Hostname: "
read HOSTNAME
echo "Installing apt packages ... "
sudo apt install virtualenv postgresql-$PGVERSION postgresql-plpython-$PGVERSION nginx uwsgi uwsgi-plugin-python3
echo "DONE\n"
echo "Creating user note ... "
sudo adduser --system --group --home $NOTEREPO --no-create-home --disabled-password --disabled-login note
sudo chown -R note:note $NOTEREPO
sudo chmod -R g+w $NOTEREPO
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"
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 systemctl reload postgresql
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
echo "DONE\n"
echo "Uwsgi setup ... "
sudo ln -s $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
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
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