From b09cf0a7871a8861618b84cc6cbf7d9ea8ee0179 Mon Sep 17 00:00:00 2001 From: David Beniamine <david.beniamine@tetras-libre.fr> Date: Wed, 6 Nov 2024 15:19:48 +0100 Subject: [PATCH] Detect DIR properly --- checks/backups.sh | 10 ++++++++++ install/AptCacher.sh | 6 +++--- install/Base.sh | 6 +++--- install/Certbot.sh | 5 +++-- install/Collabora.sh | 5 +++-- install/Dolibarr.sh | 5 +++-- install/Monit.sh | 5 +++-- install/MySQL.sh | 5 +++-- install/OnlyOffice.sh | 5 +++-- install/Traefik.sh | 5 +++-- install/WebServer.sh | 5 +++-- main.env.sample | 3 --- upgrade/All.sh | 7 ++++--- upgrade/Backups.sh | 7 ++++--- upgrade/Collabora.sh | 5 +++-- upgrade/Dolibarr.sh | 5 +++-- upgrade/Monit.sh | 5 +++-- upgrade/Traefik.sh | 11 ++++++++++- upgrade/WebServer.sh | 5 +++-- 19 files changed, 70 insertions(+), 40 deletions(-) diff --git a/checks/backups.sh b/checks/backups.sh index e245252..f0d1902 100644 --- a/checks/backups.sh +++ b/checks/backups.sh @@ -2,6 +2,16 @@ echo "RUN $(basename "$0") ===" +DIR=$(realpath $(dirname $0/..)) +if [ ! -e $DIR/main.env ] +then + echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" + exit 1 +else + echo "Environment file loaded" +fi +. $DIR/../main.env + backup_system="" duplicity_dir="/opt/duplicity-ftp-backup/" duplicity_alt_dir="/root/duplicity-ftp-backup/" diff --git a/install/AptCacher.sh b/install/AptCacher.sh index 162fad5..f445048 100755 --- a/install/AptCacher.sh +++ b/install/AptCacher.sh @@ -2,15 +2,15 @@ echo "RUN $(basename "$0") ===" -if [ ! -e $(dirname "$0")/../main.env ] +DIR=$(realpath $(dirname $0/..)) +if [ ! -e $DIR/main.env ] then echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" exit 1 else echo "Environment file loaded" fi -. $(dirname "$0")/../main.env - +. $DIR/../main.env apt-get update apt-get -y install apt-cacher-ng diff --git a/install/Base.sh b/install/Base.sh index f4d5c10..2144962 100644 --- a/install/Base.sh +++ b/install/Base.sh @@ -20,15 +20,15 @@ set -o nounset # Treat unset variables as an error echo "RUN $(basename "$0") ===" -if [ ! -e $(dirname "$0")/../main.env ] +DIR=$(realpath $(dirname $0/..)) +if [ ! -e $DIR/main.env ] then echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" exit 1 else echo "Environment file loaded" fi -. $(dirname "$0")/../main.env - +. $DIR/../main.env apt-get clean diff --git a/install/Certbot.sh b/install/Certbot.sh index 164bdd6..91dbb5c 100755 --- a/install/Certbot.sh +++ b/install/Certbot.sh @@ -18,14 +18,15 @@ echo "RUN $(basename "$0") ===" -if [ ! -e $(dirname "$0")/../main.env ] +DIR=$(realpath $(dirname $0/..)) +if [ ! -e $DIR/main.env ] then echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" exit 1 else echo "Environment file loaded" fi -. $(dirname "$0")/../main.env +. $DIR/../main.env apt-get update && apt-get install certbot python-certbot-apache diff --git a/install/Collabora.sh b/install/Collabora.sh index 128e025..414a5be 100644 --- a/install/Collabora.sh +++ b/install/Collabora.sh @@ -20,14 +20,15 @@ set -o nounset # Treat unset variables as an error echo "RUN $(basename "$0") ===" -if [ ! -e $(dirname "$0")/../main.env ] +DIR=$(realpath $(dirname $0/..)) +if [ ! -e $DIR/main.env ] then echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" exit 1 else echo "Environment file loaded" fi -. $(dirname "$0")/../main.env +. $DIR/../main.env ########################################################################### diff --git a/install/Dolibarr.sh b/install/Dolibarr.sh index 99524c6..3ccde65 100644 --- a/install/Dolibarr.sh +++ b/install/Dolibarr.sh @@ -20,14 +20,15 @@ set -o nounset # Treat unset variables as an error echo "RUN $(basename "$0") ===" -if [ ! -e $(dirname "$0")/../main.env ] +DIR=$(realpath $(dirname $0/..)) +if [ ! -e $DIR/main.env ] then echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" exit 1 else echo "Environment file loaded" fi -. $(dirname "$0")/../main.env +. $DIR/../main.env diff --git a/install/Monit.sh b/install/Monit.sh index ffa51e7..ffa5253 100644 --- a/install/Monit.sh +++ b/install/Monit.sh @@ -2,14 +2,15 @@ echo "RUN $(basename "$0") ===" -if [ ! -e $(dirname "$0")/../main.env ] +DIR=$(realpath $(dirname $0/..)) +if [ ! -e $DIR/main.env ] then echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" exit 1 else echo "Environment file loaded" fi -. $(dirname "$0")/../main.env +. $DIR/../main.env # Install monit if not installed diff --git a/install/MySQL.sh b/install/MySQL.sh index b59fd77..79567ef 100644 --- a/install/MySQL.sh +++ b/install/MySQL.sh @@ -20,14 +20,15 @@ set -o nounset # Treat unset variables as an error echo "RUN $(basename "$0") ===" -if [ ! -e $(dirname "$0")/../main.env ] +DIR=$(realpath $(dirname $0/..)) +if [ ! -e $DIR/main.env ] then echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" exit 1 else echo "Environment file loaded" fi -. $(dirname "$0")/../main.env +. $DIR/../main.env if [ -f installMySQL.env ] diff --git a/install/OnlyOffice.sh b/install/OnlyOffice.sh index c2d8f62..5cb54f6 100644 --- a/install/OnlyOffice.sh +++ b/install/OnlyOffice.sh @@ -2,14 +2,15 @@ echo "RUN $(basename "$0") ===" -if [ ! -e $(dirname "$0")/../main.env ] +DIR=$(realpath $(dirname $0/..)) +if [ ! -e $DIR/main.env ] then echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" exit 1 else echo "Environment file loaded" fi -. $(dirname "$0")/../main.env +. $DIR/../main.env . $DIR/install/main.env diff --git a/install/Traefik.sh b/install/Traefik.sh index 0b928be..d321f96 100644 --- a/install/Traefik.sh +++ b/install/Traefik.sh @@ -2,14 +2,15 @@ echo "RUN $(basename "$0") ===" -if [ ! -e $(dirname "$0")/../main.env ] +DIR=$(realpath $(dirname $0/..)) +if [ ! -e $DIR/main.env ] then echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" exit 1 else echo "Environment file loaded" fi -. $(dirname "$0")/../main. +. $DIR/../main.env apt-get update diff --git a/install/WebServer.sh b/install/WebServer.sh index 715d0e4..2ba01ad 100644 --- a/install/WebServer.sh +++ b/install/WebServer.sh @@ -20,14 +20,15 @@ set -o nounset # Treat unset variables as an error echo "RUN $(basename "$0") ===" -if [ ! -e $(dirname "$0")/../main.env ] +DIR=$(realpath $(dirname $0/..)) +if [ ! -e $DIR/main.env ] then echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" exit 1 else echo "Environment file loaded" fi -. $(dirname "$0")/../main.env +. $DIR/../main.env apt-get update diff --git a/main.env.sample b/main.env.sample index 5abc885..30a746d 100644 --- a/main.env.sample +++ b/main.env.sample @@ -5,9 +5,6 @@ export MODS="Base GlpiAgent Traefik" -# TODO Racine of NoCloud Auto Instaler -export DIR=/opt/NoCloud-Auto-Installer - # Valid levels are security and upgrade export MAINTENANCE_LEVEL="security" diff --git a/upgrade/All.sh b/upgrade/All.sh index 01761f6..fc45e36 100644 --- a/upgrade/All.sh +++ b/upgrade/All.sh @@ -18,15 +18,16 @@ echo "RUN $(basename "$0") ===" -if [ ! -e $(dirname "$0")/../main.env ] + +DIR=$(realpath $(dirname $0/..)) +if [ ! -e $DIR/main.env ] then echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" exit 1 else echo "Environment file loaded" fi -. $(dirname "$0")/../main.env - +. $DIR/../main.env $DIR/utils/configure_base_tools.sh . $DIR/install/Nextcloud.env diff --git a/upgrade/Backups.sh b/upgrade/Backups.sh index 04780e8..541be2f 100644 --- a/upgrade/Backups.sh +++ b/upgrade/Backups.sh @@ -1,15 +1,16 @@ #!/bin/bash echo "RUN $(basename "$0") ===" -if [ ! -e $(dirname "$0")/../main.env ] + +DIR=$(realpath $(dirname $0/..)) +if [ ! -e $DIR/main.env ] then echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" exit 1 else echo "Environment file loaded" fi -. $(dirname "$0")/../main.env - +. $DIR/../main.env duplicity_dir="/opt/duplicity-ftp-backup/" duplicity_alt_dir="/root/duplicity-ftp-backup/" diff --git a/upgrade/Collabora.sh b/upgrade/Collabora.sh index 30bbe0d..3762ee4 100644 --- a/upgrade/Collabora.sh +++ b/upgrade/Collabora.sh @@ -2,14 +2,15 @@ echo "RUN $(basename "$0") ===" -if [ ! -e $(dirname "$0")/../main.env ] +DIR=$(realpath $(dirname $0/..)) +if [ ! -e $DIR/main.env ] then echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" exit 1 else echo "Environment file loaded" fi -. $(dirname "$0")/../main.env +. $DIR/../main.env SCRIPT_DIRECTORY=$(dirname $0) if [ -z "$(grep 'capabilities' /etc/apache2/sites-available/collabora.conf)" ]; then diff --git a/upgrade/Dolibarr.sh b/upgrade/Dolibarr.sh index d38b951..65e8383 100644 --- a/upgrade/Dolibarr.sh +++ b/upgrade/Dolibarr.sh @@ -18,14 +18,15 @@ echo "RUN $(basename "$0") ===" -if [ ! -e $(dirname "$0")/../main.env ] +DIR=$(realpath $(dirname $0/..)) +if [ ! -e $DIR/main.env ] then echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" exit 1 else echo "Environment file loaded" fi -. $(dirname "$0")/../main.env +. $DIR/../main.env DOLIBARR_DB=${DOLIBARR_DB:-"dolibarr"} if [ -z "`dpkg -l | grep dolibarr`" ] diff --git a/upgrade/Monit.sh b/upgrade/Monit.sh index b0ec799..6d3d091 100644 --- a/upgrade/Monit.sh +++ b/upgrade/Monit.sh @@ -2,14 +2,15 @@ echo "RUN $(basename "$0") ===" -if [ ! -e $(dirname "$0")/../main.env ] +DIR=$(realpath $(dirname $0/..)) +if [ ! -e $DIR/main.env ] then echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" exit 1 else echo "Environment file loaded" fi -. $(dirname "$0")/../main.env +. $DIR/../main.env # Install monit if not installed and general config if [ -z "$(dpkg -l | grep ' monit ')" ]; then diff --git a/upgrade/Traefik.sh b/upgrade/Traefik.sh index 4e71b24..380471f 100644 --- a/upgrade/Traefik.sh +++ b/upgrade/Traefik.sh @@ -1,7 +1,16 @@ #!/bin/bash echo "RUN $(basename "$0") ===" -. $(dirname "$0")/../main.env + +DIR=$(realpath $(dirname $0/..)) +if [ ! -e $DIR/main.env ] +then + echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" + exit 1 +else + echo "Environment file loaded" +fi +. $DIR/../main.env # Add systemd script to control container boot order order_systemd_file="/etc/systemd/system/docker-order.service" diff --git a/upgrade/WebServer.sh b/upgrade/WebServer.sh index 3a01476..d38642e 100644 --- a/upgrade/WebServer.sh +++ b/upgrade/WebServer.sh @@ -2,14 +2,15 @@ echo "RUN $(basename "$0") ===" -if [ ! -e $(dirname "$0")/../main.env ] +DIR=$(realpath $(dirname $0/..)) +if [ ! -e $DIR/main.env ] then echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" exit 1 else echo "Environment file loaded" fi -. $(dirname "$0")/../main.env +. $DIR/../main.env # Switch to php-fpm ver=$(php --version | awk '{print $2}' | head -n 1 | cut -d . -f 1,2) -- GitLab