aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md43
1 files changed, 43 insertions, 0 deletions
diff --git a/README.md b/README.md
index 3f92052..dee575e 100644
--- a/README.md
+++ b/README.md
@@ -3,3 +3,46 @@
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:
+
+```bash
+$ 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:
+
+```bash
+#!/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.
+