|
9 | 9 | APP_NAME="NoirWatch" |
10 | 10 | VERSION=1.1.0 |
11 | 11 | LAST_UPDATED="2024-11-26" |
| 12 | + |
12 | 13 | # TODO: |
13 | | -# - Change: url default path to use normalization functions |
14 | 14 | # - Add more notification methods (email, slack, discord, etc.) |
15 | 15 |
|
16 | 16 | # ============================== |
@@ -80,8 +80,8 @@ NC='\033[0m' # No Color |
80 | 80 | # Application Specific Variables |
81 | 81 | # ============================== |
82 | 82 |
|
83 | | -# Default URL list file location |
84 | | -DEFAULT_URL_FILE="$HOME/.config/noirwatch_urls.conf" |
| 83 | +# Default URL list file location (full default path added during initialization) |
| 84 | +URL_FILE="noirwatch_urls.conf" |
85 | 85 |
|
86 | 86 | # Initialize URLS as an empty array |
87 | 87 | URLS=() |
@@ -810,7 +810,7 @@ show_help() { |
810 | 810 |
|
811 | 811 | # URL Management |
812 | 812 | printf "\nURL Management:\n" |
813 | | - printf " -f, --url-file <file> Specify a file containing a list of URLs to monitor. (default: %s)\n" "$DEFAULT_URL_FILE" |
| 813 | + printf " -f, --url-file <file> Specify a file containing a list of URLs to monitor. (default: %s)\n" "$URL_FILE" |
814 | 814 | printf " -U, --list-urls List all watched URLs.\n" |
815 | 815 | printf " -C, --clean Delete all cached files.\n" |
816 | 816 |
|
@@ -1061,6 +1061,7 @@ process_arguments() { |
1061 | 1061 | CACHE_DIR="$(get_temp_path "$CACHE_DIR")" |
1062 | 1062 | LOG_FILE="$CACHE_DIR/$LOG_FILE" |
1063 | 1063 | PID_FILE="$CACHE_DIR/$PID_FILE" |
| 1064 | + URL_FILE="$(get_config_path "$URL_FILE")" |
1064 | 1065 |
|
1065 | 1066 | # Set default hostname |
1066 | 1067 | SYSTEM_NAME="$(get_hostname)" |
@@ -1103,7 +1104,7 @@ process_arguments() { |
1103 | 1104 | process_urls |
1104 | 1105 |
|
1105 | 1106 | # Check if the array is empty |
1106 | | - if [ ${#URLS[@]} -eq 0 ]; then |
| 1107 | + if [ ! $SHOW_STATUS && ! $SHOW_STOP && ${#URLS[@]} -eq 0 ]; then |
1107 | 1108 | log_message "ERROR" "Error: No URLS have been provided." |
1108 | 1109 | exit 1 |
1109 | 1110 | fi |
@@ -1132,8 +1133,6 @@ process_urls() { |
1132 | 1133 | if [ ${#URLS[@]} -eq 0 ]; then |
1133 | 1134 | if [ -n "$URL_FILE" ]; then |
1134 | 1135 | process_url_file "$URL_FILE" |
1135 | | - elif [ -f "$DEFAULT_URL_FILE" ]; then |
1136 | | - process_url_file "$DEFAULT_URL_FILE" |
1137 | 1136 | elif [[ "$SHOW_CONFIG" = false && "$SHOW_CONFIG_FILE" = false ]]; then |
1138 | 1137 | log_message "INFO" "Usage: $(basename "$0") <website_url>... [options]" "$LINENO" |
1139 | 1138 | log_message "INFO" "Try '$(basename "$0") --help' for more information." "$LINENO" |
@@ -1266,6 +1265,7 @@ check_website() { |
1266 | 1265 | local normalized_file="$CACHE_DIR/normalized_content_$encoded_url.txt" |
1267 | 1266 | local hash_file="$CACHE_DIR/hash_$encoded_url.txt" |
1268 | 1267 |
|
| 1268 | + log_message "DEBUG" "" "$LINENO" |
1269 | 1269 | log_message "DEBUG" "$SYSTEM_NAME Checking URL: $clean_url" "$LINENO" |
1270 | 1270 | log_message "DEBUG" "- Submitted URL: $website_url" "$LINENO" |
1271 | 1271 | log_message "DEBUG" "- Global threshold: $THRESHOLD%" "$LINENO" |
|
0 commit comments