hook A command line webhook utility.
It's not likely of much use on its own. The real power comes when you tie it together with your shell scripts to run a command, or send the output of something to your chat server if things go wrong.
With an example configuration file:
backups:
url: https://discordapp.com/api/webhooks/fill/me/in
schema:
username: 'backups@{{.Vars.Hostname}}'
content: '{{.Vars.Message}} ```{{.Stdin}}```'
Placed in $HOME/.hook.yml
We can then call say our backup script:
$ bin/backup.sh | hook -n backups -V Hostname "$(hostname)" -v Message "Backup output"
Which will yield a webhook being sent out with the output from your
bin/backup.sh script
A slightly more complex example might be to use it in a shell script:
#!/bin/sh
output="$(mktemp)"
restic backup /var/www 2>&1 > "$output"
if [ $? -ne 0 ] ; then
hook -n backups \
-v Hostname "$(hostname)" \
-v Message "Backup failure! :bomb:" \
< "$output"
fi
rm "$output"
The above example would only send out a webhook if the backup had a failure
by using $? to check the status code.
