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

premier essai de script

parent b39f2939
echo "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/ migrate
sudo -u note $NOTEREPO/note_kfet/
sudo -u note $NOTEREPO/note_kfet/
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 " and setup ..."
cp $NOTEREPO/note_kfet/ $NOTEREPO/note_kfet/
cp $NOTEREPO/note_kfet/ $NOTEREPO/note_kfet/
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/
sed -e "s/SITE_DOMAIN = Note/SITE_DOMAIN = '$HOSTNAME'/" $NOTEREPO/note_kfet/
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