Skip to content

Commit eda6442

Browse files
author
Oliver Cervera
authored
Merge pull request #44 from phidauex/master
Add custom Healthchecks.io URL
2 parents 2127bc8 + 57b95d9 commit eda6442

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

script-config.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ FROM_EMAIL_ADDRESS="sender-email-goes-here"
1717
# Use Healthchecks.io to report script errors. Set to 1 to enable.
1818
# Please note that every "WARNING" will be reported as failure.
1919
# When enabled, enter your Healthchecks UUID (not the full URL).
20+
# If using a self-hosted instance, change the URL to your endpoint
21+
# including the trailing slash.
2022
HEALTHCHECKS=0
2123
HEALTHCHECKS_ID="your-uuid-here"
24+
HEALTHCHECKS_URL="https://hc-ping.com/"
2225

2326
# Use Telegram to report script execution summary (not the whole report)
2427
# Set 1 to enable. Create a bot using @botfather, then copy the API token.

snapraid-aio-script.sh

100644100755
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ CONFIG_FILE=$CURRENT_DIR/script-config.sh
2020
#shellcheck source=script-config.sh
2121
source "$CONFIG_FILE"
2222

23+
# set default variables for backward compatibility with older config files
24+
: ${HEALTHCHECKS_URL:="https://hc-ping.com/"}
25+
2326
########################################################################
2427

2528
SYNC_MARKER="SYNC -"
@@ -61,8 +64,8 @@ function main(){
6164
fi
6265
# invoke notification services if configured
6366
if [ "$HEALTHCHECKS" -eq 1 ]; then
64-
echo "Healthchecks.io notification is enabled."
65-
curl -fsS -m 5 --retry 3 -o /dev/null https://hc-ping.com/"$HEALTHCHECKS_ID"/start
67+
echo "Healthchecks.io notification is enabled. Notifications sent to $HEALTHCHECKS_URL."
68+
curl -fsS -m 5 --retry 3 -o /dev/null "$HEALTHCHECKS_URL$HEALTHCHECKS_ID"/start
6669
fi
6770
if [ "$TELEGRAM" -eq 1 ]; then
6871
echo "Telegram notification is enabled."
@@ -805,7 +808,7 @@ SUMMARY: Equal [$EQ_COUNT] - Added [$ADD_COUNT] - Deleted [$DEL_COUNT] - Moved [
805808

806809
function notify_success(){
807810
if [ "$HEALTHCHECKS" -eq 1 ]; then
808-
curl -fsS -m 5 --retry 3 -o /dev/null https://hc-ping.com/"$HEALTHCHECKS_ID"/0 --data-raw "$NOTIFY_OUTPUT"
811+
curl -fsS -m 5 --retry 3 -o /dev/null "$HEALTHCHECKS_URL$HEALTHCHECKS_ID"/0 --data-raw "$NOTIFY_OUTPUT"
809812
fi
810813
if [ "$TELEGRAM" -eq 1 ]; then
811814
curl -fsS -m 5 --retry 3 -o /dev/null -X POST \
@@ -823,7 +826,7 @@ function notify_success(){
823826

824827
function notify_warning(){
825828
if [ "$HEALTHCHECKS" -eq 1 ]; then
826-
curl -fsS -m 5 --retry 3 -o /dev/null https://hc-ping.com/"$HEALTHCHECKS_ID"/fail --data-raw "$NOTIFY_OUTPUT"
829+
curl -fsS -m 5 --retry 3 -o /dev/null "$HEALTHCHECKS_URL$HEALTHCHECKS_ID"/fail --data-raw "$NOTIFY_OUTPUT"
827830
fi
828831
if [ "$TELEGRAM" -eq 1 ]; then
829832
curl -fsS -m 5 --retry 3 -o /dev/null -X POST \

0 commit comments

Comments
 (0)