From c3e5a5d1887e41c6b6c532d1de7d3581e33b8e54 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Fri, 28 May 2021 22:24:37 +0200 Subject: [PATCH] Systemd script for Debian 9 or 10, with postgresql 11 or not. --- config/config.sh | 2 ++ config/configure_systemd.sh | 8 +++++++- config/etc/scodoc.service | 14 ++++++++------ config/install_debian10.sh | 4 +--- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/config/config.sh b/config/config.sh index 07f684c105..4c5e288ca1 100644 --- a/config/config.sh +++ b/config/config.sh @@ -34,9 +34,11 @@ export POSTGRES_USER=www-data if [ "${debian_version}" = "10" ] then PSQL=/usr/lib/postgresql/11/bin/psql + export POSTGRES_SERVICE="postgresql@11-main.service" elif [ "${debian_version}" = "9" ] then PSQL=/usr/lib/postgresql/9.6/bin/psql + export POSTGRES_SERVICE="postgresql" elif [ "${debian_version}" = "8" ] then PSQL=/usr/lib/postgresql/9.4/bin/psql diff --git a/config/configure_systemd.sh b/config/configure_systemd.sh index ed0b0d4f4c..f1a2d9b2b2 100755 --- a/config/configure_systemd.sh +++ b/config/configure_systemd.sh @@ -8,7 +8,13 @@ source utils.sh check_uid_root $0 echo 'Installation du demarrage automatique de ScoDoc (systemd)' -cp $SCODOC_DIR/config/etc/scodoc.service /etc/systemd/system + +# La variable POSTGRES_SERVICE doit ĂȘtre positionnĂ©e dans config.sh +# suivant la version de Debian et de postgresql +[ -z "${POSTGRES_SERVICE}" ] && die "incompatible Debian version" + +cat "$SCODOC_DIR/config/etc/scodoc.service" | sed 's/{{postgresql}}/'"${POSTGRES_SERVICE}"'/g' > /etc/systemd/system/scodoc.service + systemctl enable scodoc.service echo "A partir de maintenant, utiliser" diff --git a/config/etc/scodoc.service b/config/etc/scodoc.service index 89a63e138d..c91c3f08df 100644 --- a/config/etc/scodoc.service +++ b/config/etc/scodoc.service @@ -1,13 +1,15 @@ # ScoDoc7 service # Zope based -# Depends on postgresql -# => is restarted when postgresql restarts +# Depends on {{postgresql}} (replaced by installation script by +# postgresql@11-main.service on Debian 10 +# postgresql on Debian <= 9 +# => is restarted when {{postgresql}} restarts # [Unit] Description=ScoDoc 7 service -After=network.target postgresql -Requires=postgresql -PartOf=postgresql +After=network.target {{postgresql}} +Requires={{postgresql}} +PartOf={{postgresql}} StartLimitIntervalSec=0 [Service] @@ -21,4 +23,4 @@ ExecStop=/opt/scodoc/bin/zopectl stop ExecReload=/opt/scodoc/bin/zopectl restart [Install] -WantedBy=postgresql +WantedBy={{postgresql}} diff --git a/config/install_debian10.sh b/config/install_debian10.sh index 3494d793ed..8d2bdb3202 100755 --- a/config/install_debian10.sh +++ b/config/install_debian10.sh @@ -220,9 +220,7 @@ read ans if [ "$(norm_ans "$ans")" != 'N' ] then # ScoDoc 7.19+ uses systemd - echo 'Installation du demarrage automatique de ScoDoc (systemd)' - cp $SCODOC_DIR/config/etc/scodoc.service /etc/systemd/system - systemctl enable scodoc.service + $SCODOC_DIR/config/configure_systemd.sh fi