From 9e441232a4999190b550ba5341e9bdfcd344f738 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Tue, 24 Aug 2021 18:55:58 +0200 Subject: [PATCH] install script avec venv --- tools/build_release.sh | 15 +++++++++++++-- tools/debian/postinst | 3 ++- tools/debian/preinst | 30 ++++++++++++++++++------------ tools/install_debian11.sh | 2 +- tools/utils.sh | 1 - 5 files changed, 34 insertions(+), 17 deletions(-) diff --git a/tools/build_release.sh b/tools/build_release.sh index 5052f92d..93701ad9 100644 --- a/tools/build_release.sh +++ b/tools/build_release.sh @@ -7,7 +7,7 @@ die() { } PACKAGE_NAME=scodoc9 -RELEASE_TAG=9.0.0 +RELEASE_TAG=9.0.0-b VERSION=9.0.0 RELEASE=1 ARCH="amd64" @@ -52,6 +52,17 @@ cp -p "$SCODOC_DIR"/tools/etc/scodoc9.service "$slash"/etc/systemd/system/ || di mv "$SCODOC_DIR"/tools/debian "$slash"/DEBIAN || die "can't install DEBIAN dir" chmod 755 "$slash"/DEBIAN/*inst || die "can't chmod debian scripts" - +# ------------ CREATION DU VIRTUALENV +echo "Creating python3 virtualenv..." +(cd $SCODOC_DIR && python3 -m venv venv) || die "error creating Python 3 virtualenv" + +# ------------ INSTALL DES PAQUETS PYTHON (3.9) +# pip in our env, as user "scodoc" +(cd $SCODOC_DIR && source venv/bin/activate && pip install wheel && pip install -r requirements-3.9.txt) || die "Error installing python packages" + +# -------- THE END +echo "Terminé." +echo "Après vérification, construire le paquet .deb avec:" +echo " dpkg-deb --build --root-owner-group $DEST_DIR" diff --git a/tools/debian/postinst b/tools/debian/postinst index 6a4d369d..2c9254c4 100644 --- a/tools/debian/postinst +++ b/tools/debian/postinst @@ -9,7 +9,8 @@ source /opt/scodoc/tools/config.sh source /opt/scodoc/tools/utils.sh # -- Création au besoin de notre utilisateur -adduser --system "${SCODOC_USER}" +# adduser --system "${SCODOC_USER}" +check_create_scodoc_user # -- Répertoires /opt/scodoc donné à scodoc change_scodoc_file_ownership diff --git a/tools/debian/preinst b/tools/debian/preinst index 178d36b3..571580d2 100644 --- a/tools/debian/preinst +++ b/tools/debian/preinst @@ -3,17 +3,23 @@ # Pre-installation de scodoc # ------------ Safety checks -# Version majeure de Debian (..., 9, 10) -debian_version=$(cat /etc/debian_version) -debian_version=${debian_version%%.*} -if [ "${debian_version}" != "11" ] -then - echo "Version du systeme Linux Debian incompatible" - exit 1 -fi +# Version majeure de Debian (..., 9, 10, 11) -if [ "$(arch)" != "x86_64" ] -then - echo "Version du systeme Linux Debian incompatible (pas X86 64 bits)" - exit 1 +if [ -e /etc/debian_version ] +then + debian_version=$(cat /etc/debian_version) + debian_version=${debian_version%%.*} + echo "Detected Debian version: ${debian_version}" +else + echo "can't detect Debian version" fi +# +echo arch="$(arch)" + +# if [ "$(arch)" != "x86_64" ] +# then +# echo +# echo "Version du systeme Linux Debian incompatible (pas X86 64 bits)" +# echo +# exit 1 +# fi diff --git a/tools/install_debian11.sh b/tools/install_debian11.sh index 0cb70847..70cc61fa 100755 --- a/tools/install_debian11.sh +++ b/tools/install_debian11.sh @@ -78,7 +78,7 @@ su -c "(cd $SCODOC_DIR && python3 -m venv venv)" scodoc || die "can't create Pyt # ------------ INSTALL DES PAQUETS PYTHON (3.9) # pip in our env, as user "scodoc" -su -c "(cd $SCODOC_DIR && source venv/bin/activate && pip install wheel && pip install -r requirements-3.9.txt)" || die "Error installing python packages" +su -c "(cd $SCODOC_DIR && source venv/bin/activate && pip install wheel && pip install -r requirements-3.9.txt)" scodoc || die "Error installing python packages" # pip install --upgrade pip => bug [Errno 39] Directory not empty: '_internal' # ------------ diff --git a/tools/utils.sh b/tools/utils.sh index b481de21..e34cc526 100644 --- a/tools/utils.sh +++ b/tools/utils.sh @@ -60,7 +60,6 @@ init_postgres_user() { # run as root } # --- Ensure Unix user "scodoc" exists -# note: le paquet debian utilise directement adduser --system check_create_scodoc_user() { if ! id -u "${SCODOC_USER}" &> /dev/null then