aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorMitch Riedstra <mitch@riedstra.us>2019-09-22 06:19:25 -0400
committerMitch Riedstra <mitch@riedstra.us>2019-09-22 06:19:25 -0400
commit7ea49a4869751f93172f276737d094e55121a08d (patch)
treed35af679e4efbccb21217d9401a396ba09c18e57 /README.md
parente9a29c85c023e9a91027122bd361244db575d44b (diff)
downloadhook-7ea49a4869751f93172f276737d094e55121a08d.tar.gz
hook-7ea49a4869751f93172f276737d094e55121a08d.tar.xz
Add a build script, go mod file and update the readmev1.0
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.
+