3 changed files with 42 additions and 8 deletions
@ -0,0 +1,28 @@
|
||||
#!/bin/sh |
||||
|
||||
# check usage |
||||
if [ $# -ne 3 ]; then |
||||
echo "mattermost-post: ERROR: invalid number of arguments" 1>&2 |
||||
echo "mattermost-post: USAGE: $0 <access-token> <channel-id> <message>" 1>&2 |
||||
exit 1 |
||||
fi |
||||
|
||||
# take over arguments |
||||
token="$1" |
||||
channel="$2" |
||||
message="$3" |
||||
|
||||
# determine REST endpoint URL |
||||
endpoint=`grep SiteURL @l_prefix@/etc/mattermost/mattermost.json | \ |
||||
sed -e 's;,*"SiteURL"[^"]*"\([^"]*\)".*;;'` |
||||
endpoint="$endpoint/api/v4/posts" |
||||
|
||||
# post message |
||||
@l_prefix@/bin/curl \ |
||||
-i \ |
||||
-X POST \ |
||||
-H "Content-Type: application/json" \ |
||||
-H "Authorization: Bearer $token" \ |
||||
-d "{ \"channel_id\": \"$channel\", \"message\": \"$message\" }" \ |
||||
$endpoint |
||||
|
@ -0,0 +1,7 @@
|
||||
#!/bin/sh |
||||
|
||||
# pass-through execution |
||||
exec @l_prefix@/libexec/mattermost/mattermost \ |
||||
-c @l_prefix@/etc/mattermost/mattermost.json \ |
||||
${1+"$@"} |
||||
|
Loading…
Reference in new issue