From 7ea49a4869751f93172f276737d094e55121a08d Mon Sep 17 00:00:00 2001 From: Mitch Riedstra Date: Sun, 22 Sep 2019 06:19:25 -0400 Subject: Add a build script, go mod file and update the readme --- README.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'README.md') 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. + -- cgit v1.2.3