Skip to content

Instantly share code, notes, and snippets.

@jeanlouisferey
Created July 12, 2023 13:16
Show Gist options
  • Save jeanlouisferey/ce6ea0b86ed2d31bcf216d553fe00e2d to your computer and use it in GitHub Desktop.
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)
#!/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