From fc27bc5cdf32948a44392f3516f36046d043e41d Mon Sep 17 00:00:00 2001 From: viennet Date: Mon, 21 Dec 2020 13:55:04 +0100 Subject: [PATCH] WIP: migration script ScoDoc7 -> ScoDoc8 --- config/create_user_db.sh | 2 +- config/migre-7-a-8.sh | 69 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 config/migre-7-a-8.sh diff --git a/config/create_user_db.sh b/config/create_user_db.sh index 8790cd5d..e010ed64 100755 --- a/config/create_user_db.sh +++ b/config/create_user_db.sh @@ -4,7 +4,7 @@ # ScoDoc: creation de la base de donnees d'utilisateurs # # Ce script prend en charge la creation de la base de donnees -# et doit être lancé par l'utilisateur unix root dans le repertoire .../config +# et doit être lancé par l'utilisateur unix root dans le repertoire .../config # ^^^^^^^^^^^^^^^^^^^^^ # E. Viennet, Juin 2008 # diff --git a/config/migre-7-a-8.sh b/config/migre-7-a-8.sh new file mode 100644 index 00000000..1421bd0d --- /dev/null +++ b/config/migre-7-a-8.sh @@ -0,0 +1,69 @@ +#!/bin/bash + +# Migration vers ScoDoc 8 +# +# E. Viennet, dec 2020 +# +# Passe l'installation courante de ScoDoc 7 à ScoDoc 8 +# A ce jour, ScoDoc 8 n'est pas recommandé en production ! +# +# - l'installation ScoDoc 7 doit être à jour. +# - passe de SVN à GIT: pas de retour en arrière. +# - déplace la config de config/scodoc_config.py +# vers /opt/scodoc/var/scodoc/config/scodoc_local.py + + +source config.sh +source utils.sh + +check_uid_root "$0" + +scodocctl stop + +scodoc7=/opt/ScoDoc7 +if [ -e "$scodoc7" ] +then + echo "/opt/ScoDoc7 already exists. Move or remove it before retrying." + exit 1; +fi + +# 0- Upgrade and check local config +cd "$SCODOC_DIR" || { echo "Fatal error: can't cd to $SCODOC_DIR"; exit 2; } +svn up || { echo "Fatal error: can't apply last svn up"; exit 3; } + +local_config_diff=$(svn diff config/scodoc_config.py | wc -l) + +# 1- Install git +apt-get update +apt-get update || { echo "apt-get update failed with $?"; exit 4; } +apt-get -y install git + +# 2- Download ScoDoc8 +echo "Downloading files..." +cd "$SCODOC_DIR"/.. || { echo "Fatal error: can't cd to $SCODOC_DIR"; exit 2; } + +mv ScoDoc "$scodoc7" + +git clone https://scodoc.org/git/viennet/ScoDoc.git || { echo "Fatal error: can't clone git repository"; exit 5; } +cd ScoDoc || { echo "Fatal error: can't cd to $SCODOC_DIR"; exit 6; } + +git checkout ScoDoc8 || { echo "Fatal error: can't checkout ScoDoc8 branch"; exit 7; } + +# 3- Migrate user's configuration if needed +if [ "$local_config_diff" -ne 0 ] +then + src="$scodoc7"/config/scodoc_config.py + dst="${SCODOC_VAR_DIR}/config/scodoc_local.py" + if [ -e "$dst" ] + then + echo "Warning: moving ${dst} to ${dst}.old" + echo "=> vérifiez votre configuration locale avant utilisation." + mv "$dst" "$dst".old + fi + echo + echo "Copying local configuration file $src" + echo "to $dst" + cp "$src" "$dst" +fi + +printf "\nDone.\nPlease restart scodoc to use ScoDoc8.\n"