Skip to content

Commit

Permalink
Merge pull request #7 from openbridge/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
tspicer authored Jan 17, 2017
2 parents 804e760 + 51971ba commit ec26d06
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM alpine:latest
RUN apk add --update \
bash \
curl \
&& rm /var/cache/apk/*
COPY slack.sh /slack.sh
RUN chmod +x /slack.sh \
&& touch /tmp/ip.txt \
&& mkdir -p /tmp
27 changes: 16 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,6 @@ Hacky Slack requires cURL (https://curl.haxx.se). Most systems have it installed

Installation is pretty simple. Just copy the <code>slack.sh</code> to <code>/usr/local/bin</code>. Then <code>chmod +x /usr/local/bin/slack.sh</code>.

Please note that the default config (slack.sh) assumes you are installing slack into <code>/usr/local/bin</code>:

```
APP="/usr/local/bin/slack.sh"
BIN="/usr/bin/slack"
```

BIN is used to <code>ln</code> to APP to BIN. This will allow you to use <code>slack</code> vs <code>/usr/local/bin/slack.sh</code>

If you decide to copy Hacky Slack to a different APP directory change the settings accordingly.

# Using Hacky Slack
Expand Down Expand Up @@ -90,13 +81,17 @@ For more information on the above parameters, please check out the Slack docs:
The channel is "general" with username "hacky-slack". The icon is "apple" and the author is "apple". The author name is linked to "apple.com" and the text sent in the message is "Where are the new 2016 Macbook models?"

```
slack -c "#general" -u "hacky-slack" -i "apple" -a "Macbook" -b "http://www.apple.com/ -t "Where are the new 2016 Macbook models?"
sh slack.sh -c "#general" -u "hacky-slack" -i "apple" -a "Macbook" -b "http://www.apple.com/ -t "Where are the new 2016 Macbook models?"
```

Here is a sample message and a screenshot of the message with various flags set.

```
slack -a -t "Hello World" -i ":slack:" -T "Titles are awesome" -p "Pretext is so helpful to include" -s "info"
sh slack.sh -a -t "Hello World" -i ":slack:" -T "Titles are awesome" -p "Pretext is so helpful to include" -s "info"
```

```
sh slack.sh -c "#general" -u "steve" -i "dog" -a "Macbook Pro" -B "http://www.apple.com/" -p "Almost" -Z "Where are the new 2016 Macbook models" -s "ok" -T "Wow" -L "https://www.apple.com" -k "213912391-2093-10293ASSJASLKA"
```

Here is the command represented in Slack:
Expand All @@ -106,6 +101,16 @@ Here is the command represented in Slack:

Note: These examples assume you have set your token and webhook endpoint.

# Hack Slack Docker style

There is a `Dockerfile` included which may simplify running the Hacky Slack. This assumes you have Docker installed. Simply build your image by running `docker build -t slack .`

Here is an example of running with Docker:
```
docker run -it slack /bin/bash /slack.sh -c "#general" -u "steve" -i "dog" -a "Macbook Pro" -B "http://www.apple.com/" -p "Almost" -Z "Where are the new 2016 Macbook models" -s "ok" -T "Wow" -L "https://www.apple.com" -k "213912391-2093-10293ASSJASLKA"
```

This is approach consumes a lot more space that the file alone. The total image is < 10MB. However, it might provide more flexibility in some use cases. Your mileage may vary.

# Hacky Slack + Monit

Expand Down
9 changes: 5 additions & 4 deletions etc/slack.d/monit
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
PRETEXT="${MONIT_DATE} | ${MONIT_HOST}: ${MONIT_EVENT}"
FALLBACK="${MONIT_DATE} | ${MONIT_HOST}: ${MONIT_EVENT}"

if test "${PRIORITY}" = "OK"; then echo "INFO: STATUS (-s) is OK. Setting a default STATUS to OK..." && ICON=${ICON:-':monit-ok:'} && COLOR=${COLOR:-'#36a64f'}; fi
if test "${PRIORITY}" = "INFO"; then echo "INFO: STATUS (-s) is INFO. Setting a default STATUS to INFO..." && ICON=${ICON:-':monit-info:'} && COLOR=${COLOR:-'#439FE0'}; fi
if test "${PRIORITY}" = "WARN"; then echo "INFO: STATUS (-s) is WARN. Setting a default STATUS to WARN..." && ICON=${ICON:-':monit-warn:'} && COLOR=${COLOR:-'#ed7d21'}; fi
if test "${PRIORITY}" = "ERROR"; then echo "INFO: STATUS (-s) is ERROR. Setting a default STATUS to ERROR..." && ICON=${ICON:-':monit-error:'} && COLOR=${COLOR:-'#E21B6C'}; fi
if test "${PRIORITY}" = "OK"; then echo "INFO: STATUS (-s) is OK. Setting a default STATUS to OK..." && ICON=${ICON:-'monit-ok'} && COLOR=${COLOR:-'#36a64f'}; fi
if test "${PRIORITY}" = "INFO"; then echo "INFO: STATUS (-s) is INFO. Setting a default STATUS to INFO..." && ICON=${ICON:-'monit-info'} && COLOR=${COLOR:-'#439FE0'}; fi
if test "${PRIORITY}" = "WARN"; then echo "INFO: STATUS (-s) is WARN. Setting a default STATUS to WARN..." && ICON=${ICON:-'monit-warn'} && COLOR=${COLOR:-'#ed7d21'}; fi
if test "${PRIORITY}" = "ERROR"; then echo "INFO: STATUS (-s) is ERROR. Setting a default STATUS to ERROR..." && ICON=${ICON:-'monit-error'} && COLOR=${COLOR:-'#E21B6C'}; fi


# Save for later
# if grep -Fq 'Action done' ${MONIT_DESCRIPTION}; then ICON=${ICON-':cpu:'}; fi
Expand Down
Empty file modified slack.sh
100644 → 100755
Empty file.

0 comments on commit ec26d06

Please sign in to comment.