Skip to content

Commit de1c0d6

Browse files
author
John Smith III
committed
Fixed:
- URL default location is empty - Failing on --status and --stop
1 parent d33d540 commit de1c0d6

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2626
### Fixed
2727

2828
- Cross platform paths are normalization
29+
- URL default location is empty
30+
- Failing on --status and --stop
2931

3032
## [1.0.2] - 2024-11-23
3133

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ Run the script with the desired options. Below are some examples:
282282

283283
## Configuration
284284

285-
NoirWatch uses a configuration file to store default settings. The default location is `$HOME/.config/noirwatch.conf`. You can initialize a configuration file with default settings using:
285+
NoirWatch uses a configuration file to store default settings. The default location is `~/.config/noirwatch.conf`. You can initialize a configuration file with default settings using:
286286

287287
```bash
288288
./noirwatch --init
@@ -294,8 +294,8 @@ NoirWatch uses a configuration file to store default settings. The default locat
294294
# NoirWatch Configuration File
295295
CACHE_DIR="/tmp/noirwatch_cache"
296296
LOG_FILE="/tmp/noirwatch_cache/noirwatch.log"
297-
CONFIG_FILE="$HOME/.config/noirwatch.conf"
298-
URL_FILE="$HOME/.config/noirwatch_urls.conf"
297+
CONFIG_FILE="~/.config/noirwatch.conf"
298+
URL_FILE="~/.config/noirwatch_urls.conf"
299299
CHECK_INTERVAL=15
300300
TIMEOUT=5
301301
PUSHOVER_NOTIFICATION=false

noirwatch

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
APP_NAME="NoirWatch"
1010
VERSION=1.1.0
1111
LAST_UPDATED="2024-11-26"
12+
1213
# TODO:
13-
# - Change: url default path to use normalization functions
1414
# - Add more notification methods (email, slack, discord, etc.)
1515

1616
# ==============================
@@ -80,8 +80,8 @@ NC='\033[0m' # No Color
8080
# Application Specific Variables
8181
# ==============================
8282

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"
8585

8686
# Initialize URLS as an empty array
8787
URLS=()
@@ -810,7 +810,7 @@ show_help() {
810810

811811
# URL Management
812812
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"
814814
printf " -U, --list-urls List all watched URLs.\n"
815815
printf " -C, --clean Delete all cached files.\n"
816816

@@ -1061,6 +1061,7 @@ process_arguments() {
10611061
CACHE_DIR="$(get_temp_path "$CACHE_DIR")"
10621062
LOG_FILE="$CACHE_DIR/$LOG_FILE"
10631063
PID_FILE="$CACHE_DIR/$PID_FILE"
1064+
URL_FILE="$(get_config_path "$URL_FILE")"
10641065

10651066
# Set default hostname
10661067
SYSTEM_NAME="$(get_hostname)"
@@ -1103,7 +1104,7 @@ process_arguments() {
11031104
process_urls
11041105

11051106
# Check if the array is empty
1106-
if [ ${#URLS[@]} -eq 0 ]; then
1107+
if [ ! $SHOW_STATUS && ! $SHOW_STOP && ${#URLS[@]} -eq 0 ]; then
11071108
log_message "ERROR" "Error: No URLS have been provided."
11081109
exit 1
11091110
fi
@@ -1132,8 +1133,6 @@ process_urls() {
11321133
if [ ${#URLS[@]} -eq 0 ]; then
11331134
if [ -n "$URL_FILE" ]; then
11341135
process_url_file "$URL_FILE"
1135-
elif [ -f "$DEFAULT_URL_FILE" ]; then
1136-
process_url_file "$DEFAULT_URL_FILE"
11371136
elif [[ "$SHOW_CONFIG" = false && "$SHOW_CONFIG_FILE" = false ]]; then
11381137
log_message "INFO" "Usage: $(basename "$0") <website_url>... [options]" "$LINENO"
11391138
log_message "INFO" "Try '$(basename "$0") --help' for more information." "$LINENO"
@@ -1266,6 +1265,7 @@ check_website() {
12661265
local normalized_file="$CACHE_DIR/normalized_content_$encoded_url.txt"
12671266
local hash_file="$CACHE_DIR/hash_$encoded_url.txt"
12681267

1268+
log_message "DEBUG" "" "$LINENO"
12691269
log_message "DEBUG" "$SYSTEM_NAME Checking URL: $clean_url" "$LINENO"
12701270
log_message "DEBUG" "- Submitted URL: $website_url" "$LINENO"
12711271
log_message "DEBUG" "- Global threshold: $THRESHOLD%" "$LINENO"

noirwatch.1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Display this help message.
1616
Display the application version.
1717
.TP
1818
.B \-c, \--config <config_file>
19-
Specify a custom configuration file (default: $HOME/.config/noirwatch.conf).
19+
Specify a custom configuration file (default: ~/.config/noirwatch.conf).
2020
.TP
2121
.B \-I, \--init
2222
Initialize the configuration file.
@@ -64,7 +64,7 @@ Specify a custom log file location (default: /tmp/noirwatch_cache/noirwatch.log)
6464
Set the log level (FATAL, ERROR, WARN, INFO, DEBUG).
6565
.TP
6666
.B \-f, \--url-file <file>
67-
Specify a file containing a list of URLs to monitor (default: $HOME/.config/noirwatch_urls.conf).
67+
Specify a file containing a list of URLs to monitor (default: ~/.config/noirwatch_urls.conf).
6868
.TP
6969
.B \-U, \--list-urls
7070
List all watched URLs.
@@ -107,7 +107,7 @@ Stop the service:
107107
.B noirwatch --stop
108108
.SH FILES
109109
.TP
110-
.B $HOME/.config/noirwatch.conf
110+
.B ~/.config/noirwatch.conf
111111
Default configuration file.
112112
.TP
113113
.B /tmp/noirwatch_cache/

0 commit comments

Comments
 (0)