usage of printf improved, format and ensuring root privileges for setup scripts now is more reliable

This commit is contained in:
m8in
2026-05-08 00:13:12 +02:00
parent 1c94a26710
commit ee114ee732
7 changed files with 40 additions and 52 deletions
+7 -15
View File
@@ -1,25 +1,17 @@
#!/bin/bash
if [ $(id -u) -ne 0 ]; then
sudo "${0}" && exit 0
exit 1
fi
[ "$(id -u)" != "0" ] \
&& sudo "${0}" \
&& exit 0
_SETUP="$(readlink -f "${0}" 2> /dev/null)"
# Folders always ends with an tailing '/'
_CIS_ROOT="${_SETUP%%/script/monitor/*}/" #Removes longest matching pattern '/script/monitor/*' from the end
_CORE_SCRIPTS="${_CIS_ROOT:?"Missing CIS_ROOT"}core/"
_DOMAIN="$("${_CIS_ROOT:?"Missing CIS_ROOT"}core/printOwnDomain.sh")"
_DEFINITIONS="${_CIS_ROOT:?"Missing CIS_ROOT"}definitions/${_DOMAIN:?"Missing DOMAIN"}/"
source /cis/core/base.module.sh
echo "Setup the user and permission to enable the monitoring this host ... " \
&& "${_CORE_SCRIPTS:?"Missing CORE_SCRIPTS"}addNormalUser.sh" monitoring \
&& "${CIS[COREROOT]:?"Missing CIS_COREROOT"}addNormalUser.sh" monitoring \
&& echo \
&& "${_CORE_SCRIPTS:?"Missing CORE_SCRIPTS"}defineAuthorizedKeysOfUser.sh" "${_DEFINITIONS}" monitoring \
&& "${CIS[COREROOT]:?"Missing CIS_COREROOT"}defineAuthorizedKeysOfUser.sh" "${CIS[DOMAINDEFINITIONS]}" monitoring \
&& exit 0
exit 1