1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mattermost_ynh.git synced 2024-09-03 19:36:29 +02:00

Merge pull request #203 from YunoHost-Apps/repackage

This commit is contained in:
Pierre de La Morinerie 2021-01-23 19:56:21 +01:00 committed by GitHub
commit b36901fb52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 1395 additions and 428 deletions

View file

@ -1,42 +1,71 @@
# Mattermost for YunoHost # Mattermost for YunoHost
[![Integration level](https://dash.yunohost.org/integration/mattermost.svg)](https://dash.yunohost.org/appci/app/mattermost) ![](https://ci-apps.yunohost.org/ci/badges/mattermost.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/mattermost.maintain.svg) [![Integration level](https://dash.yunohost.org/integration/mattermost.svg)](https://dash.yunohost.org/appci/app/mattermost) ![](https://ci-apps.yunohost.org/ci/badges/mattermost.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/mattermost.maintain.svg)
[![Install Mattermost with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=mattermost) [![Install Mattermost with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=mattermost)
*[Lire ce readme en français.](./README_fr.md)*
> *This package allows you to install Mattermost quickly and simply on a YunoHost server.
If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
## Overview ## Overview
A Yunohost package for [Mattermost](http://www.mattermost.org/), an open-source, self-hosted alternative to Slack. Mattermost is a self-hosted, open source instant messaging and service software. It's designed as an internal chat for organizations and businesses, and it's touted as an alternative to Slack.
## Requirements **Shipped version:** 5.31.0
Mattermost requires: ## Screenshots
* A x86_64 system (check with `uname -m`) (ARM Raspberry Pi wont work, sorry), ![](https://ucarecdn.com/8cd90d9d-8902-4845-a15b-f4664e5fcfb3/-/format/auto/-/quality/lighter/-/max_icc_size/10/-/resize/1288x/)
* Yunohost 3.0 or higher (check in Yunohost Admin panel),
* MySQL 5.6 or higher, or MariaDB 10 or higher (check with `mysql --version`).
## Installing ## Configuration
You can either : * How to configure this app: From an admin panel, a plain file with SSH.
* Install by clicking the button above; ## Documentation
* 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`.
## What works * Official documentation: https://docs.mattermost.com/
* YunoHost documentation: https://yunohost.org/#/app_mattermost
* Installation on domain root or sub-directory ## YunoHost specific features
* Notification emails
* Push notifications (through Mattermost relay server)
* Service control in Yunohost Services panel
## TODO This package can install the [*Entreprise Edition*](https://docs.mattermost.com/overview/product.html#mattermost-enterprise-edition) or the [*Team Edition*](https://docs.mattermost.com/overview/product.html#mattermost-team-edition).
* ARM compatible package for Raspberry Pi (see #124) Mattermost Mobile and Desktop Apps are available [here](https://mattermost.com/download/)
* LDAP integration (only paid Entreprise Edition, see [#58](https://github.com/YunoHost-Apps/mattermost_ynh/issues/58))
## About telemetrics #### Multi-user support
Mattermost can collect some anonymous telemetrics about your usage of the software. These data are sent to a third-party service named [segment.com](https://segment.com/). * Are LDAP and HTTP auth supported? **No**
You can find more information about this behavior in the [Mattermost documentation](https://docs.mattermost.com/administration/telemetry.html). * Can the app be used by multiple users? **Yes**
In this Yunohost package telemetrics collection is strictly opt-in, and can be turned on or off before the app is installed. #### Supported architectures
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/mattermost%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/mattermost/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/mattermost%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/mattermost/)
## Limitations
* LDAP integration is not supported (see #58)
## Additional information
* This package can by installed on `ARM`, `ARM64` and `x86-64` architecture (only `x86-64` if you choose to install the *Entreprise Edition*).
## Links
* Report a bug: https://github.com/YunoHost-Apps/mattermost_ynh/issues
* App website: http://www.mattermost.org/
* Upstream app repository: https://github.com/mattermost/mattermost-server
* YunoHost website: https://yunohost.org/
---
## Developer info
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/mattermost_ynh/tree/testing).
To try the testing branch, please proceed like that.
```
sudo yunohost app install https://github.com/YunoHost-Apps/mattermost_ynh/tree/testing --debug
or
sudo yunohost app upgrade mattermost -u https://github.com/YunoHost-Apps/mattermost_ynh/tree/testing --debug
```

69
README_fr.md Normal file
View file

@ -0,0 +1,69 @@
# Mattermost pour YunoHost
[![Niveau d'intégration](https://dash.yunohost.org/integration/mattermost.svg)](https://dash.yunohost.org/appci/app/mattermost) ![](https://ci-apps.yunohost.org/ci/badges/mattermost.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/mattermost.maintain.svg)
[![Installer Mattermost avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=mattermost)
*[Read this readme in english.](./README.md)*
> *Ce package vous permet d'installer Mattermost rapidement et simplement sur un serveur YunoHost.
Si vous n'avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install) pour apprendre comment l'installer.*
## Vue d'ensemble
Mattermost est un logiciel et un service de messagerie instantanée libre auto-hébergeable. Il est conçu comme un chat interne pour les organisations et les entreprises, et il est présenté comme une alternative à Slack.
**Version incluse :** 5.31.0
## Captures d'écran
![](https://ucarecdn.com/8cd90d9d-8902-4845-a15b-f4664e5fcfb3/-/format/auto/-/quality/lighter/-/max_icc_size/10/-/resize/1288x/)
## Configuration
* Comment configurer cette application : via le panneau d'administration, un fichier brut en SSH.
## Documentation
* Documentation officielle : https://docs.mattermost.com/
* Documentation YunoHost : https://yunohost.org/#/app_mattermost_fr
## Caractéristiques spécifiques YunoHost
Ce paquet peut installer la version [*Entreprise Edition*](https://docs.mattermost.com/overview/product.html#mattermost-enterprise-edition) ou la version [*Team Edition*](https://docs.mattermost.com/overview/product.html#mattermost-team-edition).
#### Support multi-utilisateur
* L'authentification LDAP et HTTP est-elle prise en charge ? **Non**
* L'application peut-elle être utilisée par plusieurs utilisateurs ? **Oui**
#### Supported architectures
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/mattermost%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/mattermost/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/mattermost%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/mattermost/)
## Limitations
* L'intégration LDAP n'est pas gérée (see #58)
## Informations additionnelles
Ce paquet peut être installé sur les architectures `ARM`, `ARM64` et `x86-64` (mais uniquement `x86-64` si vous choisissez d'installer la version *Enterprise Edition*).
## Liens
* Signaler un bug : https://github.com/YunoHost-Apps/mattermost_ynh/issues
* Site de l'application : http://www.mattermost.org/
* Dépôt de l'application principale : https://github.com/mattermost/mattermost-server
* Site web YunoHost : https://yunohost.org/
---
## Informations pour les développeurs
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/mattermost_ynh/tree/testing).
Pour essayer la branche testing, procédez comme suit.
```
sudo yunohost app install https://github.com/YunoHost-Apps/mattermost_ynh/tree/testing --debug
ou
sudo yunohost app upgrade mattermost -u https://github.com/YunoHost-Apps/mattermost_ynh/tree/testing --debug
```

View file

@ -1,38 +1,53 @@
;; Mattermost ;; Test with Enterprise Edition
; Manifest ; Manifest
domain="ynhtests.local" (DOMAIN) domain="domain.tld" (DOMAIN)
path="/path" (PATH) path="/path" (PATH)
admin="john" (USER)
email="john@gmail.com"
admin_email="john@gmail.com" admin_email="john@gmail.com"
password="admin!42"
admin_password="admin!42" admin_password="admin!42"
admin_locale="fr" language="fr"
version="Enterprise"
team_display_name="Mon équipe" team_display_name="Mon équipe"
is_public=1 (PUBLIC|public=1|private=0) is_public=1 (PUBLIC|public=1|private=0)
analytics=0
; Checks ; Checks
pkg_linter=1 pkg_linter=1
setup_sub_dir=1
setup_root=1
setup_nourl=0
setup_private=1
setup_public=1
upgrade=1
upgrade=1 from_commit=202cc0725652d4b8fbca52630267247bd58c8de1
backup_restore=1
multi_instance=1
port_already_use=0
change_url=1
;; Test with Team Edition
; Manifest
domain="domain.tld" (DOMAIN)
path="/path" (PATH)
admin="john" (USER)
email="john@gmail.com"
admin_email="john@gmail.com"
password="admin!42"
admin_password="admin!42"
language="fr"
version="Team"
team_display_name="Mon équipe"
is_public=1 (PUBLIC|public=1|private=0)
; Checks
setup_sub_dir=1 setup_sub_dir=1
setup_root=1 setup_root=1
setup_private=1 setup_private=1
setup_public=1 setup_public=1
upgrade=1 upgrade=1
backup_restore=1 upgrade=1 from_commit=202cc0725652d4b8fbca52630267247bd58c8de1
multi_instance=1
port_already_use=1 (8085)
# Checks not supported yet
change_url=0
# Checks not applicable
setup_nourl=0
;;; Levels
Level 1=auto
Level 2=auto
Level 3=auto
Level 4=auto
Level 5=auto
Level 6=auto
Level 7=auto
Level 8=0
Level 9=0
Level 10=0
;;; Options ;;; Options
Email=kemenaran@gmail.com Email=kemenaran@gmail.com
Notification=change Notification=none
;;; Upgrade options
; commit=202cc0725652d4b8fbca52630267247bd58c8de1
name=Merge pull request #196 from amyblais/patch-51

View file

@ -1,6 +0,0 @@
SOURCE_URL=https://releases.mattermost.com/5.29.0/mattermost-5.29.0-linux-amd64.tar.gz
SOURCE_SUM=14c7aac7e39061b81085d3bab98a1de5e18adb24ecdc0e126b573cfd58b757e2
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=mattermost-5.29.0-linux-amd64.tar.gz

6
conf/arm.src Normal file
View file

@ -0,0 +1,6 @@
SOURCE_URL=https://github.com/SmartHoneybee/ubiquitous-memory/releases/download/v5.31.0/mattermost-v5.31.0-linux-arm.tar.gz
SOURCE_SUM=15af0f4757fe1db9f6322fd9d5551aacbfe1c4082ad543dc4641d0a541133b5f
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=mattermost-v5.31.0-linux-arm.tar.gz

6
conf/arm64.src Normal file
View file

@ -0,0 +1,6 @@
SOURCE_URL=https://github.com/SmartHoneybee/ubiquitous-memory/releases/download/v5.31.0/mattermost-v5.31.0-linux-arm64.tar.gz
SOURCE_SUM=5bc29121ea13f7be21231bc3d18a030a062d407daf53b89b8af99c2bd554d214
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=mattermost-v5.31.0-linux-arm64.tar.gz

546
conf/config.json Normal file
View file

@ -0,0 +1,546 @@
{
"ServiceSettings": {
"SiteURL": "__URL__",
"WebsocketURL": "",
"LicenseFileLocation": "",
"ListenAddress": "__PORT__",
"ConnectionSecurity": "",
"TLSCertFile": "",
"TLSKeyFile": "",
"TLSMinVer": "1.2",
"TLSStrictTransport": false,
"TLSStrictTransportMaxAge": 63072000,
"TLSOverwriteCiphers": [],
"UseLetsEncrypt": false,
"LetsEncryptCertificateCacheFile": "./config/letsencrypt.cache",
"Forward80To443": false,
"TrustedProxyIPHeader": [],
"ReadTimeout": 300,
"WriteTimeout": 300,
"IdleTimeout": 60,
"MaximumLoginAttempts": 10,
"GoroutineHealthThreshold": -1,
"GoogleDeveloperKey": "",
"EnableOAuthServiceProvider": false,
"EnableIncomingWebhooks": true,
"EnableOutgoingWebhooks": true,
"EnableCommands": true,
"EnableOnlyAdminIntegrations": true,
"EnablePostUsernameOverride": false,
"EnablePostIconOverride": false,
"EnableLinkPreviews": true,
"EnableTesting": false,
"EnableDeveloper": false,
"EnableOpenTracing": false,
"EnableSecurityFixAlert": true,
"EnableInsecureOutgoingConnections": false,
"AllowedUntrustedInternalConnections": "",
"EnableMultifactorAuthentication": false,
"EnforceMultifactorAuthentication": false,
"EnableUserAccessTokens": false,
"AllowCorsFrom": "",
"CorsExposedHeaders": "",
"CorsAllowCredentials": false,
"CorsDebug": false,
"AllowCookiesForSubdomains": false,
"ExtendSessionLengthWithActivity": true,
"SessionLengthWebInDays": 30,
"SessionLengthMobileInDays": 30,
"SessionLengthSSOInDays": 30,
"SessionCacheInMinutes": 10,
"SessionIdleTimeoutInMinutes": 43200,
"WebsocketSecurePort": 443,
"WebsocketPort": 80,
"WebserverMode": "gzip",
"EnableCustomEmoji": true,
"EnableEmojiPicker": true,
"EnableGifPicker": true,
"GfycatApiKey": "2_KtH_W5",
"GfycatApiSecret": "3wLVZPiswc3DnaiaFoLkDvB4X0IV6CpMkj4tf2inJRsBY6-FnkT08zGmppWFgeof",
"RestrictCustomEmojiCreation": "all",
"RestrictPostDelete": "all",
"AllowEditPost": "always",
"PostEditTimeLimit": -1,
"TimeBetweenUserTypingUpdatesMilliseconds": 5000,
"EnablePostSearch": true,
"MinimumHashtagLength": 3,
"EnableUserTypingMessages": true,
"EnableChannelViewedMessages": true,
"EnableUserStatuses": true,
"ExperimentalEnableAuthenticationTransfer": true,
"ClusterLogTimeoutMilliseconds": 2000,
"CloseUnusedDirectMessages": false,
"EnablePreviewFeatures": true,
"EnableTutorial": true,
"ExperimentalEnableDefaultChannelLeaveJoinMessages": true,
"ExperimentalGroupUnreadChannels": "disabled",
"ExperimentalChannelOrganization": false,
"ExperimentalChannelSidebarOrganization": "disabled",
"ExperimentalDataPrefetch": true,
"ImageProxyType": "",
"ImageProxyURL": "",
"ImageProxyOptions": "",
"EnableAPITeamDeletion": false,
"EnableAPIUserDeletion": false,
"ExperimentalEnableHardenedMode": false,
"DisableLegacyMFA": true,
"ExperimentalStrictCSRFEnforcement": false,
"EnableEmailInvitations": false,
"DisableBotsWhenOwnerIsDeactivated": true,
"EnableBotAccountCreation": false,
"EnableSVGs": false,
"EnableLatex": false,
"EnableAPIChannelDeletion": false,
"EnableLocalMode": false,
"LocalModeSocketLocation": "/var/tmp/mattermost_local.socket",
"EnableAWSMetering": false,
"SplitKey": "",
"FeatureFlagSyncIntervalSeconds": 30,
"DebugSplit": false,
"ThreadAutoFollow": true,
"CollapsedThreads": "disabled",
"ManagedResourcePaths": ""
},
"TeamSettings": {
"SiteName": "Mattermost",
"MaxUsersPerTeam": 50,
"EnableTeamCreation": true,
"EnableUserCreation": true,
"EnableOpenServer": false,
"EnableUserDeactivation": false,
"RestrictCreationToDomains": "",
"EnableCustomBrand": false,
"CustomBrandText": "",
"CustomDescriptionText": "",
"RestrictDirectMessage": "any",
"RestrictTeamInvite": "all",
"RestrictPublicChannelManagement": "all",
"RestrictPrivateChannelManagement": "all",
"RestrictPublicChannelCreation": "all",
"RestrictPrivateChannelCreation": "all",
"RestrictPublicChannelDeletion": "all",
"RestrictPrivateChannelDeletion": "all",
"RestrictPrivateChannelManageMembers": "all",
"EnableXToLeaveChannelsFromLHS": false,
"UserStatusAwayTimeout": 300,
"MaxChannelsPerTeam": 2000,
"MaxNotificationsPerChannel": 1000,
"EnableConfirmNotificationsToChannel": true,
"TeammateNameDisplay": "username",
"ExperimentalViewArchivedChannels": true,
"ExperimentalEnableAutomaticReplies": false,
"ExperimentalHideTownSquareinLHS": false,
"ExperimentalTownSquareIsReadOnly": false,
"LockTeammateNameDisplay": false,
"ExperimentalPrimaryTeam": "",
"ExperimentalDefaultChannels": []
},
"ClientRequirements": {
"AndroidLatestVersion": "",
"AndroidMinVersion": "",
"DesktopLatestVersion": "",
"DesktopMinVersion": "",
"IosLatestVersion": "",
"IosMinVersion": ""
},
"SqlSettings": {
"DriverName": "mysql",
"DataSource": "__DB_USER__:__DB_PASS__@tcp(localhost:3306)/__DB_NAME__?charset=utf8mb4,utf8",
"DataSourceReplicas": [],
"DataSourceSearchReplicas": [],
"MaxIdleConns": 20,
"ConnMaxLifetimeMilliseconds": 3600000,
"MaxOpenConns": 300,
"Trace": false,
"AtRestEncryptKey": "",
"QueryTimeout": 30,
"DisableDatabaseSearch": false
},
"LogSettings": {
"EnableConsole": true,
"ConsoleLevel": "INFO",
"ConsoleJson": true,
"EnableFile": true,
"FileLevel": "INFO",
"FileJson": true,
"FileLocation": "",
"EnableWebhookDebugging": true,
"EnableDiagnostics": false,
"EnableSentry": true,
"AdvancedLoggingConfig": ""
},
"ExperimentalAuditSettings": {
"FileEnabled": false,
"FileName": "",
"FileMaxSizeMB": 100,
"FileMaxAgeDays": 0,
"FileMaxBackups": 0,
"FileCompress": false,
"FileMaxQueueSize": 1000,
"AdvancedLoggingConfig": ""
},
"NotificationLogSettings": {
"EnableConsole": false,
"ConsoleLevel": "INFO",
"ConsoleJson": true,
"EnableFile": true,
"FileLevel": "INFO",
"FileJson": true,
"FileLocation": "__LOG__",
"AdvancedLoggingConfig": ""
},
"PasswordSettings": {
"MinimumLength": 8,
"Lowercase": false,
"Number": false,
"Uppercase": false,
"Symbol": false
},
"FileSettings": {
"EnableFileAttachments": true,
"EnableMobileUpload": true,
"EnableMobileDownload": true,
"MaxFileSize": 52428800,
"DriverName": "local",
"Directory": "__DATA__",
"EnablePublicLink": false,
"PublicLinkSalt": "",
"InitialFont": "nunito-bold.ttf",
"AmazonS3AccessKeyId": "",
"AmazonS3SecretAccessKey": "",
"AmazonS3Bucket": "",
"AmazonS3PathPrefix": "",
"AmazonS3Region": "",
"AmazonS3Endpoint": "s3.amazonaws.com",
"AmazonS3SSL": true,
"AmazonS3SignV2": false,
"AmazonS3SSE": false,
"AmazonS3Trace": false
},
"EmailSettings": {
"EnableSignUpWithEmail": true,
"EnableSignInWithEmail": true,
"EnableSignInWithUsername": true,
"SendEmailNotifications": true,
"UseChannelInEmailNotifications": false,
"RequireEmailVerification": false,
"FeedbackName": "Mattermost notification",
"FeedbackEmail": "__FEEDBACK__",
"ReplyToAddress": "",
"FeedbackOrganization": "",
"EnableSMTPAuth": false,
"SMTPUsername": "mattermost",
"SMTPPassword": "__USER_PW__",
"SMTPServer": "localhost",
"SMTPPort": "25",
"SMTPServerTimeout": 10,
"ConnectionSecurity": "",
"SendPushNotifications": true,
"PushNotificationServer": "https://push-test.mattermost.com",
"PushNotificationContents": "full",
"PushNotificationBuffer": 1000,
"EnableEmailBatching": false,
"EmailBatchingBufferSize": 256,
"EmailBatchingInterval": 30,
"EnablePreviewModeBanner": true,
"SkipServerCertificateVerification": false,
"EmailNotificationContentsType": "full",
"LoginButtonColor": "#0000",
"LoginButtonBorderColor": "#2389D7",
"LoginButtonTextColor": "#2389D7"
},
"RateLimitSettings": {
"Enable": false,
"PerSec": 10,
"MaxBurst": 100,
"MemoryStoreSize": 10000,
"VaryByRemoteAddr": true,
"VaryByUser": false,
"VaryByHeader": ""
},
"PrivacySettings": {
"ShowEmailAddress": true,
"ShowFullName": true
},
"SupportSettings": {
"TermsOfServiceLink": "https://about.mattermost.com/default-terms/",
"PrivacyPolicyLink": "https://about.mattermost.com/default-privacy-policy/",
"AboutLink": "https://about.mattermost.com/default-about/",
"HelpLink": "https://about.mattermost.com/default-help/",
"ReportAProblemLink": "https://about.mattermost.com/default-report-a-problem/",
"SupportEmail": "feedback@mattermost.com",
"CustomTermsOfServiceEnabled": false,
"CustomTermsOfServiceReAcceptancePeriod": 365,
"EnableAskCommunityLink": true
},
"AnnouncementSettings": {
"EnableBanner": false,
"BannerText": "",
"BannerColor": "#f2a93b",
"BannerTextColor": "#333333",
"AllowBannerDismissal": true,
"AdminNoticesEnabled": true,
"UserNoticesEnabled": true,
"NoticesURL": "https://notices.mattermost.com/",
"NoticesFetchFrequency": 3600,
"NoticesSkipCache": false
},
"ThemeSettings": {
"EnableThemeSelection": true,
"DefaultTheme": "default",
"AllowCustomThemes": true,
"AllowedThemes": []
},
"GitLabSettings": {
"Enable": false,
"Secret": "",
"Id": "",
"Scope": "",
"AuthEndpoint": "",
"TokenEndpoint": "",
"UserApiEndpoint": ""
},
"GoogleSettings": {
"Enable": false,
"Secret": "",
"Id": "",
"Scope": "profile email",
"AuthEndpoint": "https://accounts.google.com/o/oauth2/v2/auth",
"TokenEndpoint": "https://www.googleapis.com/oauth2/v4/token",
"UserApiEndpoint": "https://people.googleapis.com/v1/people/me?personFields=names,emailAddresses,nicknames,metadata"
},
"Office365Settings": {
"Enable": false,
"Secret": "",
"Id": "",
"Scope": "User.Read",
"AuthEndpoint": "https://login.microsoftonline.com/common/oauth2/v2.0/authorize",
"TokenEndpoint": "https://login.microsoftonline.com/common/oauth2/v2.0/token",
"UserApiEndpoint": "https://graph.microsoft.com/v1.0/me",
"DirectoryId": ""
},
"LdapSettings": {
"Enable": false,
"EnableSync": false,
"LdapServer": "",
"LdapPort": 389,
"ConnectionSecurity": "",
"BaseDN": "",
"BindUsername": "cn",
"BindPassword": "",
"UserFilter": "",
"GroupFilter": "",
"GuestFilter": "",
"EnableAdminFilter": false,
"AdminFilter": "",
"GroupDisplayNameAttribute": "",
"GroupIdAttribute": "",
"FirstNameAttribute": "",
"LastNameAttribute": "",
"EmailAttribute": "",
"UsernameAttribute": "",
"NicknameAttribute": "",
"IdAttribute": "",
"PositionAttribute": "",
"LoginIdAttribute": "",
"PictureAttribute": "",
"SyncIntervalMinutes": 60,
"SkipCertificateVerification": false,
"PublicCertificateFile": "",
"PrivateKeyFile": "",
"QueryTimeout": 60,
"MaxPageSize": 0,
"LoginFieldName": "",
"LoginButtonColor": "#0000",
"LoginButtonBorderColor": "#2389D7",
"LoginButtonTextColor": "#2389D7",
"Trace": false
},
"ComplianceSettings": {
"Enable": false,
"Directory": "./data/",
"EnableDaily": false
},
"LocalizationSettings": {
"DefaultServerLocale": "__LANGUAGE__",
"DefaultClientLocale": "__LANGUAGE__",
"AvailableLocales": ""
},
"SamlSettings": {
"Enable": false,
"EnableSyncWithLdap": false,
"EnableSyncWithLdapIncludeAuth": false,
"IgnoreGuestsLdapSync": false,
"Verify": true,
"Encrypt": true,
"SignRequest": false,
"IdpUrl": "",
"IdpDescriptorUrl": "",
"IdpMetadataUrl": "",
"ServiceProviderIdentifier": "",
"AssertionConsumerServiceURL": "",
"SignatureAlgorithm": "RSAwithSHA1",
"CanonicalAlgorithm": "Canonical1.0",
"ScopingIDPProviderId": "",
"ScopingIDPName": "",
"IdpCertificateFile": "",
"PublicCertificateFile": "",
"PrivateKeyFile": "",
"IdAttribute": "",
"GuestAttribute": "",
"EnableAdminAttribute": false,
"AdminAttribute": "",
"FirstNameAttribute": "",
"LastNameAttribute": "",
"EmailAttribute": "",
"UsernameAttribute": "",
"NicknameAttribute": "",
"LocaleAttribute": "",
"PositionAttribute": "",
"LoginButtonText": "SAML",
"LoginButtonColor": "#34a28b",
"LoginButtonBorderColor": "#2389D7",
"LoginButtonTextColor": "#ffffff"
},
"NativeAppSettings": {
"AppDownloadLink": "https://mattermost.com/download/#mattermostApps",
"AndroidAppDownloadLink": "https://about.mattermost.com/mattermost-android-app/",
"IosAppDownloadLink": "https://about.mattermost.com/mattermost-ios-app/"
},
"ClusterSettings": {
"Enable": false,
"ClusterName": "",
"OverrideHostname": "",
"NetworkInterface": "",
"BindAddress": "",
"AdvertiseAddress": "",
"UseIpAddress": true,
"UseExperimentalGossip": false,
"EnableExperimentalGossipEncryption": false,
"ReadOnlyConfig": true,
"GossipPort": 8074,
"StreamingPort": 8075,
"MaxIdleConns": 100,
"MaxIdleConnsPerHost": 128,
"IdleConnTimeoutMilliseconds": 90000
},
"MetricsSettings": {
"Enable": false,
"BlockProfileRate": 0,
"ListenAddress": ":8067"
},
"ExperimentalSettings": {
"ClientSideCertEnable": false,
"ClientSideCertCheck": "secondary",
"EnableClickToReply": false,
"LinkMetadataTimeoutMilliseconds": 5000,
"RestrictSystemAdmin": false,
"UseNewSAMLLibrary": false,
"CloudUserLimit": 0,
"CloudBilling": false,
"EnableSharedChannels": false
},
"AnalyticsSettings": {
"MaxUsersForStatistics": 2500
},
"ElasticsearchSettings": {
"ConnectionUrl": "http://localhost:9200",
"Username": "elastic",
"Password": "changeme",
"EnableIndexing": false,
"EnableSearching": false,
"EnableAutocomplete": false,
"Sniff": true,
"PostIndexReplicas": 1,
"PostIndexShards": 1,
"ChannelIndexReplicas": 1,
"ChannelIndexShards": 1,
"UserIndexReplicas": 1,
"UserIndexShards": 1,
"AggregatePostsAfterDays": 365,
"PostsAggregatorJobStartTime": "03:00",
"IndexPrefix": "",
"LiveIndexingBatchSize": 1,
"BulkIndexingTimeWindowSeconds": 3600,
"RequestTimeoutSeconds": 30,
"SkipTLSVerification": false,
"Trace": ""
},
"BleveSettings": {
"IndexDir": "",
"EnableIndexing": false,
"EnableSearching": false,
"EnableAutocomplete": false,
"BulkIndexingTimeWindowSeconds": 3600
},
"DataRetentionSettings": {
"EnableMessageDeletion": false,
"EnableFileDeletion": false,
"MessageRetentionDays": 365,
"FileRetentionDays": 365,
"DeletionJobStartTime": "02:00"
},
"MessageExportSettings": {
"EnableExport": false,
"ExportFormat": "actiance",
"DailyRunTime": "01:00",
"ExportFromTimestamp": 0,
"BatchSize": 10000,
"DownloadExportResults": false,
"GlobalRelaySettings": {
"CustomerType": "A9",
"SmtpUsername": "",
"SmtpPassword": "",
"EmailAddress": "",
"SMTPServerTimeout": 1800
}
},
"JobSettings": {
"RunJobs": true,
"RunScheduler": true
},
"PluginSettings": {
"Enable": true,
"EnableUploads": false,
"AllowInsecureDownloadUrl": false,
"EnableHealthCheck": true,
"Directory": "./plugins",
"ClientDirectory": "./client/plugins",
"Plugins": {},
"PluginStates": {
"com.mattermost.nps": {
"Enable": true
}
},
"EnableMarketplace": true,
"EnableRemoteMarketplace": true,
"AutomaticPrepackagedPlugins": true,
"RequirePluginSignature": false,
"MarketplaceUrl": "https://api.integrations.mattermost.com",
"SignaturePublicKeyFiles": []
},
"DisplaySettings": {
"CustomUrlSchemes": [],
"ExperimentalTimezone": true
},
"GuestAccountsSettings": {
"Enable": false,
"AllowEmailAccounts": true,
"EnforceMultifactorAuthentication": false,
"RestrictCreationToDomains": ""
},
"ImageProxySettings": {
"Enable": false,
"ImageProxyType": "local",
"RemoteImageProxyURL": "",
"RemoteImageProxyOptions": ""
},
"CloudSettings": {
"CWSUrl": "https://customers.mattermost.com"
},
"FeatureFlags": {
"TestFeature": "off",
"TestBoolFeature": false,
"CloudDelinquentEmailJobsEnabled": false
}
}

6
conf/enterprise.src Normal file
View file

@ -0,0 +1,6 @@
SOURCE_URL=https://releases.mattermost.com/5.31.0/mattermost-5.31.0-linux-amd64.tar.gz
SOURCE_SUM=05e4631a1c755925981838a331addf9575e5ff16f5c4ade2354ef66325f3d06d
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=mattermost-5.31.0-linux-amd64.tar.gz

View file

@ -1,6 +1,3 @@
# This file is managed by the Yunohost Mattermost package,
# and will be overwritten on upgrade.
[Unit] [Unit]
Description=Mattermost Description=Mattermost
After=network.target After=network.target
@ -15,7 +12,7 @@ Restart=always
RestartSec=10 RestartSec=10
WorkingDirectory=__FINALPATH__ WorkingDirectory=__FINALPATH__
User=__APP__ User=__APP__
Group=www-data Group=__APP__
LimitNOFILE=49152 LimitNOFILE=49152
[Install] [Install]

6
conf/x86-64.src Normal file
View file

@ -0,0 +1,6 @@
SOURCE_URL=https://releases.mattermost.com/5.31.0/mattermost-team-5.31.0-linux-amd64.tar.gz
SOURCE_SUM=3c9e862df1166000566772876f38713cf1eb8b64b675bcef3819fb9cc255d7bc
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=mattermost-team-5.31.0-linux-amd64.tar.gz

View file

@ -1,24 +1,25 @@
{ {
"packaging_format": 1,
"name": "Mattermost", "name": "Mattermost",
"id": "mattermost", "id": "mattermost",
"packaging_format": 1,
"description": { "description": {
"en": "An open-source, self-hosted alternative to Slack", "en": "Open source collaboration platform built for developers",
"fr": "Une alternative open-source et auto-hébergée à Slack" "fr": "Plateforme de collaboration open source conçue pour les développeurs"
}, },
"version": "5.31.0~ynh1",
"url": "http://www.mattermost.org/", "url": "http://www.mattermost.org/",
"license": "GPL-3.0-only", "license": "GPL-3.0-only",
"version": "5.29.0~ynh1",
"maintainer": { "maintainer": {
"name": "pmorinerie", "name": "pmorinerie",
"email": "kemenaran@gmail.com" "email": "kemenaran@gmail.com"
}, },
"multi_instance": true, "multi_instance": true,
"services": [ "services": [
"nginx" "nginx",
"mysql"
], ],
"requirements": { "requirements": {
"yunohost": ">= 3.0.0" "yunohost": ">= 3.8.1"
}, },
"arguments": { "arguments": {
"install" : [ "install" : [
@ -38,45 +39,62 @@
"en": "Choose a path for Mattermost", "en": "Choose a path for Mattermost",
"fr": "Choisissez un chemin pour Mattermost" "fr": "Choisissez un chemin pour Mattermost"
}, },
"example": "/chat", "example": "/mattermost",
"default": "/chat" "default": "/chat"
}, },
{ {
"name": "is_public", "name": "is_public",
"type": "boolean", "type": "boolean",
"ask": { "ask": {
"en": "Can users non registered on Yunohost access this chat?", "en": "Is it a public application?",
"fr": "Les invités non-enregistrés sur Yunohost peuvent-ils accéder à ce chat ?" "fr": "Est-ce une application publique ?"
},
"help": {
"en": "If enabled, Mattermost will be accessible by the user without a YunoHost account. This can be changed later via the webadmin.",
"fr": "Si cette case est cochée, Mattermost sera accessible par l'utilisateur sans compte YunoHost. Vous pourrez changer ceci plus tard via linterface dadministration."
}, },
"default": true "default": true
}, },
{ {
"name": "admin_email", "name": "admin",
"type": "string", "type": "user",
"ask": { "ask": {
"en": "Login email for the chat admin", "en": "Choose an admin user",
"fr": "Adresse email de login pour ladministrateur du chat" "fr": "Choisissez l'administrateur"
}, },
"example": "john@gmail.com", "example": "johndoe"
"optional": false
}, },
{ {
"name": "admin_password", "name": "password",
"type": "password", "type": "password",
"ask": { "ask": {
"en": "Password for the chat admin. At least 8 characters.", "en": "Set the administrator password",
"fr": "Mot de passe pour ladministrateur du chat. Minimum 8 caractères." "fr": "Définissez le mot de passe administrateur"
}, },
"optional": false "example": "Choose a password"
}, },
{ {
"name": "admin_locale", "name": "version",
"type": "string",
"ask": {
"en": "Choose the version you want to install",
"fr": "Choisissez la version que vous souhaitez installer"
},
"help": {
"en": "Use Team Edition for the open source version (ARM, ARM64 and x86-64 support) or Enterprise Edition if you want to use a license (x86-64 support only)",
"fr": "Utilisez Team Edition pour la version open source (prise en charge ARM, ARM64 et x86-64) ou Enterprise Edition si vous souhaitez utiliser une licence (prise en charge x86-64 uniquement)"
},
"choices": ["Enterprise", "Team"],
"default": "Team"
},
{
"name": "language",
"type": "string", "type": "string",
"ask": { "ask": {
"en": "Choose the language of the chat for the admin", "en": "Choose the language of the chat for the admin",
"fr": "Choissisez la langue utilisée pour l'administrateur" "fr": "Choissisez la langue utilisée pour l'administrateur"
}, },
"choices": ["en", "fr"], "choices": ["de", "en", "es", "fr", "it", "pt"],
"default": "en" "default": "en"
}, },
{ {
@ -87,17 +105,7 @@
"fr": "Choisissez le nom de léquipe" "fr": "Choisissez le nom de léquipe"
}, },
"example": "Team", "example": "Team",
"default": "Team", "default": "Team"
"optional": false
},
{
"name": "analytics",
"type": "boolean",
"ask": {
"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 lapplication ?"
},
"default": false
} }
] ]
} }

58
scripts/_common.sh Normal file
View file

@ -0,0 +1,58 @@
#!/bin/bash
#=================================================
# COMMON VARIABLES
#=================================================
#=================================================
# PERSONAL HELPERS
#=================================================
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
# Check the architecture
#
# example: architecture=$(ynh_detect_arch)
#
# usage: ynh_detect_arch
#
# Requires YunoHost version 2.2.4 or higher.
ynh_detect_arch(){
local architecture
if [ -n "$(uname -m | grep arm64)" ] || [ -n "$(uname -m | grep aarch64)" ]; then
architecture="arm64"
elif [ -n "$(uname -m | grep 64)" ]; then
architecture="x86-64"
elif [ -n "$(uname -m | grep armv7)" ]; then
architecture="arm"
elif [ -n "$(uname -m | grep armv6)" ]; then
architecture="arm"
elif [ -n "$(uname -m | grep armv5)" ]; then
architecture="arm"
else
architecture="unknown"
fi
echo $architecture
}
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================
# Execute a command as another user
# usage: ynh_exec_as USER COMMAND [ARG ...]
ynh_exec_as() {
local USER=$1
shift 1
if [[ $USER = $(whoami) ]]; then
eval "$@"
else
sudo -u "$USER" "$@"
fi
}

View file

@ -10,49 +10,67 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
final_path="/var/www/$app" final_path=$(ynh_app_setting_get --app=$app --key=final_path)
data_path="/home/yunohost.app/$app" domain=$(ynh_app_setting_get --app=$app --key=domain)
domain=$(ynh_app_setting_get $app domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_name="$app"
#================================================= #=================================================
# STANDARD BACKUP STEPS # DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
#================================================= #=================================================
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_backup "$final_path" ynh_backup --src_path="$final_path"
#================================================= #=================================================
# BACKUP THE APP DATA # BACKUP THE APP DATA
#================================================= #=================================================
ynh_backup "$data_path" ynh_backup --src_path="/home/yunohost.app/$app"
#=================================================
# BACKUP THE DATABASE
#=================================================
ynh_mysql_dump_db "$db_name" > db.sql
ynh_backup "db.sql"
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP LOGROTATE
#=================================================
ynh_backup --src_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# BACKUP SYSTEMD # BACKUP SYSTEMD
#================================================= #=================================================
ynh_backup "/etc/systemd/system/$app.service" ynh_backup --src_path="/etc/systemd/system/$app.service"
#=================================================
# BACKUP THE DATABASE
#=================================================
ynh_print_info --message="Backing up the MySQL database..."
ynh_mysql_dump_db --database="$db_name" > db.sql
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

138
scripts/change_url Normal file
View file

@ -0,0 +1,138 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH
new_domain=$YNH_APP_NEW_DOMAIN
new_path=$YNH_APP_NEW_PATH
app=$YNH_APP_INSTANCE_NAME
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED
#=================================================
change_domain=0
if [ "$old_domain" != "$new_domain" ]
then
change_domain=1
fi
change_path=0
if [ "$old_path" != "$new_path" ]
then
change_path=1
fi
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=4
ynh_systemd_action --service_name=$app --action=stop --log_path="/var/log/$app/$app.log"
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# Change the path in the NGINX config file
if [ $change_path -eq 1 ]
then
# Make a backup of the original NGINX config file if modified
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for NGINX helper
domain="$old_domain"
path_url="$new_path"
# Create a dedicated NGINX config
ynh_add_nginx_config
fi
# Change the domain for NGINX
if [ $change_domain -eq 1 ]
then
# Delete file checksum for the old conf file location
ynh_delete_file_checksum --file="$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
#=================================================
# EDIT MATTERMOST CONFIG
#=================================================
# MODIFY A CONFIG FILE
#=================================================
ynh_script_progression --message="Modifying a config file..." --weight=3
# Main config File
ynh_replace_string --match_string="\"SiteURL\": \".*\"" --replace_string="\"SiteURL\": \"https://${new_domain}${new_path}\"" --target_file="$final_path/config/config.json"
ynh_replace_string --match_string="\"FeedbackEmail\": \".*\"" --replace_string="\"FeedbackEmail\": \"no-reply@${new_domain}\"" --target_file="$final_path/config/config.json"
ynh_store_file_checksum --file="$final_path/config/config.json"
#=================================================
# GENERIC FINALISATION
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=2
# Start a systemd service
ynh_systemd_action --service_name=$app --action=start --log_path="systemd" --line_match="Started Mattermost"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for $app" --last

View file

@ -6,12 +6,16 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
@ -19,206 +23,207 @@ ynh_abort_if_errors
# RETRIEVE ARGUMENTS FROM THE MANIFEST # RETRIEVE ARGUMENTS FROM THE MANIFEST
#================================================= #=================================================
app=$YNH_APP_INSTANCE_NAME
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH path_url=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC is_public=$YNH_APP_ARG_IS_PUBLIC
admin_email=$YNH_APP_ARG_ADMIN_EMAIL admin=$YNH_APP_ARG_ADMIN
admin_password=$YNH_APP_ARG_ADMIN_PASSWORD email=$(ynh_user_get_info "$admin" mail)
admin_locale=$YNH_APP_ARG_ADMIN_LOCALE password=$YNH_APP_ARG_PASSWORD
language=$YNH_APP_ARG_LANGUAGE
team_display_name=$YNH_APP_ARG_TEAM_DISPLAY_NAME team_display_name=$YNH_APP_ARG_TEAM_DISPLAY_NAME
analytics=$YNH_APP_ARG_ANALYTICS architecture=$(ynh_detect_arch)
version=$YNH_APP_ARG_VERSION
app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#================================================= #=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1
# Allow using the `ynh_die` command without triggering linter warnings final_path=/var/www/$app
function script_die () { test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
die_command=$(printf '%s%s' 'ynh_' 'die')
$die_command "$*"
}
# Check for 64 bits support
arch="$(uname -m)"
if [[ "$arch" != "x86_64" ]]; then
script_die "Mattermost requires an x86_64 machine, but this one is '${arch}'."
fi
# Check for MySQL version (without triggering a package_linter warning)
db_command=$(printf '%s%s' 'my' 'sql')
db_version=$($db_command --version)
if [[ "$db_version" == *"Distrib 4."* ]] \
|| [[ "$db_version" == *"Distrib 5.0"* ]] \
|| [[ "$db_version" == *"Distrib 5.1"* ]] \
|| [[ "$db_version" == *"Distrib 5.2"* ]] \
|| [[ "$db_version" == *"Distrib 5.3"* ]] \
|| [[ "$db_version" == *"Distrib 5.4"* ]] \
|| [[ "$db_version" == *"Distrib 5.5"* ]];
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"
# Register (book) web path # Register (book) web path
ynh_webpath_register "$app" "$domain" "$path_url" ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
# Store setting
ynh_app_setting_set "$app" domain "$domain" #=================================================
ynh_app_setting_set "$app" path "$path_url" # STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..." --weight=6
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set --app=$app --key=password --value=$password
ynh_app_setting_set --app=$app --key=language --value=$language
ynh_app_setting_set --app=$app --key=version --value=$version
ynh_app_setting_set --app=$app --key=team_display_name --value=$team_display_name
#================================================= #=================================================
# FIND AN AVAILABLE PORT # FIND AN AVAILABLE PORT
#================================================= #=================================================
ynh_script_progression --message="Finding an available port..." --weight=3
# Find an available port # Find an available port
port=$(ynh_find_port 8065) port=$(ynh_find_port --port=8065)
# Store setting ynh_app_setting_set --app=$app --key=port --value=$port
ynh_app_setting_set "$app" port "$port"
#=================================================
# SET UP INSTALLATION VARIABLES
#=================================================
root_path="$(pwd)/.."
final_path="/var/www/$app"
data_path="/home/yunohost.app/$app"
logs_path="/var/log/$app"
#================================================= #=================================================
# CREATE A MYSQL DATABASE # CREATE A MYSQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Creating a MySQL database..." --weight=10
db_name="$app" db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user="$YNH_APP_INSTANCE_NAME" db_user=$db_name
db_password=$(ynh_string_random --length=24)
ynh_mysql_create_db "$db_name" "$db_user" "$db_password" ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_app_setting_set "$app" mysqluser "$db_user" ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
ynh_app_setting_set "$app" mysqlpwd "$db_password"
#================================================= #=================================================
# CREATE USER FOR EMAIL NOTIFICATIONS # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Configuring system user..." --weight=3
mattermost_user="$app" # Create a system user
mattermost_user_password=$(ynh_string_random --length=24) ynh_system_user_create --username=$app
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 # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=3
ynh_app_setting_set "$app" final_path "$final_path" ynh_app_setting_set --app=$app --key=final_path --value=$final_path
ynh_setup_source "$final_path" # Download, check integrity, uncompress and patch the source from app.src
mkdir -p "$data_path" if [ "$version" = "Enterprise" ]; then
mkdir -p "$logs_path" # Get Enterprise binary path
ynh_setup_source --dest_dir="$final_path" --source_id="enterprise"
elif [ "$version" = "Team" ]; then
# Get Team binary path
ynh_setup_source --dest_dir="$final_path" --source_id="$architecture"
fi
#=================================================
# CREATE DIRECTORY FOR DATA
#=================================================
ynh_script_progression --message="Creating the data directory..." --weight=1
# Create datadir folder
mkdir -p "/home/yunohost.app/$app"
# Define app's data directory
data_path="/home/yunohost.app/$app"
# Give permission to the datadir
chown -R $app: "$data_path"
#=================================================
# HANDLE LOG FILES AND LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1
# Create log directory
mkdir -p /var/log/$app
#touch /var/log/$app/$app.log
logs_path="/var/log/$app"
chown $app -R $logs_path
# Setup logrotate
ynh_use_logrotate
#================================================= #=================================================
# EDIT MATTERMOST CONFIG # EDIT MATTERMOST CONFIG
#================================================= #=================================================
# MODIFY A CONFIG FILE
#=================================================
ynh_script_progression --message="Modifying a config file..." --weight=3
# Configure Service Settings cp ../conf/config.json $final_path/config/config.json
ynh_replace_string --match_string "\"SiteURL\": \"\"" --replace_string "\"SiteURL\": \"https://${domain}${path_url}\"" --target_file $final_path/config/config.json
ynh_replace_string --match_string "\"ListenAddress\": \".*\"" --replace_string "\"ListenAddress\": \"127.0.0.1:${port}\"" --target_file $final_path/config/config.json # Main config File
# Configure the database connection ynh_replace_string --match_string="__URL__" --replace_string="https://$domain$path_url" --target_file="$final_path/config/config.json"
db_connection_url="${db_user}:${db_password}@tcp(127.0.0.1:3306)/${db_name}?charset=utf8mb4,utf8" ynh_replace_string --match_string="__PORT__" --replace_string="127.0.0.1:$port" --target_file="$final_path/config/config.json"
ynh_replace_string --match_string "\"DataSource\": \".*\"" --replace_string "\"DataSource\": \"${db_connection_url}\"" --target_file $final_path/config/config.json ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/config/config.json"
# Configure uploaded files directory ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$final_path/config/config.json"
ynh_replace_string --match_string "\"Directory\": \"./data/\"" --replace_string "\"Directory\": \"${data_path}/\"" --target_file $final_path/config/config.json ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="$final_path/config/config.json"
# Configure SMTP account for sending email notifications ynh_replace_string --match_string="__DATA__" --replace_string="$data_path" --target_file="$final_path/config/config.json"
ynh_replace_string --match_string "\"SendEmailNotifications\": false" --replace_string "\"SendEmailNotifications\": true" --target_file $final_path/config/config.json ynh_replace_string --match_string="__FEEDBACK__" --replace_string="no-reply@${domain}" --target_file="$final_path/config/config.json"
ynh_replace_string --match_string "\"FeedbackName\": \"\"" --replace_string "\"FeedbackName\": \"Mattermost notification\"" --target_file $final_path/config/config.json ynh_replace_string --match_string="__USER_PW__" --replace_string="$(ynh_string_random --length=24)" --target_file="$final_path/config/config.json"
ynh_replace_string --match_string "\"FeedbackEmail\": \"\"" --replace_string "\"FeedbackEmail\": \"no-reply@${domain}\"" --target_file $final_path/config/config.json ynh_replace_string --match_string="__LOG__" --replace_string="$logs_path" --target_file="$final_path/config/config.json"
ynh_replace_string --match_string "\"SMTPUsername\": \"\"" --replace_string "\"SMTPUsername\": \"${mattermost_user}\"" --target_file $final_path/config/config.json ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$final_path/config/config.json"
ynh_replace_string --match_string "\"SMTPPassword\": \"\"" --replace_string "\"SMTPPassword\": \"${mattermost_user_password}\"" --target_file $final_path/config/config.json
ynh_replace_string --match_string "\"SMTPServer\": \"\"" --replace_string "\"SMTPServer\": \"localhost\"" --target_file $final_path/config/config.json ynh_store_file_checksum --file="$final_path/config/config.json"
ynh_replace_string --match_string "\"SMTPPort\": \".*\"" --replace_string "\"SMTPPort\": \"25\"" --target_file $final_path/config/config.json
# Disable Mattermost debug console by default
ynh_replace_string --match_string "\"EnableConsole\": true" --replace_string "\"EnableConsole\": false" --target_file $final_path/config/config.json
# Configure log file location
ynh_replace_string --match_string "\"FileLocation\": \"\"" --replace_string "\"FileLocation\": \"$logs_path\"" --target_file $final_path/config/config.json
# Disable questionable password complexity rules
ynh_replace_string --match_string "\"MinimumLength\": 10" --replace_string "\"MinimumLength\": 8" --target_file $final_path/config/config.json
ynh_replace_string --match_string "\"Lowercase\": true" --replace_string "\"Lowercase\": false" --target_file $final_path/config/config.json
ynh_replace_string --match_string "\"Number\": true" --replace_string "\"Number\": false" --target_file $final_path/config/config.json
ynh_replace_string --match_string "\"Uppercase\": true" --replace_string "\"Uppercase\": false" --target_file $final_path/config/config.json
ynh_replace_string --match_string "\"Symbol\": true" --replace_string "\"Symbol\": false" --target_file $final_path/config/config.json
# Configure analytics according to user choice
if [ $analytics -eq 0 ]; then
ynh_replace_string --match_string "\"EnableDiagnostics\": true" --replace_string "\"EnableDiagnostics\": false" --target_file $final_path/config/config.json
fi
ynh_app_setting_set "$app" analytics "$analytics"
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
#================================================= #=================================================
chown -R "$mattermost_user:www-data" "$final_path" chown -R $app: $final_path
chown -R "$mattermost_user:www-data" "$data_path" chmod -R g+w $final_path
chown -R "$mattermost_user:adm" "$logs_path"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=2
# Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
#================================================= #=================================================
# SYSTEMD CONFIGURATION # SETUP SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=2
# Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
yunohost service add "$app" --log "$logs_path/mattermost.log"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_app_setting_set "$app" is_public "$is_public"
if [[ $is_public == "1" ]]; then
# Make the app accessible to the public
ynh_app_setting_set "$app" unprotected_uris "/"
fi
#=================================================
# RELOAD NGINX
#=================================================
systemctl reload nginx
#=================================================
# START SERVER
#=================================================
systemctl start "$app"
#================================================= #=================================================
# CREATE ADMIN AND FIRST TEAM # 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) 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" pushd "$final_path"
./mattermost user create --username "$admin_username" --email "$admin_email" --password "$admin_password" --locale "$admin_locale" --system_admin ynh_exec_warn_less ynh_exec_as $app bin/mattermost user create --username "$admin" --email "$email" --password "$password" --locale "$language" --system_admin
./mattermost user verify "$admin_username" ynh_exec_warn_less ynh_exec_as $app bin/mattermost user verify "$admin"
./mattermost team create --name "$team_name" --display_name "$team_display_name" --email "$admin_email" ynh_exec_warn_less ynh_exec_as $app bin/mattermost team create --name "$team_name" --display_name "$team_display_name" --email "$email"
./mattermost team add "$team_name" "$admin_username" ynh_exec_warn_less ynh_exec_as $app bin/mattermost team add "$team_name" "$admin"
popd
ynh_app_setting_set "$app" admin_email "$admin_email" #=================================================
ynh_app_setting_set "$app" admin_locale "$admin_locale" # INTEGRATE SERVICE IN YUNOHOST
ynh_app_setting_set "$app" team_name "$team_name" #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="Collaboration platform built for developers" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=2
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started Mattermost"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring SSOwat..." --weight=1
if [ $is_public -eq 1 ]
then
ynh_permission_update --permission "main" --add "visitors"
fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=2
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last

View file

@ -1,5 +1,4 @@
#!/bin/bash #!/bin/bash
set -u # treat unset variables as an error
#================================================= #=================================================
# GENERIC START # GENERIC START
@ -7,6 +6,7 @@ set -u # treat unset variables as an error
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
@ -14,69 +14,83 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
db_name="$app" domain=$(ynh_app_setting_get --app=$app --key=domain)
db_user=$(ynh_app_setting_get $app mysqluser) port=$(ynh_app_setting_get --app=$app --key=port)
db_user=${db_user:-"mmuser"} db_name=$(ynh_app_setting_get --app=$app --key=db_name)
mattermost_user="$app" db_user=$db_name
final_path="/var/www/$app" final_path=$(ynh_app_setting_get --app=$app --key=final_path)
data_path="/home/yunohost.app/$app"
logs_path="/var/log/$app"
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
#================================================= #=================================================
#=================================================
# REMOVE SERVICE FROM ADMIN PANEL # REMOVE SERVICE FROM ADMIN PANEL
#================================================= #=================================================
if yunohost service status | grep -q "$app"; then # Remove the service from the list of services known by Yunohost (added from `yunohost service add`)
yunohost service remove "$app" if ynh_exec_warn_less yunohost service status $app >/dev/null
then
ynh_script_progression --message="Removing $app service..." --weight=1
yunohost service remove $app
fi fi
#================================================= #=================================================
# STOP AND REMOVE SERVICE # STOP AND REMOVE SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
# Remove systemd service # Remove the dedicated systemd config
if $(systemctl -q is-active "$app"); then
systemctl stop "$app"
fi
ynh_remove_systemd_config ynh_remove_systemd_config
# Legacy, for older versions of this app which used supervisor
if [ -f "/etc/supervisor/conf.d/${app}.conf" ]; then
supervisorctl stop "$app"
ynh_secure_remove --file="/etc/supervisor/conf.d/${app}.conf"
fi
#================================================= #=================================================
# REMOVE THE MYSQL DATABASE # REMOVE THE MySQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Removing the MySQL database..." --weight=2
ynh_mysql_remove_db "$db_user" "$db_name" # Remove a database if it exists, along with the associated user
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Removing $app main directory..." --weight=6
ynh_secure_remove "$final_path" # Remove the app directory securely
ynh_secure_remove "$data_path" ynh_secure_remove --file="$final_path"
ynh_secure_remove --file="/home/yunohost.app/$app"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=5
# Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_remove_nginx_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
# Remove the app-specific logrotate config
ynh_remove_logrotate
#================================================= #=================================================
# REMOVE LOG FILE # REMOVE LOG FILE
#================================================= #=================================================
ynh_secure_remove --file="$logs_path" ynh_secure_remove --file="/var/log/$app"
#================================================= #=================================================
# REMOVE DEDICATED USER # REMOVE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
ynh_system_user_delete "$mattermost_user" ynh_system_user_delete --username=$app
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed" --last

View file

@ -1,43 +1,47 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
is_public=$(ynh_app_setting_get $app is_public) path_url=$(ynh_app_setting_get --app=$app --key=path)
path_url=$(ynh_app_setting_get $app path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
final_path="/var/www/$app" port=$(ynh_app_setting_get --app=$app --key=port)
data_path="/home/yunohost.app/$app" db_name=$(ynh_app_setting_get --app=$app --key=db_name)
logs_path="/var/log/$app" db_user=$db_name
db_name="$app"
db_user=$(ynh_app_setting_get $app mysqluser)
db_user=${db_user:-"mmuser"}
mattermost_user="$app"
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
#================================================= #=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1
ynh_webpath_available $domain $path_url \ ynh_webpath_available --domain=$domain --path_url=$path_url \
|| ynh_die "Path not available: ${domain}" || ynh_die --message="Path not available: ${domain}${path_url}"
test ! -d $final_path \ test ! -d $final_path \
|| ynh_die "There is already a directory: $final_path " || ynh_die --message="There is already a directory: $final_path "
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
@ -45,63 +49,50 @@ test ! -d $final_path \
# RESTORE THE NGINX CONFIGURATION # RESTORE THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=2
ynh_restore_file "$final_path" ynh_restore_file --origin_path="$final_path"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app
#================================================= #=================================================
# RESTORE THE APP DATA # RESTORE THE APP DATA
#================================================= #=================================================
ynh_restore_file "$data_path" ynh_restore_file --origin_path="/home/yunohost.app/$app"
chown -R $app: "/home/yunohost.app/$app"
#================================================= #=================================================
# RESTORE THE MYSQL DATABASE # RESTORE THE MYSQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Restoring the MySQL database..." --weight=6
db_pwd=$(ynh_app_setting_get $app mysqlpwd) db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
ynh_mysql_setup_db "$db_user" "$db_name" "$db_pwd" ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_mysql_connect_as "$db_user" "$db_pwd" "$db_name" < ./db.sql ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
# Create the dedicated user (if not existing)
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
#================================================= #=================================================
# RESTORE USER RIGHTS # RESTORE USER RIGHTS
#================================================= #=================================================
# Restore permissions on app files # Restore permissions on app files
chown -R "$mattermost_user:www-data" "$final_path" chown -R $app: $final_path
chmod -R g+w $final_path
mkdir -p "$data_path" logs_path="/var/log/$app"
chown -R "$mattermost_user:www-data" "$data_path" mkdir -p $logs_path
chown -R $app: $logs_path
mkdir -p "$logs_path"
chown -R "$mattermost_user:adm" "$logs_path"
#=================================================
# RESTORE SSOWAT
#=================================================
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
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
@ -110,24 +101,39 @@ fi
#================================================= #=================================================
ynh_restore_file "/etc/systemd/system/$app.service" ynh_restore_file "/etc/systemd/system/$app.service"
systemctl enable "$app" systemctl enable $app.service --quiet
#================================================= #=================================================
# ADVERTISE SERVICE IN ADMIN PANEL # ADVERTISE SERVICE IN ADMIN PANEL
#================================================= #=================================================
yunohost service add "$app" --log "$logs_path/mattermost.log" yunohost service add $app --description="Collaboration platform built for developers" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=2
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started Mattermost"
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
service nginx reload ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# START SERVER # END OF SCRIPT
#================================================= #=================================================
systemctl start "$app" ynh_script_progression --message="Restoration completed for $app" --last

View file

@ -6,93 +6,45 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=2
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_app_setting_get $app path) # used during nginx configuration
is_public=$(ynh_app_setting_get $app is_public)
port=$(ynh_app_setting_get $app port)
mattermost_user="$app"
root_path="$(pwd)/.." domain=$(ynh_app_setting_get --app=$app --key=domain)
final_path="/var/www/$app" path_url=$(ynh_app_setting_get --app=$app --key=path)
data_path="/home/yunohost.app/$app" is_public=$(ynh_app_setting_get --app=$app --key=is_public)
logs_path="/var/log/$app" port=$(ynh_app_setting_get --app=$app --key=port)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
language=$(ynh_app_setting_get --app=$app --key=language)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
architecture=$(ynh_detect_arch)
version=$(ynh_app_setting_get --app=$app --key=version)
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # CHECK VERSION
#================================================= #=================================================
ynh_script_progression --message="Checking version..." --weight=1
# Backup the current version of the app upgrade_type=$(ynh_check_app_version_changed)
# (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 () {
if [ "$can_restore_backup" = true ]; then
# Stop attempting to restart the app
if $(systemctl -q is-active "$app"); then
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.
systemctl start "$app"
fi
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#================================================= #=================================================
# STOP SERVER # ENSURE DOWNWARD COMPATIBILITY
#=================================================
# Stop the server (if the app is already using systemd)
if $(systemctl -q is-active "$app"); then
systemctl stop "$app"
fi
# Legacy, for previous versions of this app which used supervisor
if [ -f "/etc/supervisor/conf.d/${app}.conf" ]; then
supervisorctl stop "$app"
rm -f "/etc/supervisor/conf.d/${app}.conf"
fi
#=================================================
# BACKUP CONFIGURATION FILE
#=================================================
config_file="$final_path/config/config.json"
backup_config_file="/tmp/config.json"
cp -f "$config_file" "$backup_config_file"
#=================================================
# MIGRATE SETTINGS FROM PREVIOUS VERSIONS
#================================================= #=================================================
# Convert is_public from "Yes"/"No" to 1 / 0 # Convert is_public from "Yes"/"No" to 1 / 0
@ -101,77 +53,171 @@ if [[ $is_public == "Yes" ]]; then
elif [[ $is_public == "No" ]]; then elif [[ $is_public == "No" ]]; then
is_public=0 is_public=0
fi fi
ynh_app_setting_set "$app" is_public "$is_public" ynh_app_setting_set --app=$app --key=is_public --value=$is_public
# Save the port used if not present # Save the port used if not present
if ! [[ "$port" ]]; then if [ -z "$port" ]; then
port=8065 port=8065
ynh_app_setting_set "$app" port "$port" ynh_app_setting_set --app=$app --key=port --value=$port
fi fi
# Save the language used if not present
if [ -z "$language" ]; then
language="en"
ynh_app_setting_set --app=$app --key=language --value=$language
fi
# If version setting doesn't exist
if [ -z "$version" ]; then
version="Enterprise"
ynh_app_setting_set --app=$app --key=version --value=$version
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=3
ynh_systemd_action --service_name=$app --action=stop --log_path="/var/log/$app/$app.log"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_app_setting_set "$app" final_path "$final_path" if [ "$upgrade_type" == "UPGRADE_APP" ]
ynh_setup_source "$final_path" then
ynh_script_progression --message="Upgrading source files..." --weight=2
#================================================= # Create a temporary directory
# RESTORE CONFIGURATION FILE tmpdir="$(mktemp -d)"
#=================================================
cp -f "$backup_config_file" "$config_file" # Backup the config file in the temp dir
cp -a "$final_path/config/config.json" "$tmpdir/config.json"
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
if [ "$version" = "Enterprise" ]; then
ynh_setup_source --dest_dir="$final_path" --source_id="enterprise"
elif [ "$version" = "Team" ]; then
ynh_setup_source --dest_dir="$final_path" --source_id="$architecture"
fi
# Copy the admin saved settings from tmp directory to final path
cp -a "$tmpdir/config.json" "$final_path/config/config.json"
# Remove the tmp directory securely
ynh_secure_remove --file="$tmpdir"
fi
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=5
# Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
#================================================= #=================================================
# SYSTEMD CONFIGURATION # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --weight=2
# Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
yunohost service add "$app" --log "$logs_path/mattermost.log"
#================================================= #=================================================
# SPECIFIC UPGRADE STEPS # SPECIFIC UPGRADE STEPS
#================================================= #=================================================
# Fix log FileLocation path (changed in Mattermost 3.8, makes Mattermost >= 4.2 crash) # # Fix log FileLocation path (changed in Mattermost 3.8, makes Mattermost >= 4.2 crash)
# https://docs.mattermost.com/administration/changelog.html#release-v3-8-3 # # https://docs.mattermost.com/administration/changelog.html#release-v3-8-3
ynh_replace_string --match_string "\"FileLocation\": \"/var/log/mattermost.log\"" --replace_string "\"FileLocation\": \"/var/log\"" --target_file "$config_file" # ynh_replace_string --match_string "\"FileLocation\": \"/var/log/mattermost.log\"" --replace_string "\"FileLocation\": \"/var/log\"" --target_file "$config_file"
# Move log files to a directory (rather than directly in /var/log) # # Move log files to a directory (rather than directly in /var/log)
# See https://github.com/YunoHost-Apps/mattermost_ynh/issues/61 # # See https://github.com/YunoHost-Apps/mattermost_ynh/issues/61
mkdir -p "$logs_path" # mkdir -p "$logs_path"
ynh_replace_string --match_string "\"FileLocation\": \"/var/log\"" --replace_string "\"FileLocation\": \"$logs_path\"" --target_file "$config_file" # ynh_replace_string --match_string "\"FileLocation\": \"/var/log\"" --replace_string "\"FileLocation\": \"$logs_path\"" --target_file "$config_file"
if [ -f "/var/log/${app}.log" ]; then # if [ -f "/var/log/${app}.log" ]; then
mv "/var/log/${app}.log" "$logs_path/" # mv "/var/log/${app}.log" "$logs_path/"
fi # fi
#=================================================
# CREATE DIRECTORY FOR DATA
#=================================================
ynh_script_progression --message="Creating the data directory..." --weight=1
# Define app's data directory
data_path="/home/yunohost.app/$app"
# Create datadir folder
mkdir -p $data_path
# Give permission to the datadir
chown -R $app: "$data_path"
#================================================= #=================================================
# RESTORE FILE PERMISSIONS # RESTORE FILE PERMISSIONS
#================================================= #=================================================
chown -R "$mattermost_user:www-data" "$final_path" chown -R $app: $final_path
chown -R "$mattermost_user:www-data" "$data_path" chmod -R g+w $final_path
chown -R "$mattermost_user:adm" "$logs_path" chown -R $app: "/var/log/$app"
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="Collaboration platform built for developers" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=2
# Start a systemd service
ynh_systemd_action --service_name=$app --action=start --log_path="systemd" --line_match="Started Mattermost"
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
service nginx reload ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# START SERVER # END OF SCRIPT
#================================================= #=================================================
systemctl start "$app" ynh_script_progression --message="Upgrade of $app completed" --last