Skip to content

Commit c657404

Browse files
authored
Introduce Apprise support
Use Apprise for external notifications. - Gets installed if configured - Notifies start and finish - If the script has a warning, it will attach the output
1 parent 14ee372 commit c657404

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

snapraid-aio-script.sh

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
######################
99
# SCRIPT VARIABLES #
1010
######################
11-
SNAPSCRIPTVERSION="3.4" #DEV3
11+
SNAPSCRIPTVERSION="3.4" #DEV5
1212

1313
# Read SnapRAID version
1414
SNAPRAIDVERSION="$(snapraid -V | sed -e 's/snapraid v\(.*\)by.*/\1/')"
@@ -95,6 +95,11 @@ function main(){
9595
-d '{"content": "SnapRAID Script Job started"}' \
9696
"$DISCORD_WEBHOOK_URL"
9797
fi
98+
if [ "$APPRISE" -eq 1 ]; then
99+
echo "Apprise service notification is enabled."
100+
check_and_install apprise
101+
"$APPRISE_BIN" -b "SnapRAID Script Job started" "$APPRISE_URL"
102+
fi
98103
fi
99104

100105
### Check if SnapRAID is found
@@ -888,6 +893,11 @@ function notify_success(){
888893
-d '{"content": "'"$DISCORD_SUBJECT"'"}' \
889894
"$DISCORD_WEBHOOK_URL"
890895
fi
896+
897+
if [ "$APPRISE" -eq 1 ]; then
898+
echo "Sending notification using Apprise service(s)."
899+
"$APPRISE_BIN" -t "SnapRAID on $(hostname)" -b "$NOTIFY_OUTPUT" "$APPRISE_URL"
900+
fi
891901
mklog "INFO: "$SUBJECT""
892902
}
893903

@@ -908,6 +918,16 @@ function notify_warning(){
908918
-d '{"content": "'"$DISCORD_SUBJECT"'"}' \
909919
"$DISCORD_WEBHOOK_URL"
910920
fi
921+
922+
if [ "$APPRISE" -eq 1 ]; then
923+
echo "Sending notification using Apprise service(s)."
924+
if [ "$APPRISE_ATTACH" -eq 1 ]; then
925+
"$APPRISE_BIN" -t "SnapRAID on $(hostname)" -b "$NOTIFY_OUTPUT" -a "$TMP_OUTPUT" "$APPRISE_URL"
926+
else
927+
"$APPRISE_BIN" -t "SnapRAID on $(hostname)" -b "$NOTIFY_OUTPUT" "$APPRISE_URL"
928+
fi
929+
fi
930+
911931
if [ "$EMAIL_ADDRESS" ]; then
912932
trim_log < "$TMP_OUTPUT" | send_mail
913933
fi

0 commit comments

Comments
 (0)