From 9024576f76ce1624aad831367a31cfef7c624d10 Mon Sep 17 00:00:00 2001 From: Elian Loraux <elian.loraux@tetras-libre.fr> Date: Wed, 16 Oct 2024 14:57:39 +0200 Subject: [PATCH] add basename --- checks/backups.sh | 2 ++ checks/kernel.sh | 2 ++ checks/list_domains.sh | 6 +++--- checks/mail.sh | 3 ++- checks/rkhunter.sh | 2 ++ install/AptCacher.sh | 4 +++- install/Base.sh | 4 +++- install/Certbot.sh | 3 ++- install/Collabora.sh | 4 +++- install/Dolibarr.sh | 4 +++- install/GlpiAgent.sh | 2 ++ install/Monit.sh | 4 +++- install/MySQL.sh | 4 +++- install/Nextcloud.sh | 4 +++- install/NextcloudApps.sh | 2 ++ install/OnlyOffice.sh | 4 +++- install/TetrasBack.sh | 3 ++- install/Traefik.sh | 4 +++- install/WebServer.sh | 6 ++++-- install/ncdu.sh | 2 ++ run.sh | 2 ++ upgrade/All.sh | 3 ++- upgrade/Collabora.sh | 4 +++- upgrade/Dolibarr.sh | 4 +++- upgrade/Monit.sh | 5 ++++- upgrade/Nextcloud.sh | 2 ++ upgrade/TetrasBack.sh | 2 ++ upgrade/Traefik.sh | 2 ++ upgrade/WebServer.sh | 4 +++- utils/attestDolibarr.sh | 5 ++++- utils/clamav-weekly.sh | 3 ++- utils/configure_base_tools.sh | 2 ++ utils/expandCertbot.sh | 3 ++- utils/getLastDolibarrDeb.sh | 2 ++ utils/getip.sh | 2 +- utils/healthReport.sh | 1 + utils/nextcloudStrongDirectoryPermissions.sh | 2 ++ utils/startcollabora.sh | 4 +++- validate.sh | 2 ++ 39 files changed, 96 insertions(+), 27 deletions(-) diff --git a/checks/backups.sh b/checks/backups.sh index eab0aed..afa03a1 100644 --- a/checks/backups.sh +++ b/checks/backups.sh @@ -1,5 +1,7 @@ #!/bin/bash +echo "============= $(basename "$0") =================" + backup_system="" duplicity_dir="/opt/duplicity-ftp-backup/" duplicity_alt_dir="/root/duplicity-ftp-backup/" diff --git a/checks/kernel.sh b/checks/kernel.sh index bb03fa6..a7f20fe 100644 --- a/checks/kernel.sh +++ b/checks/kernel.sh @@ -1,5 +1,7 @@ #!/bin/bash +echo "============= $(basename "$0") =================" + # Check if reeboot is requird last_kernel="$(dpkg -l | awk '/linux-image-[0-9]/{print $2}' | sort -rn | head -n 1)" running_kernel="linux-image-$(uname -r)" diff --git a/checks/list_domains.sh b/checks/list_domains.sh index 54f49be..350ec38 100644 --- a/checks/list_domains.sh +++ b/checks/list_domains.sh @@ -1,4 +1,7 @@ #!/bin/bash + +echo "============= $(basename "$0") =================" + if [ "${WEB_SERVER}" == "apache2" ] then apache2ctl -S 2>/dev/null | awk '/namevhost/{print "https://"$4}' | sort -u | grep -v "127.0...1" @@ -17,6 +20,3 @@ if id "dockerweb" >/dev/null 2>&1; then echo "===== list of domain ====" docker ps -qa | xargs docker inspect | awk '/traefik.http.routers.*.rule/{print $2}' | sed -e 's/^"Host(`//' -e 's/`)",//' -e 's/`,`/\n/g' | grep -v '!ClientIP' | sort -u fi - - - diff --git a/checks/mail.sh b/checks/mail.sh index f639e79..159335b 100644 --- a/checks/mail.sh +++ b/checks/mail.sh @@ -1,3 +1,4 @@ #!/bin/bash -Subject: test\n\nCeci est un test" | sendmail -t root +echo "============= $(basename "$0") =================" +Subject: test\n\nCeci est un test" | sendmail -t root diff --git a/checks/rkhunter.sh b/checks/rkhunter.sh index 7600551..3569d35 100644 --- a/checks/rkhunter.sh +++ b/checks/rkhunter.sh @@ -1,5 +1,7 @@ #!/bin/bash +echo "============= $(basename "$0") =================" + # Check rootkits and antivirus if [ `grep -c "^ALLOWHIDDENDIR=/etc/.java" /etc/rkhunter.conf` -eq 0 ] then diff --git a/install/AptCacher.sh b/install/AptCacher.sh index 9938725..8fd0b75 100755 --- a/install/AptCacher.sh +++ b/install/AptCacher.sh @@ -1,8 +1,10 @@ #!/bin/bash +echo "============= $(basename "$0") =================" + if [ ! -e $(pwd)/$(dirname "$0")/../main.env ] then - echo "Please copy in racine of NoCloud Auto Installer main.env.sample tomain.env and edit it" + echo "Please copy in racine of NoCloud Auto Installer main.env.sample to ain.env and edit it" exit 1 fi . $(pwd)/$(dirname "$0")/../main.env diff --git a/install/Base.sh b/install/Base.sh index c8b8ee7..8eff281 100644 --- a/install/Base.sh +++ b/install/Base.sh @@ -18,9 +18,11 @@ set -o nounset # Treat unset variables as an error +echo "============= $(basename "$0") =================" + if [ ! -e $(pwd)/$(dirname "$0")/../main.env ] then - echo "Please copy in racine of NoCloud Auto Installer main.env.sample tomain.env and edit it" + echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" exit 1 fi . $(pwd)/$(dirname "$0")/../main.env diff --git a/install/Certbot.sh b/install/Certbot.sh index 65fc52c..bbd2cef 100755 --- a/install/Certbot.sh +++ b/install/Certbot.sh @@ -16,10 +16,11 @@ # You should have received a copy of the GNU General Public License # along # with this program. If not, see <http://www.gnu.org/licenses/>. +echo "============= $(basename "$0") =================" if [ ! -e $(pwd)/$(dirname "$0")/../main.env ] then - echo "Please copy in racine of NoCloud Auto Installer main.env.sample tomain.env and edit it" + echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" exit 1 fi . $(pwd)/$(dirname "$0")/../main.env diff --git a/install/Collabora.sh b/install/Collabora.sh index 0cf6d99..f6cb72f 100644 --- a/install/Collabora.sh +++ b/install/Collabora.sh @@ -18,9 +18,11 @@ set -o nounset # Treat unset variables as an error +echo "============= $(basename "$0") =================" + if [ ! -e $(pwd)/$(dirname "$0")/../main.env ] then - echo "Please copy in racine of NoCloud Auto Installer main.env.sample tomain.env and edit it" + echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" exit 1 fi . $(pwd)/$(dirname "$0")/../main.env diff --git a/install/Dolibarr.sh b/install/Dolibarr.sh index 45222d0..3e6e0dd 100644 --- a/install/Dolibarr.sh +++ b/install/Dolibarr.sh @@ -18,9 +18,11 @@ set -o nounset # Treat unset variables as an error +echo "============= $(basename "$0") =================" + if [ ! -e $(pwd)/$(dirname "$0")/../main.env ] then - echo "Please copy in racine of NoCloud Auto Installer main.env.sample tomain.env and edit it" + echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" exit 1 fi . $(pwd)/$(dirname "$0")/../main.env diff --git a/install/GlpiAgent.sh b/install/GlpiAgent.sh index 6102176..7e39ec0 100644 --- a/install/GlpiAgent.sh +++ b/install/GlpiAgent.sh @@ -1,4 +1,6 @@ #!/bin/bash +echo "============= $(basename "$0") =================" + cd /tmp wget -O glpi.deb https://github.com/glpi-project/glpi-agent/releases/download/1.4/glpi-agent_1.4-1_all.deb dpkg -i glpi.deb diff --git a/install/Monit.sh b/install/Monit.sh index bc81bbe..53c05e4 100644 --- a/install/Monit.sh +++ b/install/Monit.sh @@ -1,8 +1,10 @@ #!/bin/bash +echo "============= $(basename "$0") =================" + if [ ! -e $(pwd)/$(dirname "$0")/../main.env ] then - echo "Please copy in racine of NoCloud Auto Installer main.env.sample tomain.env and edit it" + echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" exit 1 fi . $(pwd)/$(dirname "$0")/../main.env diff --git a/install/MySQL.sh b/install/MySQL.sh index ad11186..5c8a2ab 100644 --- a/install/MySQL.sh +++ b/install/MySQL.sh @@ -18,9 +18,11 @@ set -o nounset # Treat unset variables as an error +echo "============= $(basename "$0") =================" + if [ ! -e $(pwd)/$(dirname "$0")/../main.env ] then - echo "Please copy in racine of NoCloud Auto Installer main.env.sample tomain.env and edit it" + echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" exit 1 fi . $(pwd)/$(dirname "$0")/../main.env diff --git a/install/Nextcloud.sh b/install/Nextcloud.sh index cf7831f..2829fac 100644 --- a/install/Nextcloud.sh +++ b/install/Nextcloud.sh @@ -18,9 +18,11 @@ set -o nounset # Treat unset variables as an error +echo "============= $(basename "$0") =================" + if [ ! -e $(pwd)/$(dirname "$0")/../main.env ] then - echo "Please copy in racine of NoCloud Auto Installer main.env.sample tomain.env and edit it" + echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" exit 1 fi . $(pwd)/$(dirname "$0")/../main.env diff --git a/install/NextcloudApps.sh b/install/NextcloudApps.sh index a5b7834..0ab8c32 100644 --- a/install/NextcloudApps.sh +++ b/install/NextcloudApps.sh @@ -15,6 +15,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +echo "============= $(basename "$0") =================" + NEXTCLOUD_INSTALL_DIR="/var/www/nextcloud/" APPS="tasks news talk calendar contacts impersonate" diff --git a/install/OnlyOffice.sh b/install/OnlyOffice.sh index f29e472..9b2855a 100644 --- a/install/OnlyOffice.sh +++ b/install/OnlyOffice.sh @@ -1,8 +1,10 @@ #!/bin/bash +echo "============= $(basename "$0") =================" + if [ ! -e $(pwd)/$(dirname "$0")/../main.env ] then - echo "Please copy in racine of NoCloud Auto Installer main.env.sample tomain.env and edit it" + echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" exit 1 fi . $(pwd)/$(dirname "$0")/../main.env diff --git a/install/TetrasBack.sh b/install/TetrasBack.sh index 7219a65..1a04cc1 100644 --- a/install/TetrasBack.sh +++ b/install/TetrasBack.sh @@ -16,6 +16,7 @@ # You should have received a copy of the GNU General Public License # along # with this program. If not, see <http://www.gnu.org/licenses/>. +echo "============= $(basename "$0") =================" TB_CONFIG_ServerName=${TB_CONFIG_ServerName:-tetras-back.${DOMAIN}} TB_CONFIG_ServerAdmin=${TB_CONFIG_ServerAdmin:-${SERVER_ADMIN}} @@ -24,7 +25,7 @@ set -o nounset # Treat unset variables as an error if [ ! -e $(pwd)/$(dirname "$0")/../main.env ] then - echo "Please copy in racine of NoCloud Auto Installer main.env.sample tomain.env and edit it" + echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" exit 1 fi . $(pwd)/$(dirname "$0")/../main.env diff --git a/install/Traefik.sh b/install/Traefik.sh index 11cf5c4..5adfac2 100644 --- a/install/Traefik.sh +++ b/install/Traefik.sh @@ -1,8 +1,10 @@ #!/bin/bash +echo "============= $(basename "$0") =================" + if [ ! -e $(pwd)/$(dirname "$0")/../main.env ] then - echo "Please copy in racine of NoCloud Auto Installer main.env.sample tomain.env and edit it" + echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" exit 1 fi . $(pwd)/$(dirname "$0")/../main.env diff --git a/install/WebServer.sh b/install/WebServer.sh index 3f635f5..9b68940 100644 --- a/install/WebServer.sh +++ b/install/WebServer.sh @@ -18,15 +18,17 @@ set -o nounset # Treat unset variables as an error -apt-get update +echo "============= $(basename "$0") =================" if [ ! -e $(pwd)/$(dirname "$0")/../main.env ] then - echo "Please copy in racine of NoCloud Auto Installer main.env.sample tomain.env and edit it" + echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" exit 1 fi . $(pwd)/$(dirname "$0")/../main.env +apt-get update + if [ "${WEB_SERVER}" == "apache2" ] then export WEB_SERVER_PACKAGES="apache2" diff --git a/install/ncdu.sh b/install/ncdu.sh index c06ef33..701fd0f 100644 --- a/install/ncdu.sh +++ b/install/ncdu.sh @@ -1,5 +1,7 @@ #!/bin/bash +echo "============= $(basename "$0") =================" + # Install ncdu for disk usage analysis if [ -z "$(dpkg -l | grep ncdu)" ]; then apt-get update && apt-get install -y ncdu diff --git a/run.sh b/run.sh index 9a3a450..959b02a 100644 --- a/run.sh +++ b/run.sh @@ -18,6 +18,8 @@ set -o nounset # Treat unset variables as an error +echo "============= $(basename "$0") =================" + if [ ! -e `pwd`/main.env ] then echo "Please copy `pwd`/main.env.sample to `pwd`/main.env and edit it" diff --git a/upgrade/All.sh b/upgrade/All.sh index 2489a1f..ea2a191 100644 --- a/upgrade/All.sh +++ b/upgrade/All.sh @@ -16,10 +16,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +echo "============= $(basename "$0") =================" if [ ! -e $(pwd)/$(dirname "$0")/../main.env ] then - echo "Please copy in racine of NoCloud Auto Installer main.env.sample tomain.env and edit it" + echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" exit 1 fi . $(pwd)/$(dirname "$0")/../main.env diff --git a/upgrade/Collabora.sh b/upgrade/Collabora.sh index 4c03104..d144783 100644 --- a/upgrade/Collabora.sh +++ b/upgrade/Collabora.sh @@ -1,8 +1,10 @@ #!/bin/bash +echo "============= $(basename "$0") =================" + if [ ! -e $(pwd)/$(dirname "$0")/../main.env ] then - echo "Please copy in racine of NoCloud Auto Installer main.env.sample tomain.env and edit it" + echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" exit 1 fi . $(pwd)/$(dirname "$0")/../main.env diff --git a/upgrade/Dolibarr.sh b/upgrade/Dolibarr.sh index e9da320..31fe92e 100644 --- a/upgrade/Dolibarr.sh +++ b/upgrade/Dolibarr.sh @@ -16,9 +16,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +echo "============= $(basename "$0") =================" + if [ ! -e $(pwd)/$(dirname "$0")/../main.env ] then - echo "Please copy in racine of NoCloud Auto Installer main.env.sample tomain.env and edit it" + echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" exit 1 fi . $(pwd)/$(dirname "$0")/../main.env diff --git a/upgrade/Monit.sh b/upgrade/Monit.sh index fde5319..523cafe 100644 --- a/upgrade/Monit.sh +++ b/upgrade/Monit.sh @@ -1,7 +1,10 @@ #!/bin/bash + +echo "============= $(basename "$0") =================" + if [ ! -e $(pwd)/$(dirname "$0")/../main.env ] then - echo "Please copy in racine of NoCloud Auto Installer main.env.sample tomain.env and edit it" + echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" exit 1 fi . $(pwd)/$(dirname "$0")/../main.env diff --git a/upgrade/Nextcloud.sh b/upgrade/Nextcloud.sh index 3704807..a23b5be 100644 --- a/upgrade/Nextcloud.sh +++ b/upgrade/Nextcloud.sh @@ -16,6 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +echo "============= $(basename "$0") =================" + NEXTCLOUD_INSTALL_DIR=${NEXTCLOUD_INSTALL_DIR:-'/var/www/nextcloud'} NEXTCLOUD_INSTALL_DIR=`echo $NEXTCLOUD_INSTALL_DIR | sed 's@/*$@@'` htuser=${htuser:-'www-data'} diff --git a/upgrade/TetrasBack.sh b/upgrade/TetrasBack.sh index b257d88..b5bfe5b 100644 --- a/upgrade/TetrasBack.sh +++ b/upgrade/TetrasBack.sh @@ -16,6 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +echo "============= $(basename "$0") =================" + OLD=$PWD DIR="$OLD/Tetras-back" if [ ! -d $DIR ] diff --git a/upgrade/Traefik.sh b/upgrade/Traefik.sh index ad74525..675bbd9 100644 --- a/upgrade/Traefik.sh +++ b/upgrade/Traefik.sh @@ -1,5 +1,7 @@ #!/bin/bash +echo "============= $(basename "$0") =================" + # Services maintenance cd /home/dockerweb diff --git a/upgrade/WebServer.sh b/upgrade/WebServer.sh index b19ad2f..163b9b2 100644 --- a/upgrade/WebServer.sh +++ b/upgrade/WebServer.sh @@ -1,8 +1,10 @@ #!/bin/bash +echo "============= $(basename "$0") =================" + if [ ! -e $(pwd)/$(dirname "$0")/../main.env ] then - echo "Please copy in racine of NoCloud Auto Installer main.env.sample tomain.env and edit it" + echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" exit 1 fi . $(pwd)/$(dirname "$0")/../main.env diff --git a/utils/attestDolibarr.sh b/utils/attestDolibarr.sh index da58336..3b047f6 100755 --- a/utils/attestDolibarr.sh +++ b/utils/attestDolibarr.sh @@ -1,7 +1,10 @@ #!/bin/bash + +echo "============= $(basename "$0") =================" + if [ ! -e $(pwd)/$(dirname "$0")/../main.env ] then - echo "Please copy in racine of NoCloud Auto Installer main.env.sample tomain.env and edit it" + echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" exit 1 fi . $(pwd)/$(dirname "$0")/../main.env diff --git a/utils/clamav-weekly.sh b/utils/clamav-weekly.sh index 7f812ac..009b4af 100755 --- a/utils/clamav-weekly.sh +++ b/utils/clamav-weekly.sh @@ -16,6 +16,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +echo "============= $(basename "$0") =================" LOGFILE="/var/log/clamav.log"; EMAIL_TO="root"; @@ -23,7 +24,7 @@ DIRTOSCAN="/var/www /home"; do_sendmail(){ message+="\n\n==== LOG ====\n\n" - while read line + while read line do message+="$line\n" done < $LOGFILE diff --git a/utils/configure_base_tools.sh b/utils/configure_base_tools.sh index d60205b..baaae43 100755 --- a/utils/configure_base_tools.sh +++ b/utils/configure_base_tools.sh @@ -1,4 +1,6 @@ #!/bin/bash +echo "============= $(basename "$0") =================" + if [ -z "$(grep '^alias ls=' /root/.bashrc)" ] then echo 'alias ls="ls -lstrh --color=auto"' >> /root/.bashrc diff --git a/utils/expandCertbot.sh b/utils/expandCertbot.sh index 98d9d8d..4504b13 100644 --- a/utils/expandCertbot.sh +++ b/utils/expandCertbot.sh @@ -1,4 +1,6 @@ #!/bin/bash +echo "============= $(basename "$0") =================" + if [ -z "$2" ] then echo "usage $0 additional-dommains certificate" @@ -10,4 +12,3 @@ domains="`openssl x509 -in $2 -inform pem -noout -text | grep DNS | sed -e 's/ echo "Requesting certificate for domains: '$domains'" certbot certonly --expand --apache --must-staple --hsts --domains=$domains - diff --git a/utils/getLastDolibarrDeb.sh b/utils/getLastDolibarrDeb.sh index cfc1800..7b4f9df 100755 --- a/utils/getLastDolibarrDeb.sh +++ b/utils/getLastDolibarrDeb.sh @@ -1,4 +1,6 @@ #!/bin/bash +echo "============= $(basename "$0") =================" + # Get Dolideb version list curl \ https://sourceforge.net/projects/dolibarr/files/Dolibarr%20installer%20for%20Debian-Ubuntu%20%28DoliDeb%29/ \ diff --git a/utils/getip.sh b/utils/getip.sh index 41723c0..378ccb6 100755 --- a/utils/getip.sh +++ b/utils/getip.sh @@ -15,6 +15,7 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +echo "============= $(basename "$0") =================" isIP() { @@ -44,4 +45,3 @@ do exit 0 fi done - diff --git a/utils/healthReport.sh b/utils/healthReport.sh index 0065e48..9abebdc 100755 --- a/utils/healthReport.sh +++ b/utils/healthReport.sh @@ -15,6 +15,7 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +echo "============= $(basename "$0") =================" recipient="root" level=info diff --git a/utils/nextcloudStrongDirectoryPermissions.sh b/utils/nextcloudStrongDirectoryPermissions.sh index cddabb1..d9e7304 100755 --- a/utils/nextcloudStrongDirectoryPermissions.sh +++ b/utils/nextcloudStrongDirectoryPermissions.sh @@ -16,6 +16,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +echo "============= $(basename "$0") =================" + # from https://doc.owncloud.org/server/9.0/admin_manual/installation/installation_wizard.html?highlight=trusted#trusted-domains NEXTCLOUD_INSTALL_DIR=${NEXTCLOUD_INSTALL_DIR:-'/var/www/nextcloud'} htuser=${htuser:-'www-data'} diff --git a/utils/startcollabora.sh b/utils/startcollabora.sh index 5489dde..ebf8403 100755 --- a/utils/startcollabora.sh +++ b/utils/startcollabora.sh @@ -1,8 +1,10 @@ #!/bin/bash +echo "============= $(basename "$0") =================" + if [ ! -e $(pwd)/$(dirname "$0")/../main.env ] then - echo "Please copy in racine of NoCloud Auto Installer main.env.sample tomain.env and edit it" + echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it" exit 1 fi . $(pwd)/$(dirname "$0")/../main.env diff --git a/validate.sh b/validate.sh index 3fe43a6..664a9a8 100755 --- a/validate.sh +++ b/validate.sh @@ -1,5 +1,7 @@ #!/bin/bash +echo "============= $(basename "$0") =================" + RED='\033[0;31m' NC='\033[0m' # No Color -- GitLab