Skip to content

Commit

Permalink
fixes to log pathing
Browse files Browse the repository at this point in the history
  • Loading branch information
Drazzilb08 committed Feb 18, 2024
1 parent bb9308b commit 11e84c8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 28 deletions.
30 changes: 12 additions & 18 deletions scripts/jduparr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -356,29 +356,23 @@ unraid_notify(){

}

log_file() {
main() {

data_dir=${data_dir%/}
log_dir=${log_dir%/}

# Get LOG_DIR env variable
if [ -z "$log_dir" ]; then
log_dir="${LOG_DIR:-$(dirname "$0")/../logs/jduparr}"
fi

# Check if log directory exists
if [ ! -d "$log_dir" ]; then
echo "Log directory does not exist, creating: $log_dir"
mkdir -p "$log_dir"
script_path=$(dirname "$0")
parent_dir=$(dirname "$script_path")

# If DOCKER_ENV is set
if [ -n "$DOCKER_ENV" ]; then
log_dir="${LOG_DIR:-/logs/jduparr}"
else
# Log directory exists
echo "Log directory exists: $log_dir"
log_dir="${log_dir:-$parent_dir/logs/jduparr}"
fi
}

main() {

data_dir=${data_dir%/}
log_dir=${log_dir%/}
log_file
echo "Log directory: $log_dir"

handle_options "$@"
check_duplicate_script
check_config
Expand Down
20 changes: 10 additions & 10 deletions scripts/nohl_bash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,22 @@ log_file() {
# remove trailing slash from log_dir if it exists
log_dir=${log_dir%/}

if [ -z "$log_dir" ]; then
log_dir="${LOG_DIR:-$(dirname "$0")/../logs/nohl_bash}"
fi

# check if the log_dir directory exists, if not create it
if [ ! -d "$log_dir" ]; then
echo "Log directory does not exist, creating: $log_dir"
mkdir -p "$log_dir"
script_path=$(dirname "$0")
parent_dir=$(dirname "$script_path")

# If DOCKER_ENV is set
if [ -n "$DOCKER_ENV" ]; then
log_dir="${LOG_DIR:-/logs/nohl_bash}"
else
# Log directory exists
echo "Log directory exists: $log_dir"
log_dir="${log_dir:-$parent_dir/logs/nohl_bash}"
fi
# remove trailing slash from source_dir if it exists
source_dir=${source_dir%%/}

log_file=$log_dir/nohl.log

echo "Log directory: $log_dir"
echo "Log file: $log_file"

# check if log file exists, if it does delete it
if [ -f "$log_file" ]; then
Expand Down

0 comments on commit 11e84c8

Please sign in to comment.