File kopano.patch of Package mattermost-server
diff -Naur mattermost-orig/mattermost.apache2 mattermost/mattermost.apache2
--- mattermost-orig/mattermost.apache2 1970-01-01 01:00:00.000000000 +0100
+++ mattermost/mattermost.apache2 2017-12-08 12:29:41.312313609 +0100
@@ -0,0 +1,62 @@
+<VirtualHost *:80>
+ ServerName mattermost.example.org
+ ServerAdmin webmaster@example.org
+
+ ErrorLog ${APACHE_LOG_DIR}/mattermost-error.log
+ CustomLog ${APACHE_LOG_DIR}/mattermost-access.log combined
+
+ # Enforce HTTPS:
+ RewriteEngine On
+ RewriteCond %{HTTPS} !=on
+ RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
+</VirtualHost>
+
+<VirtualHost *:443>
+ SSLEngine on
+ ServerName mattermost.example.org
+ ServerAdmin webmaster@example.org
+
+ SSLCertificateFile
+ SSLCertificateKeyFile
+ SSLCACertificateFile
+
+ ErrorLog ${APACHE_LOG_DIR}/mattermost-error.log
+ CustomLog ${APACHE_LOG_DIR}/mattermost-access.log combined
+
+ RewriteEngine On
+ RewriteCond %{REQUEST_URI} ^/api/v1/websocket [NC,OR]
+ RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC,OR]
+ RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
+ RewriteRule .* ws://127.0.0.1:8065%{REQUEST_URI} [P,QSA,L]
+ RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
+ RewriteRule .* http://127.0.0.1:8065%{REQUEST_URI} [P,QSA,L]
+ RequestHeader set X-Forwarded-Proto "https"
+
+ RequestHeader unset If-Modified-Since
+ RequestHeader unset If-None-Match
+
+ # Optional headers if Mattermost should be accesible from within Kopano WebApp
+ #Header set X-Frame-Options "ALLOW-FROM https://your.kopano.webapp.host.local"
+ #Header edit Content-Security-Policy ^(.*)$ "$1;frame-ancestors 'self' https://your.kopano.webapp.host.local"
+
+ <LocationMatch "/api/(?<version>v[0-9]+)/(?<users>users/)?websocket$">
+ Require all granted
+ ProxyPassReverse ws://127.0.0.1:8065/api/%{env:MATCH_VERSION}/%{env:MATCH_USERS}websocket
+ ProxyPassReverseCookieDomain 127.0.0.1 mattermost.example.org
+ # Optional headers if Mattermost should be accesible from within Kopano WebApp
+ #Header unset X-Frame-Options
+ #Header unset Content-Security-Policy
+ </LocationMatch>
+ <Location />
+ Require all granted
+ ProxyPassReverse http://127.0.0.1:8065/
+ ProxyPassReverseCookieDomain 127.0.0.1 mattermost.example.org
+ # Optional headers if Mattermost should be accesible from within Kopano WebApp
+ #Header unset X-Frame-Options
+ #Header unset Content-Security-Policy
+ </Location>
+
+ ProxyPreserveHost On
+ ProxyRequests Off
+</VirtualHost>
+
diff -Naur mattermost-orig/mattermost-db-configure mattermost/mattermost-db-configure
--- mattermost-orig/mattermost-db-configure 1970-01-01 01:00:00.000000000 +0100
+++ mattermost/mattermost-db-configure 2018-03-30 10:00:00.000000000 +0100
@@ -0,0 +1,49 @@
+#!/bin/bash
+
+while getopts u:p:d:n:o: option; do
+ case "${option}"
+ in
+ u) USER=${OPTARG};;
+ p) PASSWORD=${OPTARG};;
+ d) DATABASE=${OPTARG};;
+ n) ACCOUNTUSER=${OPTARG};;
+ o) ACCOUNTPASS=${OPTARG};;
+ esac
+done
+
+if [ -z "${USER}" ] || [ -z "${DATABASE}" ] || [ -z "${ACCOUNTUSER}" ] || [ -z "${ACCOUNTPASS}" ]; then
+ echo "usage: $0 -u <mysql-user> -p <mysql-password> -d <mattermost-database> -n <mattermost-dbuser> -o <mattermost-dbpass>"
+ exit 1
+fi
+
+function do_query {
+ if [ -z "${PASSWORD}" ]; then
+ echo "$@" | mysql -u"${USER}"
+ else
+ echo "$@" | mysql -u"${USER}" -p"${PASSWORD}"
+ fi
+ local status=$?
+ if [ $status -ne 0 ]; then
+ echo "Error with executing $1" >&2
+ fi
+ return $status
+}
+
+do_query "CREATE DATABASE IF NOT EXISTS ${DATABASE};"
+do_query "CREATE USER '${ACCOUNTUSER}'@'127.0.0.1' IDENTIFIED BY '${ACCOUNTPASS}';"
+do_query "GRANT ALL PRIVILEGES ON ${DATABASE}.* TO '${ACCOUNTUSER}'@'127.0.0.1';"
+
+if [ $? -ne 0 ]; then
+ echo -e "Something went wrong with creating the Mattermost database credentials, please check above output.\nMost possible causes are incorrect logon credentials."
+else
+ echo -e "Creation of DB and DB User successful."
+fi
+
+sed -i -s "s#^ *\"DataSource\":.*# \"DataSource\": \"${ACCOUNTUSER}:${ACCOUNTPASS}@tcp\(127.0.0.1:3306\)\/${DATABASE}?charset=utf8mb4,utf8\&readTimeout=30s\&writeTimeout=30s\",#g" /etc/mattermost/config.json
+
+
+if [ $? -ne 0 ]; then
+ echo "Something went wrong with adapting the Mattermost configuration."
+else
+ echo "Mattermost configuration has been adapted successfully. Please restart mattermost to use the new settings."
+fi
diff -Naur mattermost-orig/mattermost.logrotate mattermost/mattermost.logrotate
--- mattermost-orig/mattermost.logrotate 1970-01-01 01:00:00.000000000 +0100
+++ mattermost/mattermost.logrotate 2017-12-08 12:27:44.396037948 +0100
@@ -0,0 +1 @@
+# Log rotation is handled internally by Mattermost, see https://docs.mattermost.com/administration/config-settings.html#output-logs-to-file
diff -Naur mattermost-orig/mattermost.nginx mattermost/mattermost.nginx
--- mattermost-orig/mattermost.nginx 1970-01-01 01:00:00.000000000 +0100
+++ mattermost/mattermost.nginx 2017-12-08 12:27:44.396037948 +0100
@@ -0,0 +1,50 @@
+upstream backend {
+ server 127.0.0.1:8065;
+}
+
+proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=mattermost_cache:10m max_size=3g inactive=120m use_temp_path=off;
+
+server {
+ listen 80;
+ server_name mattermost.example.com;
+
+ location ~ /api/v[0-9]+/(users/)?websocket$ {
+ proxy_set_header Upgrade $http_upgrade;
+ proxy_set_header Connection "upgrade";
+ client_max_body_size 50M;
+ proxy_set_header Host $http_host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header X-Forwarded-Proto $scheme;
+ proxy_set_header X-Frame-Options SAMEORIGIN;
+ proxy_buffers 256 16k;
+ proxy_buffer_size 16k;
+ proxy_read_timeout 600s;
+ proxy_pass http://backend;
+ }
+
+ location / {
+ client_max_body_size 50M;
+ proxy_set_header Connection "";
+ proxy_set_header Host $http_host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header X-Forwarded-Proto $scheme;
+ proxy_set_header X-Frame-Options SAMEORIGIN;
+ proxy_buffers 256 16k;
+ proxy_buffer_size 16k;
+ proxy_read_timeout 600s;
+ proxy_cache mattermost_cache;
+ proxy_cache_revalidate on;
+ proxy_cache_min_uses 2;
+ proxy_cache_use_stale timeout;
+ proxy_cache_lock on;
+ proxy_pass http://backend;
+
+ # Optional headers if Mattermost should be accesible from within Kopano WebApp
+ #add_header X-Frame-Options "ALLOW-FROM 'https://your.kopano.webapp.host.local'";
+ #add_header Content-Security-Policy "frame-ancestors 'self' https://your.kopano.webapp.host.local";
+ #proxy_hide_header X-Frame-Options;
+ #proxy_hide_header Content-Security-Policy;
+ }
+}
diff -Naur mattermost-orig/mattermost-platform mattermost/mattermost-platform
--- mattermost-orig/mattermost-platform 1970-01-01 01:00:00.000000000 +0100
+++ mattermost/mattermost-platform 2017-12-08 12:27:44.396037948 +0100
@@ -0,0 +1,9 @@
+#!/bin/bash
+# helper script to comfortly call the platform binary from path
+cd /opt/mattermost
+if [ $# == 0 ]; then
+ echo "You need to pass at least one parameter. Try $0 help instead."
+ exit 1
+else
+ /opt/mattermost/bin/mattermost --config=/etc/mattermost/config.json "$@"
+fi
diff -Naur mattermost-orig/mattermost.service mattermost/mattermost.service
--- mattermost-orig/mattermost.service 1970-01-01 01:00:00.000000000 +0100
+++ mattermost/mattermost.service 2017-12-08 12:27:44.396037948 +0100
@@ -0,0 +1,18 @@
+[Unit]
+Description=Mattermost
+After=network.target
+After=mysql.service
+
+[Service]
+Type=simple
+ExecStart=/opt/mattermost/bin/mattermost --config=/etc/mattermost/config.json
+Restart=always
+RestartSec=10
+WorkingDirectory=/opt/mattermost
+User=mattermost
+Group=mattermost
+LimitNOFILE=49152
+ProtectHome=true
+ProtectSystem=true
+PrivateTmp=true
+SyslogIdentifier=mattermost