Install/Upgrade: améliore script, mail si échec (WIP)

This commit is contained in:
Emmanuel Viennet 2024-08-24 14:39:02 +02:00 committed by Iziram
parent c1d8a34e34
commit bf53dfa93a
5 changed files with 63 additions and 22 deletions

View File

@ -18,7 +18,7 @@ umask 0022
export SCODOC_DIR=/opt/scodoc
export SCODOC_VAR_DIR=/opt/scodoc-data
export SCODOC_INSTALL_STATUS_FILE="${SCODOC_VAR_DIR}/.install_status"
export SCODOC_VERSION_DIR="${SCODOC_VAR_DIR}/config/version"
export SCODOC_LOGOS_DIR="${SCODOC_VAR_DIR}/config/logos"

View File

@ -3,11 +3,17 @@
# Post-installation de scodoc
# ici, le répertoire /opt/scodoc vient d'être installé
set -euo pipefail
cd /opt/scodoc || (echo "Error chdir to /opt/scodoc"; exit 1)
# On peut donc charger la config:
source /opt/scodoc/tools/config.sh
source /opt/scodoc/tools/utils.sh
source /opt/scodoc/tools/config.sh || (echo "Error loading /opt/scodoc/tools/config.sh"; exit 1)
source /opt/scodoc/tools/utils.sh || (echo "Error loading /opt/scodoc/tools/utils.sh"; exit 1)
# Enleve fichier de statut d'installation s'il existe
# (la présence de ce fichier indique que l'install s'est bien passée)
remove_install_status
# -- Création au besoin de notre utilisateur
# adduser --system "${SCODOC_USER}"
@ -134,3 +140,6 @@ systemctl enable scodoc9
# --- RESTART SCODOC
systemctl restart scodoc9
# On est arrivé au bout du post-install !
create_install_status

19
tools/debian/prerm Normal file
View File

@ -0,0 +1,19 @@
#!/bin/bash
set -euo pipefail
# Pre-removal script for scodoc
# This script is called by dpkg before removing the package
cd /opt/scodoc || (echo "Error chdir to /opt/scodoc"; exit 1)
# On peut donc charger la config:
source /opt/scodoc/tools/config.sh || (echo "Error loading /opt/scodoc/tools/config.sh"; exit 1)
source /opt/scodoc/tools/utils.sh || (echo "Error loading /opt/scodoc/tools/utils.sh"; exit 1)
check_uid_root
remove_install_status

View File

@ -6,10 +6,11 @@
#
# Upgrade also the Linux system using apt.
#
# Script for ScoDoc 9
# Script for ScoDoc 9. Lancé automatiquement par scodoc-updater.
#
# E. Viennet, sep 2013, mar 2017, jun 2019, aug 2020, dec 2020, aug 21
set -euo pipefail
# Le répertoire de ce script:
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
@ -29,7 +30,7 @@ if [ -z "$SCODOC_UPGRADE_RUNNING" ]
# install spécifiquement scodoc9, utile si les dépendances Debian de scodoc9
# ont été changées, ce qui peut provoquer un
# "packages have been kept back"
apt install scodoc9
apt install scodoc9 || alarm_admin "apt install scodoc9 failed"
fi
systemctl restart redis
systemctl restart nginx

View File

@ -110,3 +110,15 @@ gen_passwd() {
done
echo "$password"
}
# Status file: indique si l'install s'est complètement déroulée
create_install_status() {
touch "${SCODOC_INSTALL_STATUS_FILE}" || die "can't create ${SCODOC_INSTALL_STATUS_FILE}"
}
remove_install_status() {
if [ -e "${SCODOC_INSTALL_STATUS_FILE}" ]
then
rm -f "${SCODOC_INSTALL_STATUS_FILE}"
fi
}