Skip to content

Instantly share code, notes, and snippets.

@ihoro
Created August 28, 2024 09:15
Show Gist options
  • Select an option

  • Save ihoro/024391c4408052ccd4570fd597a8d140 to your computer and use it in GitHub Desktop.

Select an option

Save ihoro/024391c4408052ccd4570fd597a8d140 to your computer and use it in GitHub Desktop.
muninn -- run a command and report via Slack webhook when it's complete
#!/bin/sh
#
# Usage examples:
# $ make -j8 buildworld; muninn
# $ muninn make -j8 buildworld # TODO: double quotes are not supported yet in the string after muninn
#
T_START=$(date "+%s")
$*
T_END=$(date "+%s")
T_DIFF_MIN=$(( ($T_END-$T_START)/60 ))
msg="$*"
test -n "$msg" || msg="DONE."
curl -s -X POST --data-urlencode "payload={\"text\": \"${T_DIFF_MIN}min $(hostname): $msg\"}" "$(cat ~/.slack.incomingwebhook)"
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment