Browse Source

improve packaging

master
parent
commit
edf5c4cb00
  1. 28
      mattermost/mattermost-post.sh
  2. 7
      mattermost/mattermost.sh
  3. 15
      mattermost/mattermost.spec

28
mattermost/mattermost-post.sh

@ -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

7
mattermost/mattermost.sh

@ -0,0 +1,7 @@
#!/bin/sh
# pass-through execution
exec @l_prefix@/libexec/mattermost/mattermost \
-c @l_prefix@/etc/mattermost/mattermost.json \
${1+"$@"}

15
mattermost/mattermost.spec

@ -38,7 +38,9 @@ Release: 20190209
Source0: https://github.com/mattermost/mattermost-server/archive/v%{version}.tar.gz
Source1: https://releases.mattermost.com/%{version}/mattermost-%{version}-linux-amd64.tar.gz
Source2: rc.mattermost
Source3: mattermost-setup.sh
Source3: mattermost.sh
Source4: mattermost-setup.sh
Source5: mattermost-post.sh
Patch0: mattermost.patch
# build information
@ -93,14 +95,11 @@ PreReq: OpenPKG, openpkg >= 20140101, postgresql
mattermost-server-%{version}/mattermost \
$RPM_BUILD_ROOT%{l_prefix}/libexec/mattermost/mattermost
# install wrapper script
( echo "#!/bin/sh"
echo "exec %{l_prefix}/libexec/mattermost/mattermost \\%{_nil}"
echo " -c %{l_prefix}/etc/mattermost/mattermost.json \\%{l_nil}"
echo " \${1+\"\$@\"}"
) >mattermost.sh
# install wrapper scripts
%{l_shtool} install -c -m 755 %{l_value -s -a} \
mattermost.sh $RPM_BUILD_ROOT%{l_prefix}/sbin/mattermost
%{SOURCE mattermost.sh} $RPM_BUILD_ROOT%{l_prefix}/sbin/mattermost
%{l_shtool} install -c -m 755 %{l_value -s -a} \
%{SOURCE mattermost-post.sh} $RPM_BUILD_ROOT%{l_prefix}/sbin/mattermost-post
# install configuration
%{l_shtool} install -c -m 644 %{l_value -s -a} \

Loading…
Cancel
Save