From fc27bc5cdf32948a44392f3516f36046d043e41d Mon Sep 17 00:00:00 2001 From: viennet Date: Mon, 21 Dec 2020 13:55:04 +0100 Subject: [PATCH 1/3] 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" From 9e7109283e72a07e61bbb04db3654b4c27df8322 Mon Sep 17 00:00:00 2001 From: viennet Date: Mon, 21 Dec 2020 14:10:18 +0100 Subject: [PATCH 2/3] fix mode --- config/migre-7-a-8.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 config/migre-7-a-8.sh diff --git a/config/migre-7-a-8.sh b/config/migre-7-a-8.sh old mode 100644 new mode 100755 From 3c2aff23021729de85e1f92cc1e807b64fc1abe1 Mon Sep 17 00:00:00 2001 From: viennet Date: Mon, 21 Dec 2020 15:26:39 +0100 Subject: [PATCH 3/3] polished migration script --- config/migre-7-a-8.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/migre-7-a-8.sh b/config/migre-7-a-8.sh index 1421bd0d..2e9fddc6 100755 --- a/config/migre-7-a-8.sh +++ b/config/migre-7-a-8.sh @@ -39,7 +39,7 @@ apt-get update || { echo "apt-get update failed with $?"; exit 4; } apt-get -y install git # 2- Download ScoDoc8 -echo "Downloading files..." +printf "\nDownloading files...\n" cd "$SCODOC_DIR"/.. || { echo "Fatal error: can't cd to $SCODOC_DIR"; exit 2; } mv ScoDoc "$scodoc7" @@ -57,7 +57,7 @@ then if [ -e "$dst" ] then echo "Warning: moving ${dst} to ${dst}.old" - echo "=> vérifiez votre configuration locale avant utilisation." + printf "=> vérifiez votre configuration locale avant utilisation.\n\n" mv "$dst" "$dst".old fi echo @@ -66,4 +66,4 @@ then cp "$src" "$dst" fi -printf "\nDone.\nPlease restart scodoc to use ScoDoc8.\n" +printf "\nDone.\nPlease start scodoc to use ScoDoc8: systemctl start scodoc\n"