88
99# Load environment variables from .env file if it exists
1010# in the same directory as this bash script
11-
11+ VERSION= ' 2.1.0 '
1212SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
1313ENV_PATH=" $SCRIPT_DIR /.env"
14+ EVAR=false
1415if [ -f " $ENV_PATH " ]; then
1516 # shellcheck source=.env
1617 echo " Loading environment variables from $ENV_PATH file"
1718 # shellcheck disable=SC1090 # shellcheck sucks
1819 if source " $ENV_PATH " ; then
1920 echo " Environment variables loaded successfully"
21+ EVAR=true
2022 else
2123 echo " Error loading environment variables" >&2
2224 exit 1
@@ -41,8 +43,9 @@ log_message() {
4143 echo " $( date ' +%Y-%m-%d %H:%M:%S' ) [$log_type ] $message " | tee -a " $LOG_FILE "
4244}
4345
44- log_message " INFO" " Script started"
45- log_message " INFO" " Using environment variables:"
46+ log_message " INFO" " xseed.sh script started $VERSION "
47+ log_message " DEBUG" " Using '.env' file for config?: $EVAR "
48+ log_message " INFO" " Gathered Starr environment variables:"
4649log_message " INFO" " TORRENT_CLIENT_NAME=$TORRENT_CLIENT_NAME "
4750log_message " INFO" " USENET_CLIENT_NAME=$USENET_CLIENT_NAME "
4851log_message " INFO" " XSEED_HOST=$XSEED_HOST "
@@ -58,6 +61,11 @@ cross_seed_request() {
5861 headers+=(-H " X-Api-Key: $XSEED_APIKEY " )
5962 fi
6063 response=$( curl --silent --output /dev/null --write-out " %{http_code}" " ${headers[@]} " )
64+
65+ if [ " $response " == " 000" ]; then
66+ log_message " ERROR" " Failed to connect to $XSEED_HOST :$XSEED_PORT . Timeout or connection refused."
67+ fi
68+
6169 echo " $response "
6270}
6371
0 commit comments