From 3a359f92184f23a544152d48af3d950ac2f6c3c6 Mon Sep 17 00:00:00 2001 From: lindy65 Date: Tue, 5 Dec 2017 14:09:21 +0200 Subject: [PATCH 01/33] Propose updating to Mattermost 4.4.3 Hi @kemenaran, Mattermost v4.4.3 release is officially out. You can find download links with hash numbers [here](https://pre-release.mattermost.com/core/pl/5kc3brcq3irbdf3pmi1enffb7h). Changelog in progress with notes on patch releases is available [here](https://github.com/mattermost/docs/pull/1668). If you do update, please consider tweeting about it, which we can then re-tweet for greater reach. Thanks! --- conf/app.src | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/app.src b/conf/app.src index 6606b69..b04b2e7 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,6 +1,6 @@ -SOURCE_URL=https://releases.mattermost.com/4.4.2/mattermost-4.4.2-linux-amd64.tar.gz -SOURCE_SUM=ba1648e5806239ce9071f5730eb712a6d0d9077fd9ecad37e85baeb08c1fa170 +SOURCE_URL=https://releases.mattermost.com/4.4.3/mattermost-4.4.3-linux-amd64.tar.gz +SOURCE_SUM=589c53252d33f32539d98b0a5fbe9af29fbd80e46ea79e1d156b81b743151ce2 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=mattermost-4.4.2-linux-amd64.tar.gz +SOURCE_FILENAME=mattermost-4.4.3-linux-amd64.tar.gz From 0d4482c6e0263c7b9f555de643d131b2fa68faf2 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Thu, 7 Dec 2017 12:13:33 +0530 Subject: [PATCH 02/33] nginx.conf: document HTTPS redirection --- conf/nginx.conf | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index c11d89b..47f726b 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -17,11 +17,6 @@ location ~ /api/v[0-9]+/(users/)?websocket$ { location / { client_max_body_size 50M; - - if ($scheme = http) { - rewrite ^ https://$server_name$request_uri? permanent; - } - proxy_set_header Connection ""; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; @@ -39,4 +34,8 @@ location / { #proxy_cache_use_stale timeout; #proxy_cache_lock on; proxy_pass http://127.0.0.1:8065; + # Yunohost addition: redirect HTTP to HTTPS + if ($scheme = http) { + rewrite ^ https://$server_name$request_uri? permanent; + } } From 917c7adb8055f4af535ab7936dce29451893d01a Mon Sep 17 00:00:00 2001 From: lindy65 Date: Tue, 12 Dec 2017 18:30:20 +0200 Subject: [PATCH 03/33] Propose updating to Mattermost 4.4.5 Hi @kemenaran, Mattermost v4.4.5 release is officially out. The release contains a medium severity security fix. Upgrading is highly recommended although you might wish to wait and upgrade when v4.5 is released on Friday, 15 December. You can find download links with hash numbers [here](https://pre-release.mattermost.com/core/pl/buhd5ew387b1mm6bq4p8htm4wa). Changelog with notes on patch releases is available [here](https://docs.mattermost.com/administration/changelog.html?highlight=changelog#release-v4-4-5). --- conf/app.src | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/app.src b/conf/app.src index b04b2e7..76d5602 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,6 +1,6 @@ -SOURCE_URL=https://releases.mattermost.com/4.4.3/mattermost-4.4.3-linux-amd64.tar.gz -SOURCE_SUM=589c53252d33f32539d98b0a5fbe9af29fbd80e46ea79e1d156b81b743151ce2 +SOURCE_URL=https://releases.mattermost.com/4.4.5/mattermost-4.4.5-linux-amd64.tar.gz +SOURCE_SUM=54c268cb1ace376981ffc6845b18185c287783fad4dfb90969cd6bc459e306ae SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=mattermost-4.4.3-linux-amd64.tar.gz +SOURCE_FILENAME=mattermost-4.4.5-linux-amd64.tar.gz From d7f6f8874eb694e0e0ec8f72ab368cecaed5c142 Mon Sep 17 00:00:00 2001 From: lindy65 Date: Mon, 18 Dec 2017 09:13:27 +0200 Subject: [PATCH 04/33] Update app.src Hey @kemenaran, Mattermost v4.5 release is officially out! You can find download links with hash numbers [here](https://pre-release.mattermost.com/core/pl/9buqjpu6eidyxbd75xbjdn19zc). Changelog with notes on patch releases is available [here](https://docs.mattermost.com/administration/changelog.html?highlight=changelog#release-v4-5). Wondering if you'd like to help update Mattermost Yunohost to be compatible with Mattermost 4.5? If you do update, please consider tweeting about it, which we can then re-tweet for greater reach. Thanks! --- conf/app.src | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/app.src b/conf/app.src index 76d5602..c8337b7 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,6 +1,6 @@ -SOURCE_URL=https://releases.mattermost.com/4.4.5/mattermost-4.4.5-linux-amd64.tar.gz -SOURCE_SUM=54c268cb1ace376981ffc6845b18185c287783fad4dfb90969cd6bc459e306ae +SOURCE_URL=https://releases.mattermost.com/4.5.0/mattermost-4.5.0-linux-amd64.tar.gz +SOURCE_SUM=a3af246f160aaf06ce9706a566222a4470c9ec364ce1861492f35dc0a03f1360 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=mattermost-4.4.5-linux-amd64.tar.gz +SOURCE_FILENAME=mattermost-4.5-linux-amd64.tar.gz From 4fb09fa8bc8498cbc798731e5ac75abfbf5c2ba0 Mon Sep 17 00:00:00 2001 From: lindy65 Date: Wed, 17 Jan 2018 20:18:10 +0200 Subject: [PATCH 05/33] Propose updating to Mattermost v4.6 Hi @kemenaran, Here's a quick pull request to update to Mattermost v4.6 Thanks for continuing to maintain Yunohost :) --- conf/app.src | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/app.src b/conf/app.src index c8337b7..f7c25ba 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,6 +1,6 @@ -SOURCE_URL=https://releases.mattermost.com/4.5.0/mattermost-4.5.0-linux-amd64.tar.gz -SOURCE_SUM=a3af246f160aaf06ce9706a566222a4470c9ec364ce1861492f35dc0a03f1360 +SOURCE_URL=https://releases.mattermost.com/4.6.0/mattermost-4.6.0-linux-amd64.tar.gz +SOURCE_SUM=1865fbee3cd00659e56b178f766aff6eac6be2f4062b08a09fd66e801e687be1 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=mattermost-4.5-linux-amd64.tar.gz +SOURCE_FILENAME=mattermost-4.6-linux-amd64.tar.gz From c984358fddf09370939ac6b473116e437c57d22f Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Tue, 23 Jan 2018 18:47:34 +0530 Subject: [PATCH 06/33] Manifest: add app version --- manifest.json | 1 + 1 file changed, 1 insertion(+) diff --git a/manifest.json b/manifest.json index 61641df..83261ae 100644 --- a/manifest.json +++ b/manifest.json @@ -8,6 +8,7 @@ }, "url": "http://www.mattermost.org/", "license": "free", + "version": "4.6.0-1", "maintainer": { "name": "pmorinerie", "email": "kemenaran@gmail.com" From ac0637da3fd957cc76755ca2deeb499d649cf45d Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 29 Jan 2018 11:15:24 +0530 Subject: [PATCH 07/33] scripts: backup Mattermost data files Fix #79 --- scripts/backup | 7 +++++++ scripts/restore | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/scripts/backup b/scripts/backup index aa4bfe3..9e3d9d5 100755 --- a/scripts/backup +++ b/scripts/backup @@ -20,6 +20,7 @@ ynh_abort_if_errors app=$YNH_APP_INSTANCE_NAME final_path="/var/www/$app" +data_path="/home/yunohost.app/$app" domain=$(ynh_app_setting_get $app domain) db_name="$app" default_backup_dir="${1}apps/$app" @@ -33,6 +34,12 @@ backup_dir=${backup_dir:-"$default_backup_dir"} ynh_backup "$final_path" "${backup_dir}$final_path" +#================================================= +# BACKUP THE APP DATA +#================================================= + +ynh_backup "$data_path" "${backup_dir}$data_path" + #================================================= # BACKUP THE DATABASE #================================================= diff --git a/scripts/restore b/scripts/restore index bd4ef34..df91701 100644 --- a/scripts/restore +++ b/scripts/restore @@ -51,6 +51,12 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file "$final_path" +#================================================= +# RESTORE THE APP DATA +#================================================= + +ynh_restore_file "$data_path" + #================================================= # RESTORE THE MYSQL DATABASE #================================================= From cbf70d12c5bf0f36819d489dff29b185bde68ec0 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 29 Jan 2018 11:18:14 +0530 Subject: [PATCH 08/33] scripts: modernize backup script --- scripts/backup | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/scripts/backup b/scripts/backup index 9e3d9d5..859f559 100755 --- a/scripts/backup +++ b/scripts/backup @@ -23,8 +23,6 @@ final_path="/var/www/$app" data_path="/home/yunohost.app/$app" domain=$(ynh_app_setting_get $app domain) db_name="$app" -default_backup_dir="${1}apps/$app" -backup_dir=${backup_dir:-"$default_backup_dir"} #================================================= # STANDARD BACKUP STEPS @@ -32,29 +30,29 @@ backup_dir=${backup_dir:-"$default_backup_dir"} # BACKUP THE APP MAIN DIR #================================================= -ynh_backup "$final_path" "${backup_dir}$final_path" +ynh_backup "$final_path" #================================================= # BACKUP THE APP DATA #================================================= -ynh_backup "$data_path" "${backup_dir}$data_path" +ynh_backup "$data_path" #================================================= # BACKUP THE DATABASE #================================================= ynh_mysql_dump_db "$db_name" > db.sql -ynh_backup "db.sql" "${backup_dir}/db.sql" +ynh_backup "db.sql" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "${backup_dir}/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP SYSTEMD #================================================= -ynh_backup "/etc/systemd/system/$app.service" "${backup_dir}/etc/systemd/system/$app.service" +ynh_backup "/etc/systemd/system/$app.service" From e379a0e46eca84cf380d166bdda63ee565b874ee Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 29 Jan 2018 10:41:55 +0530 Subject: [PATCH 09/33] package_check: mark LDAP auth as not applicable Mattermost doesn't support LDAP auth in the Free edition (this feature is restricted to the Entreprise non-free edition). See https://github.com/YunoHost-Apps/mattermost_ynh/issues/58 --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index 5151a8f..e6fa3bd 100644 --- a/check_process +++ b/check_process @@ -23,7 +23,7 @@ Level 1=auto Level 2=auto Level 3=auto - Level 4=0 + Level 4=na Level 5=auto Level 6=auto Level 7=auto From ffb899422ba31dae1bd1ce532cdc4bb6b38f5789 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 29 Jan 2018 05:14:36 +0000 Subject: [PATCH 10/33] manifest: make the licence explicit This fixes a package_linter warning about YEP 1.3 --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 83261ae..6763edd 100644 --- a/manifest.json +++ b/manifest.json @@ -7,7 +7,7 @@ "fr": "Une alternative open-source et auto-hébergée à Slack" }, "url": "http://www.mattermost.org/", - "license": "free", + "license": "GPL-3.0-only", "version": "4.6.0-1", "maintainer": { "name": "pmorinerie", From 5cb1861f822accf84933471ee0adb6918adb96a3 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 29 Jan 2018 10:46:27 +0530 Subject: [PATCH 11/33] Vagrantfile: use upstream package_check version All our fixes have been merged upstream, so this is not needed anymore. --- Vagrantfile | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index a1dec32..ca9abb1 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -67,11 +67,6 @@ Vagrant.configure("2") do |config| # Install package_check if ! [ -f "$HOME/package_check/package_check.sh" ]; then git clone https://github.com/YunoHost/package_check - # Checkout our custom patches (until they get merged upstream) - cd package_check - git remote add kemenaran https://github.com/kemenaran/package_check.git - git fetch kemenaran - git checkout --track kemenaran/fixes # Fix LXC containers not being able to reach outside internet. # The default configuration is to detect the default gateway used From 6190241432bf26cd350254663cf6548281b75b2c Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 29 Jan 2018 11:05:11 +0530 Subject: [PATCH 12/33] manifest: improve copywriting --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 6763edd..c58151d 100644 --- a/manifest.json +++ b/manifest.json @@ -44,7 +44,7 @@ "name": "analytics", "type": "boolean", "ask": { - "en": "Do you want to allow Mattermost to send some telemetrics about your usage of this app?", + "en": "Allow Mattermost to send some telemetrics about your usage of this app?", "fr": "Autorisez-vous Mattermost à envoyer des informations anonymes sur votre usage de l’application ?" }, "default": false From 068bc7d399423ea917e5a9f599bffa07ff280820 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 29 Jan 2018 12:58:19 +0530 Subject: [PATCH 13/33] check_process: modernize syntax --- check_process | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/check_process b/check_process index e6fa3bd..54af7e4 100644 --- a/check_process +++ b/check_process @@ -1,10 +1,12 @@ ;; Mattermost ; Manifest - domain="ynhtests.local" (DOMAIN) + domain="ynhtests.local" (DOMAIN) path="" (PATH) + user="admin" (USER) language="fr" is_public=1 (PUBLIC|public=1|private=0) - password="alpine" (PASSWORD) + password="alpine" + port="8065" (PORT) ; Checks pkg_linter=1 setup_root=1 From 3a6b0c752ba8d5589a30238dd54fd29a14bf7b8a Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Tue, 30 Jan 2018 12:14:28 +0530 Subject: [PATCH 14/33] scripts: fix restoration of smtp user password --- scripts/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index df91701..7218c15 100644 --- a/scripts/restore +++ b/scripts/restore @@ -72,7 +72,7 @@ ynh_mysql_connect_as $db_user $db_pwd $db_name < ./db.sql # Create the dedicated user (if not existing) smtp_user="$app" if ! ynh_system_user_exists "$smtp_user"; then - smtp_password=$(ynh_app_setting_get $app smtp_password) + smtp_password=$(ynh_app_setting_get $app smtppwd) useradd -M --shell /bin/false -p $(openssl passwd -1 "$smtp_password") "$smtp_user" fi From aa7721322dd4ab7ae489bccf5e9d989cac0834f6 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 29 Jan 2018 07:19:04 +0000 Subject: [PATCH 15/33] scripts: modernize the publix/private switch This allow package_check to properly test it. --- check_process | 2 +- manifest.json | 6 +++--- scripts/install | 8 ++++---- scripts/restore | 7 +++++-- scripts/upgrade | 12 ++++++++++++ 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/check_process b/check_process index 54af7e4..58cf35f 100644 --- a/check_process +++ b/check_process @@ -10,7 +10,7 @@ ; Checks pkg_linter=1 setup_root=1 - setup_private=0 + setup_private=1 setup_public=1 upgrade=1 backup_restore=1 diff --git a/manifest.json b/manifest.json index c58151d..6924340 100644 --- a/manifest.json +++ b/manifest.json @@ -32,13 +32,13 @@ "example": "domain.org" }, { - "name": "public_site", + "name": "is_public", + "type": "boolean", "ask": { "en": "Can guest users access this chat?", "fr": "Les utilisateurs non-enregistrés peuvent-ils accéder à ce chat ?" }, - "choices": ["Yes", "No"], - "default": "Yes" + "default": true }, { "name": "analytics", diff --git a/scripts/install b/scripts/install index 4da5910..75b98b7 100644 --- a/scripts/install +++ b/scripts/install @@ -21,7 +21,7 @@ ynh_abort_if_errors app=$YNH_APP_INSTANCE_NAME domain=$YNH_APP_ARG_DOMAIN -is_public=$YNH_APP_ARG_PUBLIC_SITE +is_public=$YNH_APP_ARG_IS_PUBLIC analytics=$YNH_APP_ARG_ANALYTICS path_url="/" @@ -163,11 +163,11 @@ sudo yunohost service add "$app" --log "$logs_path/mattermost.log" #================================================= ynh_app_setting_set "$app" is_public "$is_public" -if [ "$is_public" = "Yes" ]; -then + +if [[ $is_public == "1" ]]; then + # Make the app accessible to the public ynh_app_setting_set "$app" unprotected_uris "/" fi -sudo yunohost app ssowatconf #================================================= # RELOAD NGINX diff --git a/scripts/restore b/scripts/restore index 7218c15..514bc46 100644 --- a/scripts/restore +++ b/scripts/restore @@ -93,9 +93,12 @@ sudo chown -R mattermost:adm "$logs_path" # RESTORE SSOWAT #================================================= -if [ "$is_public" = "Yes" ]; -then +if [[ $is_public == "1" ]]; then + # Make the app accessible to the public ynh_app_setting_set "$app" unprotected_uris "/" +else + # Remove the public access + ynh_app_setting_delete "$app" skipped_uris fi #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index b09a62c..2e166fc 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -72,6 +72,18 @@ backup_config_file="/tmp/config.json" sudo cp -f "$config_file" "$backup_config_file" +#================================================= +# MIGRATE SETTINGS FROM PREVIOUS VERSIONS +#================================================= + +# Convert is_public from "Yes"/"No" to 1 / 0 +if [[ $is_public == "Yes" ]]; then + is_public=1 +elif [[ $is_public == "No" ]]; then + is_public=0 +fi +ynh_app_setting_set "$app" is_public "$is_public" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= From 0918978e927500bcf6c491ea20ed83f7e8869d1d Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 29 Jan 2018 12:40:03 +0000 Subject: [PATCH 16/33] scripts: handle port in use --- check_process | 6 +++--- conf/nginx.conf | 4 ++-- conf/systemd.service | 2 +- scripts/_common.sh | 17 +++++++++++++++++ scripts/install | 23 ++++++++++++++++++----- scripts/upgrade | 12 ++++++++++-- 6 files changed, 51 insertions(+), 13 deletions(-) create mode 100644 scripts/_common.sh diff --git a/check_process b/check_process index 58cf35f..b7f56a3 100644 --- a/check_process +++ b/check_process @@ -6,7 +6,6 @@ language="fr" is_public=1 (PUBLIC|public=1|private=0) password="alpine" - port="8065" (PORT) ; Checks pkg_linter=1 setup_root=1 @@ -15,9 +14,10 @@ upgrade=1 backup_restore=1 multi_instance=0 - port_already_use=0 (XXXX) + port_already_use=1 (8085) + # Checks not supported yet change_url=0 - # Tests not applicable + # Checks not applicable setup_sub_dir=0 setup_nourl=0 incorrect_path=0 diff --git a/conf/nginx.conf b/conf/nginx.conf index 47f726b..f2daff7 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -12,7 +12,7 @@ location ~ /api/v[0-9]+/(users/)?websocket$ { proxy_buffers 256 16k; proxy_buffer_size 16k; proxy_read_timeout 600s; - proxy_pass http://127.0.0.1:8065; + proxy_pass http://127.0.0.1:__PORT__; } location / { @@ -33,7 +33,7 @@ location / { #proxy_cache_min_uses 2; #proxy_cache_use_stale timeout; #proxy_cache_lock on; - proxy_pass http://127.0.0.1:8065; + proxy_pass http://127.0.0.1:__PORT__; # Yunohost addition: redirect HTTP to HTTPS if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; diff --git a/conf/systemd.service b/conf/systemd.service index 802d0bf..7a7977f 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -12,7 +12,7 @@ ExecStart=__FINALPATH__/bin/platform # # TODO: improve mattermost to send a STARTED notification, and # switch the service to 'Type=notify' instead. -ExecStartPost=/usr/bin/timeout 10 /bin/sh -c 'while ! nc -z localhost 8065; do sleep 0.2; done' +ExecStartPost=/usr/bin/timeout 10 /bin/sh -c 'while ! nc -z localhost __PORT__; do sleep 0.2; done' Restart=always RestartSec=10 WorkingDirectory=__FINALPATH__ diff --git a/scripts/_common.sh b/scripts/_common.sh new file mode 100644 index 0000000..02b43dc --- /dev/null +++ b/scripts/_common.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# Add a systemd configuration using ynh_add_systemd_config, +# by replacing __PORT__ with the $port variable value. +mattermost_add_systemd_config () { + local config_path="../conf" + + # Replace variables in the systemd template config file + sed -i'.template' "s/__PORT__/$port/g" "$config_path/systemd.service" + + # Create a dedicated systemd config + ynh_add_systemd_config + + # Restore the original configuration template + rm "$config_path/systemd.service" + mv "$config_path/systemd.service.template" "$config_path/systemd.service" +} diff --git a/scripts/install b/scripts/install index 75b98b7..a683626 100644 --- a/scripts/install +++ b/scripts/install @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +source _common.sh source /usr/share/yunohost/helpers #================================================= @@ -55,15 +56,28 @@ then script_die "Mattermost requires MySQL 5.6 or higher, or MariaDB 10 or higher." fi +#================================================= +# FIND AN AVAILABLE PATH +#================================================= + # Normalize the url path syntax path_url=$(ynh_normalize_url_path $path_url) # Check web path availability -ynh_webpath_available $domain $path_url +ynh_webpath_available "$domain" "$path_url" # Register (book) web path -ynh_webpath_register $app $domain $path_url +ynh_webpath_register "$app" "$domain" "$path_url" # Store setting ynh_app_setting_set "$app" domain "$domain" +#================================================= +# FIND AN AVAILABLE PORT +#================================================= + +# Find an available port +port=$(ynh_find_port 8065) +# Store setting +ynh_app_setting_set "$app" port "$port" + #================================================= # SET UP INSTALLATION VARIABLES #================================================= @@ -107,6 +121,7 @@ sudo mkdir -p "$logs_path" # Configure Service Settings sudo sed -i "s|\"SiteURL\": \"\"|\"SiteURL\": \"https://${domain}${path_url}\"|g" $final_path/config/config.json +sudo sed -i "s|\"ListenAddress\": \".*\"|\"ListenAddress\": \"127.0.0.1:${port}\"|g" $final_path/config/config.json # Configure the database connection db_connection_url="${db_user}:${db_password}@tcp(127.0.0.1:3306)/${db_name}?charset=utf8mb4,utf8" sudo sed -i "s|\"DataSource\": \".*\"|\"DataSource\": \"${db_connection_url}\"|g" $final_path/config/config.json @@ -142,15 +157,13 @@ sudo chown -R mattermost:adm "$logs_path" # NGINX CONFIGURATION #================================================= -# Copy conf/nginx.conf to the correct location ynh_add_nginx_config #================================================= # SYSTEMD CONFIGURATION #================================================= -# Create a dedicated systemd config -ynh_add_systemd_config +mattermost_add_systemd_config #================================================= # ADVERTISE SERVICE IN ADMIN PANEL diff --git a/scripts/upgrade b/scripts/upgrade index 2e166fc..27670b1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +source _common.sh source /usr/share/yunohost/helpers #================================================= @@ -22,6 +23,7 @@ ynh_abort_if_errors app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get mattermost domain) is_public=$(ynh_app_setting_get mattermost is_public) +port=$(ynh_app_setting_get mattermost port) root_path="$(pwd)/.." final_path="/var/www/$app" @@ -57,7 +59,7 @@ if $(sudo systemctl -q is-active "$app"); then sudo systemctl stop "$app" fi -# Legacy, for older versions of this app which used supervisor +# Legacy, for previous versions of this app which used supervisor if [ -f "/etc/supervisor/conf.d/${app}.conf" ]; then sudo supervisorctl stop "$app" sudo rm -f "/etc/supervisor/conf.d/${app}.conf" @@ -84,6 +86,12 @@ elif [[ $is_public == "No" ]]; then fi ynh_app_setting_set "$app" is_public "$is_public" +# Save the port used if not present +if ! [[ "$port" ]]; then + port=8065 + ynh_app_setting_set "$app" port "$port" +fi + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -107,7 +115,7 @@ ynh_add_nginx_config # SYSTEMD CONFIGURATION #================================================= -ynh_add_systemd_config +mattermost_add_systemd_config #================================================= # ADVERTISE SERVICE IN ADMIN PANEL From 256cafcb07be25ed34f843fdd33b9d756d1a6288 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Tue, 30 Jan 2018 06:42:16 +0000 Subject: [PATCH 17/33] scripts: support multi-instance install --- check_process | 2 +- manifest.json | 2 +- scripts/install | 21 +++++++++++---------- scripts/remove | 7 ++++--- scripts/restore | 11 ++++++----- scripts/upgrade | 13 +++++++------ 6 files changed, 30 insertions(+), 26 deletions(-) diff --git a/check_process b/check_process index b7f56a3..2beeea8 100644 --- a/check_process +++ b/check_process @@ -13,7 +13,7 @@ setup_public=1 upgrade=1 backup_restore=1 - multi_instance=0 + multi_instance=1 port_already_use=1 (8085) # Checks not supported yet change_url=0 diff --git a/manifest.json b/manifest.json index 6924340..863002e 100644 --- a/manifest.json +++ b/manifest.json @@ -13,7 +13,7 @@ "name": "pmorinerie", "email": "kemenaran@gmail.com" }, - "multi_instance": false, + "multi_instance": true, "services": [ "nginx" ], diff --git a/scripts/install b/scripts/install index a683626..2c5160f 100644 --- a/scripts/install +++ b/scripts/install @@ -91,19 +91,20 @@ logs_path="/var/log/$app" # CREATE A MYSQL DATABASE #================================================= -db_name="mattermost" +db_name="$app" db_user="mmuser" db_password=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d 'A-Za-z0-9' | sed -n 's/\(.\{24\}\).*/\1/p') -ynh_mysql_create_db $db_name $db_user $db_password -ynh_app_setting_set mattermost mysqlpwd "$db_password" +ynh_mysql_create_db "$db_name" "$db_user" "$db_password" +ynh_app_setting_set "$app" mysqlpwd "$db_password" #================================================= # CREATE USER FOR EMAIL NOTIFICATIONS #================================================= +smtp_user="$app" smtp_password=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d 'A-Za-z0-9' | sed -n 's/\(.\{24\}\).*/\1/p') -sudo useradd -M --shell /bin/false -p $(openssl passwd -1 "$smtp_password") "mattermost" -ynh_app_setting_set mattermost smtppwd "$smtp_password" +sudo useradd -M --shell /bin/false -p $(openssl passwd -1 "$smtp_password") "$smtp_user" +ynh_app_setting_set "$app" smtppwd "$smtp_password" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -131,7 +132,7 @@ sudo sed -i "s|\"Directory\": \"./data/\"|\"Directory\": \"${data_path}/\"|g" sudo sed -i "s|\"SendEmailNotifications\": false|\"SendEmailNotifications\": true|g" $final_path/config/config.json sudo sed -i "s|\"FeedbackName\": \"\"|\"FeedbackName\": \"Mattermost notification\"|g" $final_path/config/config.json sudo sed -i "s|\"FeedbackEmail\": \"\"|\"FeedbackEmail\": \"no-reply@${domain}\"|g" $final_path/config/config.json -sudo sed -i "s|\"SMTPUsername\": \"\"|\"SMTPUsername\": \"mattermost\"|g" $final_path/config/config.json +sudo sed -i "s|\"SMTPUsername\": \"\"|\"SMTPUsername\": \"${smtp_user}\"|g" $final_path/config/config.json sudo sed -i "s|\"SMTPPassword\": \"\"|\"SMTPPassword\": \"${smtp_password}\"|g" $final_path/config/config.json sudo sed -i "s|\"SMTPServer\": \"\"|\"SMTPServer\": \"localhost\"|g" $final_path/config/config.json sudo sed -i "s|\"SMTPPort\": \"\"|\"SMTPPort\": \"25\"|g" $final_path/config/config.json @@ -149,9 +150,9 @@ ynh_app_setting_set "$app" analytics "$analytics" # SECURE FILES AND DIRECTORIES #================================================= -sudo chown -R mattermost:www-data "$final_path" -sudo chown -R mattermost:www-data "$data_path" -sudo chown -R mattermost:adm "$logs_path" +sudo chown -R "$smtp_user:www-data" "$final_path" +sudo chown -R "$smtp_user:www-data" "$data_path" +sudo chown -R "$smtp_user:adm" "$logs_path" #================================================= # NGINX CONFIGURATION @@ -192,4 +193,4 @@ sudo systemctl reload nginx # START SERVER #================================================= -sudo systemctl start mattermost +sudo systemctl start "$app" diff --git a/scripts/remove b/scripts/remove index 2325037..cee4c2c 100755 --- a/scripts/remove +++ b/scripts/remove @@ -14,9 +14,10 @@ source /usr/share/yunohost/helpers #================================================= app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get mattermost domain) -db_name="mattermost" +domain=$(ynh_app_setting_get $app domain) +db_name="$app" db_user="mmuser" +smtp_user="$app" final_path="/var/www/$app" data_path="/home/yunohost.app/$app" logs_path="/var/log/$app" @@ -76,4 +77,4 @@ sudo rm -rf "$logs_path" # REMOVE DEDICATED USER #================================================= -ynh_system_user_delete "$app" +ynh_system_user_delete "$smtp_user" diff --git a/scripts/restore b/scripts/restore index 514bc46..6ae3cff 100644 --- a/scripts/restore +++ b/scripts/restore @@ -27,6 +27,7 @@ data_path="/home/yunohost.app/$app" logs_path="/var/log/$app" db_name="$app" db_user="mmuser" +smtp_user="$app" #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -62,8 +63,8 @@ ynh_restore_file "$data_path" #================================================= db_pwd=$(ynh_app_setting_get $app mysqlpwd) -ynh_mysql_setup_db $db_user $db_name $db_pwd -ynh_mysql_connect_as $db_user $db_pwd $db_name < ./db.sql +ynh_mysql_setup_db "$db_user" "$db_name" "$db_pwd" +ynh_mysql_connect_as "$db_user" "$db_pwd" "$db_name" < ./db.sql #================================================= # RECREATE THE DEDICATED USER @@ -81,13 +82,13 @@ fi #================================================= # Restore permissions on app files -sudo chown -R mattermost:www-data "$final_path" +sudo chown -R "$smtp_user:www-data" "$final_path" mkdir -p "$data_path" -sudo chown -R mattermost:www-data "$data_path" +sudo chown -R "$smtp_user:www-data" "$data_path" mkdir -p "$logs_path" -sudo chown -R mattermost:adm "$logs_path" +sudo chown -R "$smtp_user:adm" "$logs_path" #================================================= # RESTORE SSOWAT diff --git a/scripts/upgrade b/scripts/upgrade index 27670b1..a101c06 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -21,9 +21,10 @@ ynh_abort_if_errors #================================================= app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get mattermost domain) -is_public=$(ynh_app_setting_get mattermost is_public) -port=$(ynh_app_setting_get mattermost port) +domain=$(ynh_app_setting_get $app domain) +is_public=$(ynh_app_setting_get $app is_public) +port=$(ynh_app_setting_get $app port) +smtp_user="$app" root_path="$(pwd)/.." final_path="/var/www/$app" @@ -143,9 +144,9 @@ fi # RESTORE FILE PERMISSIONS #================================================= -sudo chown -R mattermost:www-data "$final_path" -sudo chown -R mattermost:www-data "$data_path" -sudo chown -R mattermost:adm "$logs_path" +sudo chown -R "$smtp_user:www-data" "$final_path" +sudo chown -R "$smtp_user:www-data" "$data_path" +sudo chown -R "$smtp_user:adm" "$logs_path" #================================================= # RELOAD NGINX From 3c9e53fe5713e02ee50d360e3e092a978bed6164 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Tue, 30 Jan 2018 12:19:02 +0530 Subject: [PATCH 18/33] scripts: rename `smtp_user` to `mattermost_user` --- scripts/install | 40 ++++++++++++++++++++-------------------- scripts/remove | 4 ++-- scripts/restore | 16 ++++++++-------- scripts/upgrade | 8 ++++---- 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/scripts/install b/scripts/install index 2c5160f..613e095 100644 --- a/scripts/install +++ b/scripts/install @@ -101,10 +101,10 @@ ynh_app_setting_set "$app" mysqlpwd "$db_password" # CREATE USER FOR EMAIL NOTIFICATIONS #================================================= -smtp_user="$app" -smtp_password=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d 'A-Za-z0-9' | sed -n 's/\(.\{24\}\).*/\1/p') -sudo useradd -M --shell /bin/false -p $(openssl passwd -1 "$smtp_password") "$smtp_user" -ynh_app_setting_set "$app" smtppwd "$smtp_password" +mattermost_user="$app" +mattermost_user_password=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d 'A-Za-z0-9' | sed -n 's/\(.\{24\}\).*/\1/p') +sudo useradd -M --shell /bin/false -p $(openssl passwd -1 "$mattermost_user_password") "$mattermost_user" +ynh_app_setting_set "$app" smtppwd "$mattermost_user_password" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -121,25 +121,25 @@ sudo mkdir -p "$logs_path" #================================================= # Configure Service Settings -sudo sed -i "s|\"SiteURL\": \"\"|\"SiteURL\": \"https://${domain}${path_url}\"|g" $final_path/config/config.json -sudo sed -i "s|\"ListenAddress\": \".*\"|\"ListenAddress\": \"127.0.0.1:${port}\"|g" $final_path/config/config.json +sudo sed -i "s|\"SiteURL\": \"\"|\"SiteURL\": \"https://${domain}${path_url}\"|g" $final_path/config/config.json +sudo sed -i "s|\"ListenAddress\": \".*\"|\"ListenAddress\": \"127.0.0.1:${port}\"|g" $final_path/config/config.json # Configure the database connection db_connection_url="${db_user}:${db_password}@tcp(127.0.0.1:3306)/${db_name}?charset=utf8mb4,utf8" -sudo sed -i "s|\"DataSource\": \".*\"|\"DataSource\": \"${db_connection_url}\"|g" $final_path/config/config.json +sudo sed -i "s|\"DataSource\": \".*\"|\"DataSource\": \"${db_connection_url}\"|g" $final_path/config/config.json # Configure uploaded files directory -sudo sed -i "s|\"Directory\": \"./data/\"|\"Directory\": \"${data_path}/\"|g" $final_path/config/config.json +sudo sed -i "s|\"Directory\": \"./data/\"|\"Directory\": \"${data_path}/\"|g" $final_path/config/config.json # Configure SMTP account for sending email notifications -sudo sed -i "s|\"SendEmailNotifications\": false|\"SendEmailNotifications\": true|g" $final_path/config/config.json -sudo sed -i "s|\"FeedbackName\": \"\"|\"FeedbackName\": \"Mattermost notification\"|g" $final_path/config/config.json -sudo sed -i "s|\"FeedbackEmail\": \"\"|\"FeedbackEmail\": \"no-reply@${domain}\"|g" $final_path/config/config.json -sudo sed -i "s|\"SMTPUsername\": \"\"|\"SMTPUsername\": \"${smtp_user}\"|g" $final_path/config/config.json -sudo sed -i "s|\"SMTPPassword\": \"\"|\"SMTPPassword\": \"${smtp_password}\"|g" $final_path/config/config.json -sudo sed -i "s|\"SMTPServer\": \"\"|\"SMTPServer\": \"localhost\"|g" $final_path/config/config.json -sudo sed -i "s|\"SMTPPort\": \"\"|\"SMTPPort\": \"25\"|g" $final_path/config/config.json +sudo sed -i "s|\"SendEmailNotifications\": false|\"SendEmailNotifications\": true|g" $final_path/config/config.json +sudo sed -i "s|\"FeedbackName\": \"\"|\"FeedbackName\": \"Mattermost notification\"|g" $final_path/config/config.json +sudo sed -i "s|\"FeedbackEmail\": \"\"|\"FeedbackEmail\": \"no-reply@${domain}\"|g" $final_path/config/config.json +sudo sed -i "s|\"SMTPUsername\": \"\"|\"SMTPUsername\": \"${mattermost_user}\"|g" $final_path/config/config.json +sudo sed -i "s|\"SMTPPassword\": \"\"|\"SMTPPassword\": \"${mattermost_user_password}\"|g" $final_path/config/config.json +sudo sed -i "s|\"SMTPServer\": \"\"|\"SMTPServer\": \"localhost\"|g" $final_path/config/config.json +sudo sed -i "s|\"SMTPPort\": \"\"|\"SMTPPort\": \"25\"|g" $final_path/config/config.json # Disable Mattermost debug console by default -sudo sed -i "s|\"EnableConsole\": true|\"EnableConsole\": false|g" $final_path/config/config.json +sudo sed -i "s|\"EnableConsole\": true|\"EnableConsole\": false|g" $final_path/config/config.json # Configure log file location -sudo sed -i "s|\"FileLocation\": \"\"|\"FileLocation\": \"$logs_path\"|g" $final_path/config/config.json +sudo sed -i "s|\"FileLocation\": \"\"|\"FileLocation\": \"$logs_path\"|g" $final_path/config/config.json # Configure analytics according to user choice if [ $analytics -eq 0 ]; then sudo sed -i "s|\"EnableDiagnostics\": true|\"EnableDiagnostics\": false|g" $final_path/config/config.json @@ -150,9 +150,9 @@ ynh_app_setting_set "$app" analytics "$analytics" # SECURE FILES AND DIRECTORIES #================================================= -sudo chown -R "$smtp_user:www-data" "$final_path" -sudo chown -R "$smtp_user:www-data" "$data_path" -sudo chown -R "$smtp_user:adm" "$logs_path" +sudo chown -R "$mattermost_user:www-data" "$final_path" +sudo chown -R "$mattermost_user:www-data" "$data_path" +sudo chown -R "$mattermost_user:adm" "$logs_path" #================================================= # NGINX CONFIGURATION diff --git a/scripts/remove b/scripts/remove index cee4c2c..988301f 100755 --- a/scripts/remove +++ b/scripts/remove @@ -17,7 +17,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) db_name="$app" db_user="mmuser" -smtp_user="$app" +mattermost_user="$app" final_path="/var/www/$app" data_path="/home/yunohost.app/$app" logs_path="/var/log/$app" @@ -77,4 +77,4 @@ sudo rm -rf "$logs_path" # REMOVE DEDICATED USER #================================================= -ynh_system_user_delete "$smtp_user" +ynh_system_user_delete "$mattermost_user" diff --git a/scripts/restore b/scripts/restore index 6ae3cff..d1f4d44 100644 --- a/scripts/restore +++ b/scripts/restore @@ -27,7 +27,7 @@ data_path="/home/yunohost.app/$app" logs_path="/var/log/$app" db_name="$app" db_user="mmuser" -smtp_user="$app" +mattermost_user="$app" #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -71,10 +71,10 @@ ynh_mysql_connect_as "$db_user" "$db_pwd" "$db_name" < ./db.sql #================================================= # Create the dedicated user (if not existing) -smtp_user="$app" -if ! ynh_system_user_exists "$smtp_user"; then - smtp_password=$(ynh_app_setting_get $app smtppwd) - useradd -M --shell /bin/false -p $(openssl passwd -1 "$smtp_password") "$smtp_user" +mattermost_user="$app" +if ! ynh_system_user_exists "$mattermost_user"; then + mattermost_user_password=$(ynh_app_setting_get $app smtppwd) + useradd -M --shell /bin/false -p $(openssl passwd -1 "$mattermost_user_password") "$mattermost_user" fi #================================================= @@ -82,13 +82,13 @@ fi #================================================= # Restore permissions on app files -sudo chown -R "$smtp_user:www-data" "$final_path" +sudo chown -R "$mattermost_user:www-data" "$final_path" mkdir -p "$data_path" -sudo chown -R "$smtp_user:www-data" "$data_path" +sudo chown -R "$mattermost_user:www-data" "$data_path" mkdir -p "$logs_path" -sudo chown -R "$smtp_user:adm" "$logs_path" +sudo chown -R "$mattermost_user:adm" "$logs_path" #================================================= # RESTORE SSOWAT diff --git a/scripts/upgrade b/scripts/upgrade index a101c06..c9a46d7 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -24,7 +24,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) is_public=$(ynh_app_setting_get $app is_public) port=$(ynh_app_setting_get $app port) -smtp_user="$app" +mattermost_user="$app" root_path="$(pwd)/.." final_path="/var/www/$app" @@ -144,9 +144,9 @@ fi # RESTORE FILE PERMISSIONS #================================================= -sudo chown -R "$smtp_user:www-data" "$final_path" -sudo chown -R "$smtp_user:www-data" "$data_path" -sudo chown -R "$smtp_user:adm" "$logs_path" +sudo chown -R "$mattermost_user:www-data" "$final_path" +sudo chown -R "$mattermost_user:www-data" "$data_path" +sudo chown -R "$mattermost_user:adm" "$logs_path" #================================================= # RELOAD NGINX From 9e77b066d89e79ee2a27f78db3b61b64a89ad3a6 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 31 Jan 2018 12:23:36 +0530 Subject: [PATCH 19/33] README: add build status badge --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index f8c3bb1..a44f28b 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,7 @@ A Yunohost package for [Mattermost](http://www.mattermost.org/), an open-source, self-hosted alternative to Slack. -## Build status - -See https://ci-apps.yunohost.org/jenkins/job/mattermost%20(Community)/ for checking current build status. +[![Build status](https://dash.yunohost.org/integration/mattermost.svg)](https://dash.yunohost.org/appci/app/mattermost) ## Requirements From fb6402f6a6549b668da1601c7c9432d196f3d106 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 31 Jan 2018 12:27:51 +0530 Subject: [PATCH 20/33] README: add install button --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a44f28b..7f46ccc 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ A Yunohost package for [Mattermost](http://www.mattermost.org/), an open-source, self-hosted alternative to Slack. -[![Build status](https://dash.yunohost.org/integration/mattermost.svg)](https://dash.yunohost.org/appci/app/mattermost) +[![Yunohost Build status](https://dash.yunohost.org/integration/mattermost.svg)](https://dash.yunohost.org/appci/app/mattermost) ## Requirements @@ -14,10 +14,13 @@ Mattermost requires: ## Installing +[![Install Mattermost with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=mattermost) + You can either : -* Install from the Yunohost Admin web interface, by providing this URL: `https://github.com/YunoHost-Apps/mattermost_ynh` -* Install from the command-line: `sudo yunohost app install https://github.com/YunoHost-Apps/mattermost_ynh` +* Install by clicking the button above; +* Install from the Yunohost Admin web interface, from the Community Apps list; +* Install from the command-line: `sudo yunohost app install https://github.com/YunoHost-Apps/mattermost_ynh`. ## Upgrading From 363dab19a38c3b813e3edd9a57414e1bf720e76f Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 31 Jan 2018 12:28:44 +0530 Subject: [PATCH 21/33] README: remove upgrade notes Upgrade now mostly works seamlessly. --- README.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/README.md b/README.md index 7f46ccc..d6ac03d 100644 --- a/README.md +++ b/README.md @@ -22,13 +22,6 @@ You can either : * Install from the Yunohost Admin web interface, from the Community Apps list; * Install from the command-line: `sudo yunohost app install https://github.com/YunoHost-Apps/mattermost_ynh`. -## Upgrading - -Mattermost upgrades tend to work only from one minor version to the other (3.0 to 3.1, 3.1 to 3.2, etc). - -**Important**: to upgrade from Mattermost 2.2, you will need an extra manual step. -Run the upgrade from Yunohost, then follow [this guide](https://docs.mattermost.com/administration/upgrade.html). - ## What works * Installation on domain's root From 0c11d43351df70afe8a42f4901871c98d07c8dac Mon Sep 17 00:00:00 2001 From: lindy65 Date: Wed, 31 Jan 2018 12:03:28 +0200 Subject: [PATCH 22/33] Propose updating to Mattermost v4.6.1 Hi @kemenaran, Here's a quick pull request updating to v4.6.1 You can find download links with hash numbers [here](https://pre-release.mattermost.com/core/pl/fnhridds6fybbg4w8s4frdhpny). Changelog with notes on patch releases is available [here](https://docs.mattermost.com/administration/changelog.html#release-v4-6). --- conf/app.src | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/app.src b/conf/app.src index f7c25ba..21f5cef 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,6 +1,6 @@ -SOURCE_URL=https://releases.mattermost.com/4.6.0/mattermost-4.6.0-linux-amd64.tar.gz -SOURCE_SUM=1865fbee3cd00659e56b178f766aff6eac6be2f4062b08a09fd66e801e687be1 +SOURCE_URL=https://releases.mattermost.com/4.6.1/mattermost-4.6.1-linux-amd64.tar.gz +SOURCE_SUM=38ab2cbeb7e0759fe156819690b17b52d5a3cff5c08e155a01af3763e335f19d SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=mattermost-4.6-linux-amd64.tar.gz +SOURCE_FILENAME=mattermost-4.6.1-linux-amd64.tar.gz From cad4712038afe8565f270c4bdee5a2d12b259383 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 5 Feb 2018 05:06:50 +0000 Subject: [PATCH 23/33] upgrade: attempt to restore backup only if it was correctly saved --- scripts/upgrade | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index c9a46d7..332de9b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -36,16 +36,32 @@ logs_path="/var/log/$app" #================================================= # Backup the current version of the app -ynh_backup_before_upgrade +# (NB: `tee` uses process substitution rather than a pipe, +# to avoid spawning a subshell that would not save global +# variables defined by `ynh_backup_before_upgrade`.) +ynh_backup_before_upgrade > >(tee "upgrade.log") +# Ensure the backup can be restored +if grep -q "mattermost: Warning$" "upgrade.log"; then + can_restore_backup=false +else + can_restore_backup=true +fi # If the upgrade fails… ynh_clean_setup () { - # Stop attempting to restart the app - if $(sudo systemctl -q is-active "$app"); then - sudo systemctl stop "$app" + if [ "$can_restore_backup" = true ]; then + # Stop attempting to restart the app + if $(sudo systemctl -q is-active "$app"); then + sudo systemctl stop "$app" + fi + # Restore the backup + ynh_restore_upgradebackup + + else + # Backup restoration is not available: + # let's try at least to restart the server. + sudo systemctl start "$app" fi - # Restore the backup - ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script From 972636a42cdcaf5bf2fa45428728ce88e21ebe24 Mon Sep 17 00:00:00 2001 From: lindy65 Date: Fri, 16 Feb 2018 10:54:09 +0200 Subject: [PATCH 24/33] Propose upgrading to Mattermost v4.7 Hey @kemenaran! Mattermost v4.7 release is officially out! You can find download links with hash numbers [here](https://pre-release.mattermost.com/core/pl/ezdkj88no7yd3qn4h5z3i8cbqr). Changelog with notes on patch releases is available [here](https://docs.mattermost.com/administration/changelog.html#release-v4-7). --- conf/app.src | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/app.src b/conf/app.src index 21f5cef..dfd65c3 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,6 +1,6 @@ -SOURCE_URL=https://releases.mattermost.com/4.6.1/mattermost-4.6.1-linux-amd64.tar.gz -SOURCE_SUM=38ab2cbeb7e0759fe156819690b17b52d5a3cff5c08e155a01af3763e335f19d +SOURCE_URL=https://releases.mattermost.com/4.7.0/mattermost-4.7.0-linux-amd64.tar.gz +SOURCE_SUM=ff53968ef8ac0a44f9a2d21fde719930b8042801f22866bc25bad53503819abd SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=mattermost-4.6.1-linux-amd64.tar.gz +SOURCE_FILENAME=mattermost-4.7.0-linux-amd64.tar.gz From 15e19ce6c93671b0c21fc8e208873515a5be951b Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Fri, 16 Feb 2018 06:25:18 +0000 Subject: [PATCH 25/33] Create first user and team from the app install --- check_process | 8 +++++--- manifest.json | 36 ++++++++++++++++++++++++++++++++++++ scripts/install | 21 +++++++++++++++++++++ 3 files changed, 62 insertions(+), 3 deletions(-) diff --git a/check_process b/check_process index 2beeea8..43764ff 100644 --- a/check_process +++ b/check_process @@ -2,10 +2,12 @@ ; Manifest domain="ynhtests.local" (DOMAIN) path="" (PATH) - user="admin" (USER) - language="fr" + admin_email="john@gmail.com" + admin_password="mattermost_password" + admin_locale="fr" + team_display_name="Mon équipe" is_public=1 (PUBLIC|public=1|private=0) - password="alpine" + analytics=0 ; Checks pkg_linter=1 setup_root=1 diff --git a/manifest.json b/manifest.json index 863002e..d4a2ee7 100644 --- a/manifest.json +++ b/manifest.json @@ -40,6 +40,42 @@ }, "default": true }, + { + "name": "admin_email", + "ask": { + "en": "Login email for the chat admin", + "fr": "Adresse email de login pour l’administrateur du chat" + }, + "example": "john@gmail.com", + "optional": false + }, + { + "name": "admin_password", + "type": "password", + "ask": { + "en": "Password for the chat admin", + "fr": "Mot de passe pour l’administrateur du chat" + }, + "optional": false + }, + { + "name": "admin_locale", + "ask": { + "en": "Choose the language of the chat for the admin", + "fr": "Choissisez la langue utilisée pour l'administrateur" + }, + "choices": ["en", "fr"], + "default": "en" + }, + { + "name": "team_display_name", + "ask": { + "en": "Choose a Team name", + "fr": "Choisissez le nom de l’équipe" + }, + "example": "Super Groupe", + "optional": false + }, { "name": "analytics", "type": "boolean", diff --git a/scripts/install b/scripts/install index 613e095..e1f29bf 100644 --- a/scripts/install +++ b/scripts/install @@ -23,6 +23,10 @@ ynh_abort_if_errors app=$YNH_APP_INSTANCE_NAME domain=$YNH_APP_ARG_DOMAIN is_public=$YNH_APP_ARG_IS_PUBLIC +admin_email=$YNH_APP_ARG_ADMIN_EMAIL +admin_password=$YNH_APP_ARG_ADMIN_PASSWORD +admin_locale=$YNH_APP_ARG_ADMIN_LOCALE +team_display_name=$YNH_APP_ARG_TEAM_DISPLAY_NAME analytics=$YNH_APP_ARG_ANALYTICS path_url="/" @@ -194,3 +198,20 @@ sudo systemctl reload nginx #================================================= sudo systemctl start "$app" + +#================================================= +# CREATE ADMIN AND FIRST TEAM +#================================================= + +admin_username=$(cut -d @ -f 1 <<< "$admin_email") +team_name=$(echo "$team_display_name" | iconv -f utf8 -t ascii//TRANSLIT//IGNORE | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z) + +cd "$final_path/bin" +sudo ./platform user create --username "$admin_username" --email "$admin_email" --password "$admin_password" --locale "$admin_locale" --system_admin +sudo ./platform user verify "$admin_username" +sudo ./platform team create --name "$team_name" --display_name "$team_display_name" --email "$admin_email" +sudo ./platform team add "$team_name" "$admin_username" + +ynh_app_setting_set "$app" admin_email "$admin_email" +ynh_app_setting_set "$app" admin_locale "$admin_locale" +ynh_app_setting_set "$app" team_name "$team_name" From 5e84e55b8cd2e3a9e48ae243e3e6e3f3e0a34ac7 Mon Sep 17 00:00:00 2001 From: lindy65 Date: Fri, 23 Feb 2018 10:42:34 +0200 Subject: [PATCH 26/33] Propose Upgrading to Mattermost 4.7.2 Hi @kemenaran, Mattermost v4.7.2 has been released! You can find download links with hash numbers [here](https://pre-release.mattermost.com/core/pl/3qtanuti1jgbuympmhmu6g1sce). Changelog with notes on patch releases is available [here](https://docs.mattermost.com/administration/changelog.html#release-v4-7). Could we have your help upgrading mattermost-ynh to the v4.7.2? Thanks! --- conf/app.src | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/app.src b/conf/app.src index dfd65c3..b1b5572 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,6 +1,6 @@ -SOURCE_URL=https://releases.mattermost.com/4.7.0/mattermost-4.7.0-linux-amd64.tar.gz -SOURCE_SUM=ff53968ef8ac0a44f9a2d21fde719930b8042801f22866bc25bad53503819abd +SOURCE_URL=https://releases.mattermost.com/4.7.2/mattermost-4.7.2-linux-amd64.tar.gz +SOURCE_SUM=947577631a94a003d660b4eb08f07585e0e1f93c3e5b63a8c30a72e0abcde9c1 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=mattermost-4.7.0-linux-amd64.tar.gz +SOURCE_FILENAME=mattermost-4.7.2-linux-amd64.tar.gz From 30694ab367407324ed93ebdc6b86851849e039e3 Mon Sep 17 00:00:00 2001 From: lindy65 Date: Fri, 9 Mar 2018 10:14:28 +0200 Subject: [PATCH 27/33] Propose upgrading to Mattermost v4.7.3 Hi @kemenaran, Mattermost v4.7.3 release is officially out. It contains a security fix so upgrade is recommended. You can find download links with hash numbers [here](https://pre-release.mattermost.com/core/pl/usjficyphtnbmx7g8bxtbm8dwr). Changelog with notes on patch releases is available [here](https://docs.mattermost.com/administration/changelog.html#release-v4-7). Thanks for continuing to maintain Mattermost Yunohost! --- conf/app.src | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/app.src b/conf/app.src index b1b5572..17a898d 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,6 +1,6 @@ -SOURCE_URL=https://releases.mattermost.com/4.7.2/mattermost-4.7.2-linux-amd64.tar.gz -SOURCE_SUM=947577631a94a003d660b4eb08f07585e0e1f93c3e5b63a8c30a72e0abcde9c1 +SOURCE_URL=https://releases.mattermost.com/4.7.3/mattermost-4.7.3-linux-amd64.tar.gz +SOURCE_SUM=09a728ad189d2cf315d664fed7caf68fbf9af60f85e2619d308b5345e576293c SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=mattermost-4.7.2-linux-amd64.tar.gz +SOURCE_FILENAME=mattermost-4.7.3-linux-amd64.tar.gz From a79aa7eb2d29f4b5cfb2a26004cbdb10dc71388f Mon Sep 17 00:00:00 2001 From: lindy65 Date: Fri, 16 Mar 2018 09:37:57 +0200 Subject: [PATCH 28/33] Propose upgrading to Mattermost v4.8.0 Hey @kemenaran! Mattermost v4.8.0 release is officially out. You can find download links with hash numbers [here](https://pre-release.mattermost.com/core/pl/57qfbxkdrid88ci7hpasrozwda). Changelog with notes on patch releases is available [here](https://docs.mattermost.com/administration/changelog.html). (Note: changelog has been merged and will show up a little later.) Thanks! --- conf/app.src | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/app.src b/conf/app.src index 17a898d..5ac7636 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,6 +1,6 @@ -SOURCE_URL=https://releases.mattermost.com/4.7.3/mattermost-4.7.3-linux-amd64.tar.gz -SOURCE_SUM=09a728ad189d2cf315d664fed7caf68fbf9af60f85e2619d308b5345e576293c +SOURCE_URL=https://releases.mattermost.com/4.8.0/mattermost-4.8.0-linux-amd64.tar.gz +SOURCE_SUM=1d6dda36592544b92905989a922ff4698d0a824c30483e0ecdf7233443001c25 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=mattermost-4.7.3-linux-amd64.tar.gz +SOURCE_FILENAME=mattermost-4.8.0-linux-amd64.tar.gz From 331fcce8c5989722106d4e8a034709f362a7c065 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Fri, 16 Feb 2018 09:43:55 +0530 Subject: [PATCH 29/33] conf: use a Type=notify systemd service MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Starting from Mattermost 4.8, the server process sends a systemd notification when it is ready to accept network connections. Thus we don't need to explicitely wait for the port to be open in the service. As a bonus, by removing the hack, we don't need to replace `__PORT__` in the service anymore–which means the associated script helper can be removed too. --- conf/systemd.service | 8 +------- scripts/_common.sh | 17 ----------------- scripts/install | 3 +-- scripts/upgrade | 3 +-- 4 files changed, 3 insertions(+), 28 deletions(-) delete mode 100644 scripts/_common.sh diff --git a/conf/systemd.service b/conf/systemd.service index 7a7977f..7b2b574 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -5,14 +5,8 @@ After=mysql.service Requires=mysql.service [Service] -Type=simple +Type=notify ExecStart=__FINALPATH__/bin/platform -# HACK: Wait for Mattermost port to be open before declaring the service to be launched successfully. -# This avoids to report the service as launched even when it crashes a few milliseconds after start. -# -# TODO: improve mattermost to send a STARTED notification, and -# switch the service to 'Type=notify' instead. -ExecStartPost=/usr/bin/timeout 10 /bin/sh -c 'while ! nc -z localhost __PORT__; do sleep 0.2; done' Restart=always RestartSec=10 WorkingDirectory=__FINALPATH__ diff --git a/scripts/_common.sh b/scripts/_common.sh deleted file mode 100644 index 02b43dc..0000000 --- a/scripts/_common.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -# Add a systemd configuration using ynh_add_systemd_config, -# by replacing __PORT__ with the $port variable value. -mattermost_add_systemd_config () { - local config_path="../conf" - - # Replace variables in the systemd template config file - sed -i'.template' "s/__PORT__/$port/g" "$config_path/systemd.service" - - # Create a dedicated systemd config - ynh_add_systemd_config - - # Restore the original configuration template - rm "$config_path/systemd.service" - mv "$config_path/systemd.service.template" "$config_path/systemd.service" -} diff --git a/scripts/install b/scripts/install index e1f29bf..621960d 100644 --- a/scripts/install +++ b/scripts/install @@ -6,7 +6,6 @@ # IMPORT GENERIC HELPERS #================================================= -source _common.sh source /usr/share/yunohost/helpers #================================================= @@ -168,7 +167,7 @@ ynh_add_nginx_config # SYSTEMD CONFIGURATION #================================================= -mattermost_add_systemd_config +ynh_add_systemd_config #================================================= # ADVERTISE SERVICE IN ADMIN PANEL diff --git a/scripts/upgrade b/scripts/upgrade index 332de9b..965f1f8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -6,7 +6,6 @@ # IMPORT GENERIC HELPERS #================================================= -source _common.sh source /usr/share/yunohost/helpers #================================================= @@ -132,7 +131,7 @@ ynh_add_nginx_config # SYSTEMD CONFIGURATION #================================================= -mattermost_add_systemd_config +ynh_add_systemd_config #================================================= # ADVERTISE SERVICE IN ADMIN PANEL From 397793f407170d229c8c051e0c2e5f5861a07eb1 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Fri, 16 Feb 2018 09:45:53 +0530 Subject: [PATCH 30/33] conf: make the start timeout explicit This is the default value of systemd, made explicit. If startup takes longer than that, the process will be killed. --- conf/systemd.service | 1 + 1 file changed, 1 insertion(+) diff --git a/conf/systemd.service b/conf/systemd.service index 7b2b574..b32afd3 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -7,6 +7,7 @@ Requires=mysql.service [Service] Type=notify ExecStart=__FINALPATH__/bin/platform +TimeoutStartSec=90 Restart=always RestartSec=10 WorkingDirectory=__FINALPATH__ From 1404063a5cd61030b3126f8ce787cb27b5a94602 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Fri, 16 Feb 2018 09:46:01 +0530 Subject: [PATCH 31/33] conf: add file overwrite warning --- conf/systemd.service | 3 +++ 1 file changed, 3 insertions(+) diff --git a/conf/systemd.service b/conf/systemd.service index b32afd3..55ea561 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -1,3 +1,6 @@ +# This file is managed by the Yunohost Mattermost package, +# and will be overwritten on upgrade. + [Unit] Description=Mattermost After=network.target From d10c3cf7b34bafb9360d531a8255844ee1cc86fd Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Thu, 1 Mar 2018 18:06:55 +0530 Subject: [PATCH 32/33] conf: increase systemd start timeout This allows for time to execute database migrations, and is in line with the official Mattermost docs. --- conf/systemd.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/systemd.service b/conf/systemd.service index 55ea561..2bbde55 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -10,7 +10,7 @@ Requires=mysql.service [Service] Type=notify ExecStart=__FINALPATH__/bin/platform -TimeoutStartSec=90 +TimeoutStartSec=3600 Restart=always RestartSec=10 WorkingDirectory=__FINALPATH__ From e3798d828f99761e85a88119dfcdff14cacfcb67 Mon Sep 17 00:00:00 2001 From: amyblais Date: Tue, 10 Apr 2018 09:55:36 -0400 Subject: [PATCH 33/33] Update app.src --- conf/app.src | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/app.src b/conf/app.src index 5ac7636..b906bb9 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,6 +1,6 @@ -SOURCE_URL=https://releases.mattermost.com/4.8.0/mattermost-4.8.0-linux-amd64.tar.gz -SOURCE_SUM=1d6dda36592544b92905989a922ff4698d0a824c30483e0ecdf7233443001c25 +SOURCE_URL=https://releases.mattermost.com/4.8.1/mattermost-4.8.1-linux-amd64.tar.gz +SOURCE_SUM=3dac9f9bb4884cd83b8274c2bd7c32418f2535d3f9911cea845ac047ee2c7a82 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=mattermost-4.8.0-linux-amd64.tar.gz +SOURCE_FILENAME=mattermost-4.8.1-linux-amd64.tar.gz