2016-05-26 04:06:17 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# 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
|
2016-11-06 19:01:30 +01:00
|
|
|
apt-get update && apt-get install -y python3-pip python3-dev python3-venv \
|
2016-09-12 16:49:37 +02:00
|
|
|
libmysqlclient-dev libjpeg-dev git redis-server
|
2016-11-14 06:39:55 +01:00
|
|
|
pip install -U pip
|
2016-05-26 04:06:17 +02:00
|
|
|
|
|
|
|
# Configuration et installation de mysql. Le mot de passe root est le même que
|
|
|
|
# le mot de passe pour l'utilisateur local - pour rappel, ceci est une instance
|
|
|
|
# locale de développement.
|
|
|
|
echo "mysql-server mysql-server/root_password password $DBPASSWD" | debconf-set-selections
|
|
|
|
echo "mysql-server mysql-server/root_password_again password $DBPASSWD" | debconf-set-selections
|
|
|
|
|
|
|
|
apt-get install -y mysql-server
|
|
|
|
|
|
|
|
mysql -uroot -p$DBPASSWD -e "CREATE DATABASE $DBNAME; GRANT ALL PRIVILEGES ON $DBNAME.* TO '$DBUSER'@'localhost' IDENTIFIED BY '$DBPASSWD'"
|
2017-01-06 16:58:27 +01:00
|
|
|
mysql -uroot -p$DBPASSWD -e "CREATE DATABASE test_$DBNAME; GRANT ALL PRIVILEGES ON test_$DBNAME.* TO '$DBUSER'@'localhost'"
|
2016-05-26 04:06:17 +02:00
|
|
|
|
2016-09-12 16:49:37 +02:00
|
|
|
# Installation et configuration d'Apache
|
|
|
|
apt-get install -y apache2
|
2016-11-06 01:36:10 +01:00
|
|
|
a2enmod proxy proxy_http proxy_wstunnel headers
|
2016-09-12 16:49:37 +02:00
|
|
|
cp /vagrant/provisioning/apache.conf /etc/apache2/sites-available/gestiocof.conf
|
|
|
|
a2ensite gestiocof
|
|
|
|
a2dissite 000-default
|
|
|
|
service apache2 restart
|
|
|
|
mkdir /var/www/static
|
2016-11-06 19:01:30 +01:00
|
|
|
chown -R ubuntu:www-data /var/www/static
|
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
|
|
|
|
export DJANGO_SETTINGS_MODULE='cof.settings_dev'
|
|
|
|
|
|
|
|
# Identifiants MySQL
|
|
|
|
export DBUSER="$DBUSER"
|
|
|
|
export DBNAME="$DBNAME"
|
|
|
|
export DBPASSWD="$DBPASSWD"
|
|
|
|
|
|
|
|
# Permet d'utiliser les utilitaires pythons locaux
|
|
|
|
export PATH="\$PATH:\$HOME/.local/bin"
|
|
|
|
|
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
|
|
|
|
|
|
|
|
# On va dans /vagrant où se trouve gestioCOF
|
|
|
|
cd /vagrant
|
|
|
|
|
2016-11-06 15:39:50 +01:00
|
|
|
# Installation du virtualenv, on utilise désormais python3
|
2016-11-06 19:01:30 +01:00
|
|
|
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 requirements.txt -r requirements-devel.txt
|
2016-05-26 04:06:17 +02:00
|
|
|
|
|
|
|
# Préparation de Django
|
2016-11-06 19:01:30 +01:00
|
|
|
sudo -H -u ubuntu DJANGO_SETTINGS_MODULE='cof.settings_dev' DBUSER=$DBUSER DBNAME=$DBNAME DBPASSWD=$DBPASSWD bash provisioning/prepare_django.sh
|
2016-07-23 14:16:19 +02:00
|
|
|
|
|
|
|
# Installation du cron pour les mails de rappels
|
2016-11-06 19:01:30 +01:00
|
|
|
sudo -H -u ubuntu crontab provisioning/cron.dev
|
2016-09-12 16:49:37 +02:00
|
|
|
|
|
|
|
# On installe Daphne et on demande à supervisor de le lancer
|
2016-11-06 19:28:47 +01:00
|
|
|
sudo -H -u ubuntu ~ubuntu/venv/bin/pip install daphne
|
2016-09-12 16:49:37 +02:00
|
|
|
apt-get install -y supervisor
|
|
|
|
cp /vagrant/provisioning/supervisor.conf /etc/supervisor/conf.d/gestiocof.conf
|
2016-09-12 19:33:39 +02:00
|
|
|
sed "s/{DBUSER}/$DBUSER/" -i /etc/supervisor/conf.d/gestiocof.conf
|
|
|
|
sed "s/{DBNAME}/$DBNAME/" -i /etc/supervisor/conf.d/gestiocof.conf
|
|
|
|
sed "s/{DBPASSWD}/$DBPASSWD/" -i /etc/supervisor/conf.d/gestiocof.conf
|
2016-09-12 16:49:37 +02:00
|
|
|
service supervisor restart
|