site_tps/deploy.sh
2018-03-02 20:34:12 +01:00

48 lines
1.8 KiB
Bash

#! /bin/bash
PYTHON_INTERPRETER = "/usr/bin/python3"
printf "\033[0;32m > Création du virtualenv \033[0m\n"
virtualenv env_site -p "$PYTHON_INTERPRETER"
source env_site/bin/activate
printf "\033[0;32m > Installation des dépendances \033[0m\n"
pip install -r requirements.txt
printf "\033[0;32m > Génération des settings locaux. \033[0m\n"
printf "\033[0;32m > Génération de la secret_key \033[0m\n"
django_secret_key=$(python -c "import random; print(''.join([random.SystemRandom().choice('abcdefghijklmnopqrstuvwxyz0123456789%=+') for i in range(50)]))")
cp site_tps/settings_local.example.py site_tps/settings_local.py
sed -i 's/SUPER_SECRET_KEY/'"$django_secret_key"'/g' site_tps/settings_local.py
printf "\033[0;32m > Configuration de MySQL \033[0m\n"
read -p "Hôte > " db_host
read -p "Nom de la base de données > " db_name
read -p "Utilisateur MySQL > " db_user
read -p -s "Mot de passe > " db_pass
sed -i 's/db_engine/django.db.backends.mysql/g' site_tps/settings_local.py
sed -i 's/db_name/'"$db_name"'/g' site_tps/settings_local.py
sed -i 's/db_user/'"$db_user"'/g' site_tps/settings_local.py
sed -i 's/db_pass/'"$db_pass"'/g' site_tps/settings_local.py
sed -i 's/db_host/'"$db_host"'/g' site_tps/settings_local.py
#printf "\033[0;32m > Configuration des mails \033[0m\n"
#read -p "Domaine d'envoi des mails > " domain_name
#read -p "Mail de l'administrateur > " admin_mail
printf "\033[0;32m > Domaine\033[0m\n"
read -p "Domaine autorisé > " url_server
sed -i 's/URL_SERVER/'"$url_server"'/g' site_tps/settings_local.py
printf "\033[0;32m > settings_local.py créé \033[0m\n"
printf "\033[0;32m > Application des migrations \033[0m\n"
python manage.py migrate
printf "\033[0;32m > Création du groupe admin \033[0m\n"
python manage.py create_admin
printf "\033[0;32m > Création d'un super utilisateur\033[0m\n"
python manage.py createsuperuser