diff --git a/core/base.module.sh b/core/base.module.sh index 7f4db0a..2f706c3 100755 --- a/core/base.module.sh +++ b/core/base.module.sh @@ -66,7 +66,7 @@ function prepare.setCIS() { && base.abort "Array CIS was not initialized correctly." # Retrieves the variables for this module using 'BASH_SOURCE[0]', the infos about the script using '$0'. - local _ROOT_TRUNK _FULLBASENAME _FULLSCRIPTNAME + local _ROOT_TRUNK _FULLBASENAME _FULLSCRIPTNAME _CIS_ROOT _FULLBASENAME="$(realpath "${BASH_SOURCE[0]}" 2> /dev/null)" _FULLSCRIPTNAME="$(realpath "${0}" 2> /dev/null)" @@ -80,11 +80,18 @@ function prepare.setCIS() { _ROOT_TRUNK="${_ROOT_TRUNK%cis/*}" done - readonly _ROOT_TRUNK _FULLBASENAME _FULLSCRIPTNAME # Folders always ends with an tailing '/' - CIS[ROOT]="${_ROOT_TRUNK:?"Missing ROOT_TRUNK"}cis/" - CIS[DOMAIN]="$(base.printOwnDomain "${CIS[ROOT]:?"Missing ROOT"}")" + _CIS_ROOT="${_ROOT_TRUNK:?"Missing ROOT_TRUNK"}cis/" + readonly _ROOT_TRUNK _FULLBASENAME _FULLSCRIPTNAME _CIS_ROOT + + [ -d "${_CIS_ROOT:?"Missing CIS_ROOT"}" ] \ + && [ -d "${_CIS_ROOT}core/" ] \ + && [ -d "${_CIS_ROOT}definitions/" ] \ + && [ -d "${_CIS_ROOT}states/" ] \ + && CIS[ROOT]="${_CIS_ROOT}" + + CIS[DOMAIN]="$(base.printOwnDomain "${CIS[ROOT]:?"Missing global CIS_ROOT"}")" [ -z "${CIS[DOMAIN]}" ] \ && echo \ diff --git a/core/printCisRoot.sh b/core/printCisRoot.sh deleted file mode 100755 index 67bc2db..0000000 --- a/core/printCisRoot.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -_SCRIPT="$(readlink -f "${0}" 2> /dev/null)" -_CIS_ROOT="${_SCRIPT%%/core/*}/" #Removes longest matching pattern '/core/*' from the end - -[ -d "${_CIS_ROOT}" ] \ - && [ -d "${_CIS_ROOT}definitions/" ] \ - && [ -d "${_CIS_ROOT}states/" ] \ - && echo "${_CIS_ROOT}" \ - && exit 0 - -echo "FAIL: Unable to detect CIS_ROOT" >&2 -exit 1