refactored to use vendored shell framework. lets test.

This commit is contained in:
2025-07-14 12:34:33 -05:00
parent 5a8561ea84
commit 5bbaff89e9
6 changed files with 115 additions and 43 deletions

View File

@ -1,19 +1,25 @@
#Boilerplate and support functions
FrameworkIncludeFiles="$(ls -1 --color=none ../../../Framework-Includes/*)"
#!/bin/bash
IFS=$'\n\t'
for file in ${FrameworkIncludeFiles[@]}; do
source "$file"
export PROJECT_ROOT_PATH
PROJECT_ROOT_PATH="$(realpath ../../)"
#Framework variables are read from hee
export GIT_VENDOR_PATH_ROOT
GIT_VENDOR_PATH_ROOT="$PROJECT_ROOT_PATH/vendor/git@git.knownelement.com/29418/"
export KNELShellFrameworkRoot
KNELShellFrameworkRoot="$GIT_VENDOR_PATH_ROOT/KNEL/KNELShellFramework"
source $KNELShellFrameworkRoot/Framework-ConfigFiles/FrameworkVars
for framework_include_file in $KNELShellFrameworkRoot/framework-includes/*; do
source "$framework_include_file"
done
unset IFS
ProjectIncludeFiles="$(ls -1 --color=none ../../../Project-Includes/*)"
IFS=$'\n\t'
for file in ${ProjectIncludeFiles[@]}; do
source "$file"
for project_include_file in ../Project-Includes/*; do
source "$project_include_file"
done
unset IFS
print_info "Setting up librenms agent..."

View File

@ -1,31 +1,30 @@
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
set -o functrace
#####
#Core framework functions...
#####
export PS4='(${BASH_SOURCE}:${LINENO}): - [${SHLVL},${BASH_SUBSHELL},$?] $ '
export PROJECT_ROOT_PATH
PROJECT_ROOT_PATH="$(realpath ../../)"
function error_out()
{
echo "Bailing out. See above for reason...."
exit 1
}
#Framework variables are read from hee
function handle_failure() {
local lineno=$1
local fn=$2
local exitstatus=$3
local msg=$4
local lineno_fns=${0% 0}
if [[ "$lineno_fns" != "-1" ]] ; then
lineno="${lineno} ${lineno_fns}"
fi
echo "${BASH_SOURCE[0]}: Function: ${fn} Line Number : [${lineno}] Failed with status ${exitstatus}: $msg"
}
export GIT_VENDOR_PATH_ROOT
GIT_VENDOR_PATH_ROOT="$PROJECT_ROOT_PATH/vendor/git@git.knownelement.com/29418/"
export KNELShellFrameworkRoot
KNELShellFrameworkRoot="$GIT_VENDOR_PATH_ROOT/KNEL/KNELShellFramework"
source $KNELShellFrameworkRoot/Framework-ConfigFiles/FrameworkVars
for framework_include_file in $KNELShellFrameworkRoot/framework-includes/*; do
source "$framework_include_file"
done
for project_include_file in ../Project-Includes/*; do
source "$project_include_file"
done
trap 'handle_failure "${BASH_LINENO[*]}" "$LINENO" "${FUNCNAME[*]:-script}" "$?" "$BASH_COMMAND"' ERR
export DL_ROOT
DL_ROOT="https://dl.knownelement.com/KNEL/FetchApply/"

View File

@ -1,11 +1,23 @@
#!/bin/bash
#####
#Core framework functions...
#####
export PROJECT_ROOT_PATH
PROJECT_ROOT_PATH="$(realpath ../../)"
#Framework variables are read from hee
source $PROJECT_ROOT_PATH/Framework-ConfigFiles/FrameworkVars
#Boilerplate and support functions
export GIT_VENDOR_PATH_ROOT
GIT_VENDOR_PATH_ROOT="$PROJECT_ROOT_PATH/vendor/git@git.knownelement.com/29418/"
for framework_include_file in ../Framework-Includes/*; do
export KNELShellFrameworkRoot
KNELShellFrameworkRoot="$GIT_VENDOR_PATH_ROOT/KNEL/KNELShellFramework"
source $KNELShellFrameworkRoot/Framework-ConfigFiles/FrameworkVars
for framework_include_file in $KNELShellFrameworkRoot/framework-includes/*; do
source "$framework_include_file"
done

View File

@ -1,13 +1,34 @@
#!/bin/bash
for framework_include_file in ../../../Framework-Includes/*; do
#####
#Core framework functions...
#####
export PROJECT_ROOT_PATH
PROJECT_ROOT_PATH="$(realpath ../)"
#Framework variables are read from hee
export GIT_VENDOR_PATH_ROOT
GIT_VENDOR_PATH_ROOT="$PROJECT_ROOT_PATH/vendor/git@git.knownelement.com/29418/"
export KNELShellFrameworkRoot
KNELShellFrameworkRoot="$GIT_VENDOR_PATH_ROOT/KNEL/KNELShellFramework"
source $KNELShellFrameworkRoot/Framework-ConfigFiles/FrameworkVars
for framework_include_file in $KNELShellFrameworkRoot/framework-includes/*; do
source "$framework_include_file"
done
for project_include_file in ../../../Project-Includes/*; do
for project_include_file in ../Project-Includes/*; do
source "$project_include_file"
done
#Framework variables are read from hee
source $PROJECT_ROOT_PATH/Framework-ConfigFiles/FrameworkVars
export SUBODEV_CHECK
SUBODEV_CHECK="$(getent passwd | grep -c subodev || true)"

View File

@ -1,5 +1,31 @@
#!/bin/bash
#####
#Core framework functions...
#####
export PROJECT_ROOT_PATH
PROJECT_ROOT_PATH="$(realpath ../../)"
#Framework variables are read from hee
export GIT_VENDOR_PATH_ROOT
GIT_VENDOR_PATH_ROOT="$PROJECT_ROOT_PATH/vendor/git@git.knownelement.com/29418/"
export KNELShellFrameworkRoot
KNELShellFrameworkRoot="$GIT_VENDOR_PATH_ROOT/KNEL/KNELShellFramework"
source $KNELShellFrameworkRoot/Framework-ConfigFiles/FrameworkVars
for framework_include_file in $KNELShellFrameworkRoot/framework-includes/*; do
source "$framework_include_file"
done
for project_include_file in ../Project-Includes/*; do
source "$project_include_file"
done
# We don't want to run this on the wazuh server, otherwise bad things happen...
export TSYS_NSM_CHECK

View File

@ -8,9 +8,17 @@ export PROJECT_ROOT_PATH
PROJECT_ROOT_PATH="$(realpath ../)"
#Framework variables are read from hee
source $PROJECT_ROOT_PATH/Framework-ConfigFiles/FrameworkVars
for framework_include_file in ../Framework-Includes/*; do
export GIT_VENDOR_PATH_ROOT
GIT_VENDOR_PATH_ROOT="$PROJECT_ROOT_PATH/vendor/git@git.knownelement.com/29418/"
export KNELShellFrameworkRoot
KNELShellFrameworkRoot="$GIT_VENDOR_PATH_ROOT/KNEL/KNELShellFramework"
source $KNELShellFrameworkRoot/Framework-ConfigFiles/FrameworkVars
for framework_include_file in $KNELShellFrameworkRoot/framework-includes/*; do
source "$framework_include_file"
done