Browse Source

wip

pull/5/head
Valentin Lab 10 months ago
committed by Boris Gallet
parent
commit
62a832330c
  1. 39
      bin/send

39
bin/send

@ -0,0 +1,39 @@
#!/bin/bash
## Send a notification with NTFY and check if the config file is complete
if [[ "$UID" == "0" ]]; then
NTFY_CONFIG_FILE="/etc/ntfy/ntfy.conf"
else
NTFY_CONFIG_FILE="$HOME/.config/ntfy/ntfy.conf"
fi
if ! [ -e "$NTFY_CONFIG_FILE" ]; then
mkdir -p "${NTFY_CONFIG_FILE%/*}"
## default option to change if needed
echo 'SERVER="https://ntfy.0k.io/"' > "$NTFY_CONFIG_FILE"
else
source "$NTFY_CONFIG_FILE"
for var in TOKEN SERVER; do
if ! [ -v "$var" ]; then
echo "Error: missing $var in $NTFY_CONFIG_FILE"
exit 1
fi
done
fi
exname=${0##*/}
usage="Usage: $exname CHANNEL MESSAGE"
if [ "$#" -ne 2 ]; then
echo "$usage" >&2
exit 1
fi
channel="$1"
message="$2"
curl -s -H "Authorization: Bearer $TOKEN" \
-d "$message" "$SERVER/$channel" > /dev/null
Loading…
Cancel
Save