Mise à jours de MRIOutils¶
1- Méthode manuelle (déprécié)¶
mettre le site en maintenance
touch /opt/mri_outils/maintenance/maintenance.enable
Renommer l'ancien répertoire de l'appli:
mv /opt/mri_outils/www /opt/mri_outils/www.old
Créer nouveau repertoire et extraire nouvelle version
mkdir /opt/mri_outils/www unzip -d /opt/mri_outils/www MRIOutils-version.zip
Copie de la config:
cp /opt/mri_outils/www.old/MRIOutils/settings_local.py /opt/mri_outils/www/MRIOutils/settings_local.py
Faire la maj du site, bdd et virtualenv:
source /opt/mri_outils/venv_MRIOutils/bin/activate cd /opt/mri_outils/www/ pip install -r requirements.txt ./manage.py migrate ./manage.py collectstatic -c --noinput ./manage.py compilemessages deactivate
Redémarrer apache et sortir de maintenance
service apache2 restart rm /opt/mri_outils/maintenance/maintenance.enable
Quand la maj est déclaré ok supprimer la sauvegarde de l'ancienne version
2- Avec script update¶
copier le script ci dessous sur le serveur, puis l'executer en mettant en parametre le zip de la nouvelle version de MRIOutils.
#!/bin/bash if [[ -z $1 ]]; then echo "Please provide the archive of the source code as the input of the script." exit 1 fi archive=$1 if [[ !(-e $archive) || !($(file --mime-type -b "$archive") == "application/zip") ]]; then echo "File $archive provided is not valid: provide a .zip file" exit 1 fi MRI_OUTILS_DIR="/opt/mri_outils/www" BACKUP_DIR="/opt/mri_outils/www.old" VENV_PATH="/opt/mri_outils/venv_MRIOutils" MAINTENANCE_ENABLE_FILE="/opt/mri_outils/maintenance/maintenance.enable" # Maintenance mode touch $MAINTENANCE_ENABLE_FILE # Create backup if [[ -e $BACKUP_DIR ]]; then read -p "A backup directory has been found. Do you want to delete it ? (type 'yes' if you want to delete it, otherwise the program will stop.) " must_delete_folder if [[ $must_delete_folder == "yes" ]]; then rm -rf $BACKUP_DIR if [[ !(-e $BACKUP_DIR) ]]; then echo "The previous backup directory '$BACKUP_DIR' has been deleted." else echo "Warning: The current backup directory '$BACKUP_DIR' has not been deleted." exit 0 fi else echo "The current backup directory '$BACKUP_DIR' has been kept untouched." exit 0 fi fi mv $MRI_OUTILS_DIR $BACKUP_DIR echo -e "\033[35mCreated new backup directory '$BACKUP_DIR'.\033[0m"; # Extract archive and add config files echo "Extracting archive content..." mkdir $MRI_OUTILS_DIR unzip -d $MRI_OUTILS_DIR $archive cp "$BACKUP_DIR/MRIOutils/settings_local.py" "$MRI_OUTILS_DIR/MRIOutils/settings_local.py" echo -e "\033[35mDone.\033[0m" echo "Do upgrade..." source $VENV_PATH/bin/activate cd $MRI_OUTILS_DIR pip install -r requirements.txt ./manage.py migrate ./manage.py collectstatic -c --noinput ./manage.py compilemessages deactivate echo -e "\033[35mDone.\033[0m" echo "Restart apache..." service apache2 restart echo -e "\033[35mDone.\033[0m" rm $MAINTENANCE_ENABLE_FILE echo -e "\033[35mMRIOutils correctement mis à jours.\033[0m" echo "Pensez à effacer le repertoire $BACKUP_DIR quand celui-ci ne sera plus necessaire."