Skip to content

Commit

Permalink
fix(load-env): correct working directory when loading env file
Browse files Browse the repository at this point in the history
  • Loading branch information
zakkarry authored and bakerboy448 committed Jul 22, 2024
1 parent 556012d commit 7c48ce4
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions xseed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,22 @@
### ON IMPORT COMPLETE EVENT TYPE IN YOUR SONARR SETTINGS

# Load environment variables from .env file if it exists
if [ -f ".env" ]; then
# in the same directory as this bash script

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ENV_PATH="$SCRIPT_DIR/.env"
if [ -f "$ENV_PATH" ]; then
# shellcheck source=.env
echo "Loading environment variables from .env file"
source ".env"
echo "Loading environment variables from $ENV_PATH file"
source "$ENV_PATH"
if [ $? -eq 0 ]; then
echo "Environment variables loaded successfully"
else
echo "Error loading environment variables" >&2
exit 1
fi
else
echo ".env file not found"
echo ".env file not found in script directory ($ENV_PATH)"
fi

# Use environment variables with descriptive default values
Expand Down Expand Up @@ -86,7 +90,7 @@ detect_application() {
folderPath="$sonarr_episodefile_sourcefolder"
}
# shellcheck disable=SC2154 # These are set by Starr on call
filePath="$sonarr_episodefile_paths"
filePath="$sonarr_episodefile_path"
fi
# shellcheck disable=SC2154 # These are set by Starr on call
eventType="$sonarr_eventtype"
Expand Down

0 comments on commit 7c48ce4

Please sign in to comment.