├── README.md ├── UNLICENSE └── pingu /README.md: -------------------------------------------------------------------------------- 1 | # pingu 2 | 3 | pingu sends you a Slack message when your process finishes. 4 | 5 | Works on any POSIX system with `curl`. 6 | 7 | ## Installation 8 | 9 | ```shell 10 | curl -LO https://raw.githubusercontent.com/hoffa/pingu/master/pingu 11 | chmod +x pingu 12 | ``` 13 | 14 | ## Usage 15 | 16 | ```shell 17 | pingu 18 | ``` 19 | 20 | `SLACK_WEBHOOK_URL` must be set. 21 | 22 | See the [Slack docs](https://api.slack.com/incoming-webhooks) on how to create a webhook URL. 23 | -------------------------------------------------------------------------------- /UNLICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /pingu: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | trap : INT TERM QUIT 4 | 5 | eval "$@" 6 | cmd_status=$? 7 | 8 | # Escape double quotes 9 | escape_quotes() { 10 | sed 's/"/\\"/g' 11 | } 12 | 13 | # Send POST request with JSON body 14 | # $1: URL 15 | # stdin: JSON data 16 | curl_post_json() { 17 | curl \ 18 | -sSL \ 19 | --header "Content-Type: application/json" \ 20 | --data @- \ 21 | "$1" >/dev/null 22 | } 23 | 24 | # Send message to Slack 25 | # $1: text 26 | # $2: fallback 27 | # $3: footer 28 | # $4: color 29 | send_slack_message() { 30 | if [ -n "${SLACK_WEBHOOK_URL}" ]; then 31 | curl_post_json "${SLACK_WEBHOOK_URL}" <