2016-09-28 20:36:48 +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="event_gestion"
|
|
|
|
DBNAME="event_gestion"
|
|
|
|
DBPASSWD="4KZt3nGPLVeWSvtBZPsd9jdssdJMds78"
|
|
|
|
|
|
|
|
# Installation de paquets utiles
|
|
|
|
apt-get update && apt-get install -y python3-pip python3-dev \
|
2016-09-28 22:06:05 +02:00
|
|
|
libpq-dev postgresql postgresql-contrib libjpeg-dev
|
2016-09-28 20:36:48 +02:00
|
|
|
|
|
|
|
# Setup Database and User
|
|
|
|
sudo -u postgres createdb $DBNAME
|
|
|
|
sudo -u postgres createuser -SDR $DBUSER
|
|
|
|
sudo -u postgres psql -c "ALTER USER $DBUSER WITH PASSWORD '$DBPASSWD';"
|
2016-10-02 14:23:39 +02:00
|
|
|
sudo -u postgres psql -c "ALTER USER $DBUSER CREATEDB;"
|
2016-09-28 22:06:05 +02:00
|
|
|
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE $DBNAME TO $DBUSER;"
|
2016-09-28 20:36:48 +02:00
|
|
|
|
|
|
|
# Mise en place du .bash_profile pour tout configurer lors du `vagrant ssh`
|
|
|
|
cat > ~vagrant/.bash_profile <<EOF
|
|
|
|
# On utilise la version de prod de qwann.fr
|
2016-09-29 00:13:16 +02:00
|
|
|
export DJANGO_SETTINGS_MODULE='evenementiel.settings_dev'
|
2016-09-28 20:36:48 +02:00
|
|
|
|
|
|
|
# Identifiants MySQL
|
|
|
|
export DBUSER="$DBUSER"
|
|
|
|
export DBNAME="$DBNAME"
|
|
|
|
export DBPASSWD="$DBPASSWD"
|
|
|
|
|
|
|
|
# On va dans /vagrant où se trouve le code
|
|
|
|
cd /vagrant
|
|
|
|
EOF
|
|
|
|
chown vagrant: ~vagrant/.bash_profile
|
|
|
|
|
|
|
|
# On va dans /vagrant où se trouve le code
|
|
|
|
cd /vagrant
|
|
|
|
|
|
|
|
# Installation des dépendances python
|
2017-02-21 20:28:26 +01:00
|
|
|
sudo -H pip3 install -U pip
|
2016-09-28 22:06:05 +02:00
|
|
|
sudo -H -u vagrant pip3 install --user -r requirements.txt
|
|
|
|
sudo -H -u vagrant pip3 install --user -r requirements-devel.txt
|
2016-09-28 20:36:48 +02:00
|
|
|
|
|
|
|
# Préparation de Django
|
|
|
|
sudo -H -u vagrant DJANGO_SETTINGS_MODULE='evenementiel.settings_dev' DBUSER=$DBUSER DBNAME=$DBNAME DBPASSWD=$DBPASSWD python3 manage.py migrate
|