Created
July 12, 2023 13:16
-
-
Save jeanlouisferey/ce6ea0b86ed2d31bcf216d553fe00e2d to your computer and use it in GitHub Desktop.
Script shell to send notification to ntfy.sh from a Xigmanas NAS (FreeBSD without curl)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
HOST=ntfy.sh | |
TOPIC=$2 | |
PORT=80 | |
PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin" | |
CONTENT=$1 | |
# Send | |
if [[ "$CONTENT" != "" ]]; then | |
echo "$CONTENT" | |
CONTENT_LEN=$(echo -en ${CONTENT} | wc -c) | |
echo -ne "POST /${TOPIC} HTTP/1.0\r\nHost: $HOST\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: ${CONTENT_LEN}\r\n\r\n${CONTENT}" | nc -w 15 $HOST $PORT | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment