#!/usr/bin/env bash # Usage: # # Copy text to file ./test-channel-name-ios.sh # run # chmod a+x test-channel-name-ios.sh # # Start script with channel name and token # # ./test-channel-name-ios.sh "channel: deploy" "https://hooks.slack.com/services/TOKEN" # example: # ./test-channel-name-ios.sh "uptime-log" "https://hooks.slack.com/services/TOKEN" channel="${1}" hook="${2}" color="good" read -d '' shortTruePayload1Team << EOF { "channel": "#${channel}", "link_names": true, "attachments": [ { "color": "#36a64f", "title": "36 unresolved incidents notified", "footer": "test-channel-name-ios", "fields": [ { "value": "Academy team: 1", "short": true }, { "value": "#academy-team-alerts", "short": true } ] } ] } EOF read -d '' shortFalsePayload1Team << EOF { "channel": "#${channel}", "link_names": true, "attachments": [ { "color": "#36a64f", "title": "36 unresolved incidents notified", "footer": "test-channel-name-ios", "fields": [ { "value": "Academy team: 1", "short": false }, { "value": "#academy-team-alerts", "short": false } ] } ] } EOF read -d '' shortTruePayload4Teams << EOF { "channel": "#${channel}", "link_names": true, "attachments": [ { "color": "#36a64f", "title": "36 unresolved incidents notified", "footer": "test-channel-name-ios", "fields": [ { "value": "Red team: 1", "short": true }, { "value": "#red-team-alerts", "short": true }, { "value": "Blue team: 1", "short": true }, { "value": "#blue-team-alerts", "short": true }, { "value": "Academy team: 1", "short": true }, { "value": "#academy-team-alerts", "short": true } ] } ] } EOF curl \ --silent \ --output /dev/null \ -X POST \ -H 'Content-type: application/json' \ --data "${shortTruePayload1Team}" ${hook} curl \ --silent \ --output /dev/null \ -X POST \ -H 'Content-type: application/json' \ --data "${shortFalsePayload1Team}" ${hook} curl \ --silent \ -X POST \ -H 'Content-type: application/json' \ --data "${shortTruePayload4Teams}" ${hook}