2016-05-26 04:06:17 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2018-02-11 17:01:26 +01:00
|
|
|
# Stop if an error is encountered
|
|
|
|
set -e
|
|
|
|
|
2016-05-26 04:06:17 +02:00
|
|
|
# Configuration de la base de données. Le mot de passe est constant car c'est
|
|
|
|
# pour une installation de dév locale qui ne sera accessible que depuis la
|
|
|
|
# machine virtuelle.
|
|
|
|
DBUSER="cof_gestion"
|
|
|
|
DBNAME="cof_gestion"
|
|
|
|
DBPASSWD="4KZt3nGPLVeWSvtBZPSM3fSzXpzEU4"
|
|
|
|
|
|
|
|
# Installation de paquets utiles
|
2017-05-21 19:42:30 +02:00
|
|
|
apt-get update && apt-get upgrade -y
|
2017-08-09 23:07:49 +02:00
|
|
|
apt-get install -y python3-pip python3-dev python3-venv libpq-dev postgresql \
|
|
|
|
postgresql-contrib libjpeg-dev nginx git redis-server
|
2016-05-26 04:06:17 +02:00
|
|
|
|
2017-08-09 23:07:49 +02:00
|
|
|
# Postgresql
|
|
|
|
sudo -u postgres createdb $DBNAME
|
|
|
|
sudo -u postgres createuser -SdR $DBUSER
|
|
|
|
sudo -u postgres psql -c "ALTER USER $DBUSER WITH PASSWORD '$DBPASSWD';"
|
|
|
|
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE $DBNAME TO $DBUSER;"
|
2016-05-26 04:06:17 +02:00
|
|
|
|
|
|
|
|
2017-08-09 23:07:49 +02:00
|
|
|
# Redis
|
2017-04-25 21:23:51 +02:00
|
|
|
REDIS_PASSWD="dummy"
|
|
|
|
redis-cli CONFIG SET requirepass $REDIS_PASSWD
|
|
|
|
redis-cli -a $REDIS_PASSWD CONFIG REWRITE
|
2017-04-24 22:27:01 +02:00
|
|
|
|
2017-08-13 15:36:45 +02:00
|
|
|
# Contenu statique
|
|
|
|
mkdir -p /srv/gestiocof/media
|
|
|
|
mkdir -p /srv/gestiocof/static
|
2017-08-09 23:07:49 +02:00
|
|
|
chown -R ubuntu:www-data /srv/gestiocof
|
|
|
|
|
|
|
|
# Nginx
|
|
|
|
ln -s -f /vagrant/provisioning/nginx.conf /etc/nginx/sites-enabled/gestiocof.conf
|
|
|
|
rm -f /etc/nginx/sites-enabled/default
|
|
|
|
systemctl reload nginx
|
|
|
|
|
|
|
|
# Environnement virtuel python
|
|
|
|
sudo -H -u ubuntu python3 -m venv ~ubuntu/venv
|
|
|
|
sudo -H -u ubuntu ~ubuntu/venv/bin/pip install -U pip
|
|
|
|
sudo -H -u ubuntu ~ubuntu/venv/bin/pip install -r /vagrant/requirements-devel.txt
|
|
|
|
|
2017-08-10 17:55:36 +02:00
|
|
|
# Préparation de Django
|
|
|
|
cd /vagrant
|
|
|
|
ln -s -f secret_example.py cof/settings/secret.py
|
2017-08-12 00:56:02 +02:00
|
|
|
sudo -H -u ubuntu \
|
|
|
|
DJANGO_SETTINGS_MODULE='cof.settings.dev' \
|
|
|
|
bash -c ". ~/venv/bin/activate && bash provisioning/prepare_django.sh"
|
|
|
|
/home/ubuntu/venv/bin/python manage.py collectstatic --noinput --settings cof.settings.dev
|
2017-08-10 17:55:36 +02:00
|
|
|
|
|
|
|
# Installation du cron pour les mails de rappels
|
|
|
|
sudo -H -u ubuntu crontab provisioning/cron.dev
|
|
|
|
|
2017-08-09 23:07:49 +02:00
|
|
|
# Daphne + runworker
|
|
|
|
cp /vagrant/provisioning/daphne.service /etc/systemd/system/daphne.service
|
|
|
|
cp /vagrant/provisioning/worker.service /etc/systemd/system/worker.service
|
|
|
|
systemctl enable daphne.service
|
|
|
|
systemctl enable worker.service
|
|
|
|
systemctl start daphne.service
|
|
|
|
systemctl start worker.service
|
2016-08-18 14:23:27 +02:00
|
|
|
|
2016-05-26 04:06:17 +02:00
|
|
|
# Mise en place du .bash_profile pour tout configurer lors du `vagrant ssh`
|
2016-11-06 19:01:30 +01:00
|
|
|
cat >> ~ubuntu/.bashrc <<EOF
|
2016-05-26 04:06:17 +02:00
|
|
|
# On utilise la version de développement de GestioCOF
|
2017-04-24 22:52:40 +02:00
|
|
|
export DJANGO_SETTINGS_MODULE='cof.settings.dev'
|
2016-05-26 04:06:17 +02:00
|
|
|
|
2016-11-06 15:39:50 +01:00
|
|
|
# Charge le virtualenv
|
|
|
|
source ~/venv/bin/activate
|
|
|
|
|
2016-05-26 04:06:17 +02:00
|
|
|
# On va dans /vagrant où se trouve le code de gestioCOF
|
|
|
|
cd /vagrant
|
|
|
|
EOF
|