about to test this on rr-middleware...

This commit is contained in:
2025-06-30 13:23:24 -05:00
parent d82c8733fa
commit f3070de151
7 changed files with 40 additions and 95 deletions

View File

@ -1,4 +0,0 @@
#Global Variables used by the framework
export ProjectIncludes="0"
export PreflightCheck="0"

View File

@ -0,0 +1,3 @@
#Global Variables used by the framework
export ProjectIncludes="1"

View File

@ -19,7 +19,8 @@ export PS4='(${BASH_SOURCE}:${LINENO}): - [${SHLVL},${BASH_SUBSHELL},$?] $ '
function error_out() function error_out()
{ {
echo "Bailing out. See above for reason...." print_error "$1"
print_error "Bailing out. See above for reason...."
exit 1 exit 1
} }

View File

@ -3,29 +3,17 @@
function PreflightCheck() function PreflightCheck()
{ {
#Common things I check for in the scripts I write. export curr_user="$USER"
export user_check
#export curr_host="$(hostname)" user_check="$(echo "$curr_user" | grep -c root)"
#export curr_user="$USER"
#export host_check="$(echo $curr_host | grep -c <desired hostname>)"
#export user_check="$(echo $curr_user | grep -c <desired username>)"
#if [ $host_check -ne 1 ]; then
# echo "Must run on <desired host>."
# error_out
#fi
#if [ $user_check -ne 1 ]; then if [ $user_check -ne 1 ]; then
# echo "Must run as <desired user>." print_error "Must run as root."
# error_out error_out
#fi fi
#if [ "$ARG_COUNT" -ne <the right num> ]; then
# help
# error_out
#fi
#Your additional stuff here...
echo "All checks passed...." echo "All checks passed...."
} }

View File

@ -1,87 +1,43 @@
#!/usr/bin/bash #!/usr/bin/bash
export CURRENT_TIMESTAMP #####
CURRENT_TIMESTAMP="$(date +%A-%Y-%m-%d-%T)" #Core framework functions...
#####
export LOGFILENAME export FRAMEWORK_INCLUDES_FULL_PATH
LOGFILENAME="SetupNewSystem.${CURRENT_TIMESTAMP}.$$" FRAMEWORK_INCLUDES_FULL_PATH="$(realpath ../Framework-Includes)"
# Standard strict mode and error handling boilderplate... export FRAMEWORK_CONFIGS_FULL_PATH
FRAMEWORK_CONFIGS_FULL_PATH="$(realpath ../Framework-ConfigFiles)"
set -o errexit export PROJECT_INCLUDES_FULL_PATH
set -o nounset PROJECT_INCLUDES_FULL_PATH="$(realpath ../Project-Includes)"
set -o pipefail
set -o functrace
export PS4='(${BASH_SOURCE}:${LINENO}): - [${SHLVL},${BASH_SUBSHELL},$?] $ ' export PROJECT_CONGIGS_FULL_PATH
PROJECT_INCLUDES_FULL_PATH="$(realpath ../Project-ConfigFiles)"
function print_info()
{
GREEN='\033[0;32m'
NC='\033[0m'
tput bold
echo -e "$GREEN $1${NC}"
echo -e "$GREEN $1${NC}" >> "$LOGFILENAME"
tput sgr0
}
function print_error()
{
RED='\033[0;31m'
NC='\033[0m'
tput bold
echo -e "$RED $1${NC}"
echo "$1"
echo -e "$RED $1${NC}" >> "$LOGFILENAME"
tput sgr0
}
log_info_message() {
local message="$1"
local logfile="/var/log/my_script.log" # Define your log file path
echo "$message" | tee -a "$logfile"
}
function error_out() #Framework variables are read from hee
{ source $FRAMEWORK_CONFIGS_FULL_PATH/FrameworkVars
print_error "$1"
print_error "Bailing out. See above for reason...."
exit 1
}
function handle_failure() { #Boilerplate and support functions
local lineno=$1 FrameworkIncludeFiles="$(ls -1 --color=none $FRAMEWORK_INCLUDES_FULL_PATH/*)"
local fn=$2
local exitstatus=$3 IFS=$'\n\t'
local msg=$4 for file in ${FrameworkIncludeFiles[@]}; do
local lineno_fns=${0% 0} . "$file"
if [[ "$lineno_fns" != "-1" ]] ; then done
lineno="${lineno} ${lineno_fns}" unset IFS
if [[ ProjectIncludes = 1 ]]; then
ProjectIncludeFiles="$(ls -1 --color=none $PROJECT_INCLUDES_FULL_PATH/*)"
IFS=$'\n\t'
for file in ${ProjectIncludeFiles[@]}; do
. "$file"
done
unset IFS
fi fi
echo "${BASH_SOURCE[0]}: Function: ${fn} Line Number : [${lineno}] Failed with status ${exitstatus}: $msg"
}
trap 'handle_failure "${BASH_LINENO[*]}" "$LINENO" "${FUNCNAME[*]:-script}" "$?" "$BASH_COMMAND"' ERR
function PreflightCheck()
{
export curr_user="$USER"
export user_check
user_check="$(echo "$curr_user" | grep -c root)"
if [ $user_check -ne 1 ]; then
print_error "Must run as root."
error_out
fi
print_info "All checks passed...."
}
# Start actual script logic here... # Start actual script logic here...

1
logs/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
!.gitignore