66
77# App version and name
88APP_NAME=" NoirCon"
9- VERSION=1.0.1
9+ VERSION=1.0.2
1010LAST_UPDATED=" 2024-12-17"
1111
1212# ==============================
@@ -25,7 +25,7 @@ DEPENDENCIES=("nc" "openssl" "timeout" "whois")
2525
2626# Default configuration file location (full default path added during initialization)
2727CONFIG_FILE_NAME=" $( basename " $0 " ) .json"
28- SKIP_CONFIG_KEYS=(" CONFIG_FILE " " PID_FILE" )
28+ SKIP_CONFIG_KEYS=(" PID_FILE" )
2929
3030# Master directory to store all cache files (full default path added during initialization)
3131CACHE_DIR=" $( basename " $0 " ) _cache"
@@ -802,9 +802,12 @@ start_process() {
802802# Function: Load configuration from JSON file
803803load_config () {
804804 local config_file_path=" $1 "
805- if [[ ! -f " $config_file_path " ]]; then
805+
806+ if key_exists " CONFIG_FILE" SKIP_CONFIG_KEYS[@] && [[ ! -f " $config_file_path " ]]; then
806807 log_message " FATAL" " Configuration file not found: $config_file_path " " $LINENO "
807808 exit 1
809+ elif ! key_exists " CONFIG_FILE" SKIP_CONFIG_KEYS[@] && [[ ! -f " $config_file_path " ]]; then
810+ return 0
808811 fi
809812
810813 # Use jq to parse the JSON and set environment variables
@@ -814,7 +817,7 @@ load_config() {
814817
815818 while IFS=" =" read -r key value; do
816819 # Skip empty lines, invalid entries, or keys that are in the skip_keys array
817- if [[ -n " $key " && -n " $value " && ! " ${SKIP_CONFIG_KEYS[@]} " =~ " ${key} " ]]; then
820+ if [[ -n " $key " && -n " $value " && ! " ${SKIP_CONFIG_KEYS[@]} " =~ " ${key} " && " $key " != " CONFIG_FILE " ]]; then
818821 [[ " $key " == * _DIR || " $key " == * _FILE || " $key " == * _CMD ]] && value=" $( normalize_path " $value " ) "
819822 export " $key " =" $value "
820823 log_message " DEBUG" " Setting $key =$value " " $LINENO "
@@ -828,6 +831,17 @@ get_connection_groups() {
828831 jq -r ' .connections | keys | sort[]' " $config_file_path "
829832}
830833
834+ # Function: Check if a key exists in the SKIP_CONFIG_KEYS
835+ key_exists () {
836+ local key=" $1 "
837+
838+ if [[ " ${SKIP_CONFIG_KEYS[@]} " =~ " ${key} " ]]; then
839+ return 0 # Key exists
840+ fi
841+
842+ return 1 # Key does not exist
843+ }
844+
831845# Function: Get connection settings as key-value pairs
832846get_connection_settings () {
833847 local group=" $1 "
@@ -1983,7 +1997,7 @@ main() {
19831997 log_message " DEBUG" " Iteration: $repeat_count " " $LINENO "
19841998
19851999 # Check if REPEAT is set and not zero
1986- if [[ -n " $REPEAT " || " $REPEAT " -ne 0 ]] && [[ " $repeat_count " -ge " $REPEAT " ]]; then
2000+ if [[ -z " $REPEAT " || " $REPEAT " != 0 ]] && [[ " $repeat_count " -ge " $REPEAT " ]]; then
19872001 log_message " DEBUG" " Reached the maximum number of repetitions: $REPEAT " " $LINENO "
19882002 break
19892003 else
0 commit comments