diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh deleted file mode 100644 index 8a84226..0000000 --- a/.github/workflows/updater.sh +++ /dev/null @@ -1,159 +0,0 @@ -#!/bin/bash - -#================================================= -# PACKAGE UPDATING HELPER -#================================================= - -# This script is meant to be run by GitHub Actions -# The YunoHost-Apps organisation offers a template Action to run this script periodically -# Since each app is different, maintainers can adapt its contents so as to perform -# automatic actions when a new upstream release is detected. - -# Remove this exit command when you are ready to run this Action -#exit 1 - -#================================================= -# FETCHING LATEST RELEASE AND ITS ASSETS -#================================================= - -# Fetching information -current_version=$(cat manifest.json | jq -j '.version|split("~")[0]') -repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]') -# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions) -version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1) - -if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then - version=${version:1} -fi - -# x86-64 team, x86-64 enterprise, ARM64 team and ARM64 enterprise assets are hosted on Mattermost's servers. -assets=() -assets+=("https://releases.mattermost.com/$version/mattermost-team-$version-linux-amd64.tar.gz") -assets+=("https://releases.mattermost.com/$version/mattermost-enterprise-$version-linux-amd64.tar.gz") -assets+=("https://releases.mattermost.com/$version/mattermost-team-$version-linux-arm64.tar.gz") -assets+=("https://releases.mattermost.com/$version/mattermost-enterprise-$version-linux-arm64.tar.gz") - -# ARM and ARM64 are published in another repository (with a leading "v" for version tags) -other_repo="SmartHoneybee/ubiquitous-memory" -other_assets=($(curl --silent "https://api.github.com/repos/$other_repo/releases" | jq -r '[ .[] | select(.tag_name=="'v$version'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'")) - -# Setting up the environment variables -echo "Current version: $current_version" -echo "Latest release from upstream: $version" -echo "VERSION=$version" >> $GITHUB_ENV -# For the time being, let's assume the script will fail -echo "PROCEED=false" >> $GITHUB_ENV - -# Proceed only if the retrieved version is greater than the current one -if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then - echo "::warning ::No new version available" - exit 0 -# Proceed only if a PR for this new version does not already exist -elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then - echo "::warning ::A branch already exists for this update" - exit 0 -fi -# Proceed only if all the binaries have been found -if (( ${#other_assets[@]} == 0 )); then - echo "::warning ::$other_repo has not released anything for v$version" - exit 0 -else - assets+=( ${other_assets[@]} ) -fi - -# Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.) -echo "${#assets[@]} available asset(s)" - -#================================================= -# UPDATE SOURCE FILES -#================================================= - -# Here we use the $assets variable to get the resources published in the upstream release. -# Here is an example for Grav, it has to be adapted in accordance with how the upstream releases look like. - -# Let's loop over the array of assets URLs -for asset_url in ${assets[@]}; do - -echo "Handling asset at $asset_url" - -# Assign the asset to a source file in conf/ directory -# Here we base the source file name upon a unique keyword in the assets url (admin vs. update) -# Leave $src empty to ignore the asset -case $asset_url in - *"mattermost-"*"-linux-arm.tar.gz") - src="team_armhf" - ;; - *"mattermost-team-"*"-linux-arm64.tar.gz") - src="team_arm64" - ;; - *"mattermost-enterprise-"*"-linux-amd64.tar.gz") - src="enterprise_amd64" - ;; - *"mattermost-team-"*"-linux-amd64.tar.gz") - src="team_amd64" - ;; - *"mattermost-enterprise-"*"-linux-amd64.tar.gz") - src="enterprise_amd64" - ;; - *) - src="" - ;; -esac - -# If $src is not empty, let's process the asset -if [ ! -z "$src" ]; then - -# Create the temporary directory -tempdir="$(mktemp -d)" - -# Download sources and calculate checksum -filename=${asset_url##*/} -curl --silent -4 -L $asset_url -o "$tempdir/$filename" -checksum=$(sha256sum "$tempdir/$filename" | head -c 64) - -# Delete temporary directory -rm -rf $tempdir - -# Get extension -if [[ $filename == *.tar.gz ]]; then - extension=tar.gz -else - extension=${filename##*.} -fi - -# Rewrite source file -cat < conf/$src.src -SOURCE_URL=$asset_url -SOURCE_SUM=$checksum -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=$extension -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=mattermost.tar.gz -EOT -echo "... conf/$src.src updated" - -else -echo "... asset ignored" -fi - -done - -#================================================= -# SPECIFIC UPDATE STEPS -#================================================= - -# Any action on the app's source code can be done. -# The GitHub Action workflow takes care of committing all changes after this script ends. - -#================================================= -# GENERIC FINALIZATION -#================================================= - -# Replace new version in manifest -echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json - -# No need to update the README, yunohost-bot takes care of it - -# The Action will proceed only if the PROCEED environment variable is set to true -echo "PROCEED=true" >> $GITHUB_ENV -exit 0 diff --git a/.github/workflows/updater.yml b/.github/workflows/updater.yml deleted file mode 100644 index 609c284..0000000 --- a/.github/workflows/updater.yml +++ /dev/null @@ -1,49 +0,0 @@ -# This workflow allows GitHub Actions to automagically update your app whenever a new upstream release is detected. -# You need to enable Actions in your repository settings, and fetch this Action from the YunoHost-Apps organization. -# This file should be enough by itself, but feel free to tune it to your needs. -# It calls updater.sh, which is where you should put the app-specific update steps. -name: Check for new upstream releases -on: - # Allow to manually trigger the workflow - workflow_dispatch: - # Run it every day at 6:00 UTC - schedule: - - cron: '0 6 * * *' -jobs: - updater: - runs-on: ubuntu-latest - steps: - - name: Fetch the source code - uses: actions/checkout@v3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - - name: Run the updater script - id: run_updater - run: | - # Setting up Git user - git config --global user.name 'yunohost-bot' - git config --global user.email 'yunohost-bot@users.noreply.github.com' - # Run the updater script - /bin/bash .github/workflows/updater.sh - - name: Commit changes - id: commit - if: ${{ env.PROCEED == 'true' }} - run: | - git commit -am "Upgrade to v$VERSION" - - name: Create Pull Request - id: cpr - if: ${{ env.PROCEED == 'true' }} - uses: peter-evans/create-pull-request@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - commit-message: Update to version ${{ env.VERSION }} - committer: 'yunohost-bot ' - author: 'yunohost-bot ' - signoff: false - branch: ci-auto-update-v${{ env.VERSION }} - base: testing - delete-branch: true - title: 'Upgrade to version ${{ env.VERSION }}' - body: | - Upgrade to v${{ env.VERSION }} - draft: false diff --git a/README.md b/README.md index 69c86b3..8fad7cf 100644 --- a/README.md +++ b/README.md @@ -17,11 +17,19 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Overview ## Mattermost Team Edition -A free-to-use, open source, self-hosted alternative to proprietary SaaS messaging. Team Edition is your open source “virtual office”, offering all the core productivity benefits of competing SaaS solutions. It deploys as a single Linux binary with MySQL under an MIT license. + +A free-to-use, open source, self-hosted alternative to proprietary SaaS messaging. Team Edition is your open source “virtual office”, offering all the core productivity benefits of competing SaaS solutions. It deploys as a single Linux binary with PosgreSQL under an MIT license. ## Mattermost Enterprise Edition + To explore the benefits of Mattermost’s enterprise features, you can replace the Mattermost Team Edition binary with a Mattermost Enterprise Edition binary. This version supports upgrading to Mattermost Enterprise Edition E10 or E20. +## YunoHost specific features + +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). + +Mattermost Mobile and Desktop Apps are available [here](https://mattermost.com/download/) + ## Features include: - One-to-one and group messaging, file sharing, and unlimited search history @@ -33,7 +41,6 @@ To explore the benefits of Mattermost’s enterprise features, you can replace t - Extensive integration support via webhooks, APIs, drivers, and third-party extensions - Easily scalable to dozens of users per team - Runtime profiling data and system monitoring reports -- New features and improvements released regularly **Shipped version:** 8.1.1~ynh1 @@ -42,27 +49,6 @@ To explore the benefits of Mattermost’s enterprise features, you can replace t ![Screenshot of Mattermost](./doc/screenshots/screenshot.png) -## Disclaimers / important information - -## Configuration - -* How to configure this app: From an admin panel, a plain file with SSH. -* How to change from edition version to another (Team<->Enterprise): Modify the `settings.yml` in the apps directory `/etc/yunohost/apps/mattermost_instance/settings.yml` and replace the version to wich you whant: Team or Enterprise. Update your apps and verify the *About* on your Mattermost - -## YunoHost specific features - -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). - -Mattermost Mobile and Desktop Apps are available [here](https://mattermost.com/download/) - -## Limitations - -* LDAP integration is not supported (see [#58](https://github.com/YunoHost-Apps/mattermost_ynh/issues/58)) - -## Additional information - -* This package can by installed on `ARM`, `ARM64` and `x86-64` architecture (only `x86-64` and `ARM64` if you choose to install the *Entreprise Edition*). - ## Documentation and resources * Official app website: diff --git a/README_fr.md b/README_fr.md index 28d5cb5..4fc64ba 100644 --- a/README_fr.md +++ b/README_fr.md @@ -17,12 +17,19 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po ## Vue d’ensemble ## Mattermost Team Edition + Une alternative gratuite, open source et auto-hébergée à la messagerie SaaS propriétaire. Team Edition est votre « bureau virtuel » open source, offrant tous les principaux avantages de productivité des solutions SaaS concurrentes. ## Mattermost Entreprise Edition + Pour explorer les avantages des fonctionnalités d'entreprise de Mattermost, vous pouvez remplacer le binaire Mattermost Team Edition par un binaire Mattermost Enterprise Edition. Cette version prend en charge la mise à niveau vers Mattermost Enterprise Edition E10 ou E20. -## Les fonctionnalités incluent: +## 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). + + +## Les fonctionnalités incluent : - Messagerie individuelle et de groupe, partage de fichiers et historique de recherche illimité - Messagerie, emoji et emoji personnalisés @@ -33,7 +40,6 @@ Pour explorer les avantages des fonctionnalités d'entreprise de Mattermost, vou - Prise en charge étendue de l'intégration via des webhooks, des API, des pilotes et des extensions tierces - Facilement évolutif à des dizaines d'utilisateurs par équipe - Données de profilage d'exécution et rapports de surveillance du système -- Nouvelles fonctionnalités et améliorations publiées régulièrement **Version incluse :** 8.1.1~ynh1 @@ -42,25 +48,6 @@ Pour explorer les avantages des fonctionnalités d'entreprise de Mattermost, vou ![Capture d’écran de Mattermost](./doc/screenshots/screenshot.png) -## Avertissements / informations importantes - -## Configuration - -* Comment configurer cette application : via le panneau d'administration, un fichier brut en SSH. -* Comment changer d'une version à une autre (Team<->Enterprise) : Modifiez le `settings.yml` dans le répertoire de l'application `/etc/yunohost/apps/mattermost_instance/settings.yml` et remplacez la version avec celle que vous voulez : Team ou Enterprise. Mettez à jour votre application et vérifiez dans le *À Propos* sur la console système de votre application. - -## 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). - -## Limitations - -* L'intégration LDAP n'est pas gérée (see [#58](https://github.com/YunoHost-Apps/mattermost_ynh/issues/58)) - -## Informations additionnelles - -Ce paquet peut être installé sur les architectures `ARM`, `ARM64` et `x86-64` (mais uniquement `x86-64` et `ARM64` si vous choisissez d'installer la version *Enterprise Edition*). - ## Documentations et ressources * Site officiel de l’app : diff --git a/check_process b/check_process deleted file mode 100644 index d98d3a0..0000000 --- a/check_process +++ /dev/null @@ -1,61 +0,0 @@ -;; Test with Enterprise Edition - ; Manifest - domain="domain.tld" - path="/path" - admin="john" - email="john@gmail.com" - admin_email="john@gmail.com" - password="admin!42" - admin_password="admin!42" - language="fr" - version="Enterprise" - team_display_name="Mon équipe" - is_public=1 - ; Checks - pkg_linter=1 - setup_sub_dir=1 - setup_root=1 - setup_nourl=0 - setup_private=1 - setup_public=1 - upgrade=1 - # 7.2.0 - upgrade=1 from_commit=738ba505f581ddd72889c889dcb34406250fea35 - # 7.3.0 - upgrade=1 from_commit=1677cb9fa9d95ab788a6acd5b310b09c7d2ab7df - backup_restore=1 - multi_instance=1 - port_already_use=0 - change_url=1 -;; Test with Team Edition - ; Manifest - domain="domain.tld" - path="/path" - admin="john" - 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 - ; Checks - setup_sub_dir=1 - setup_root=1 - setup_private=1 - setup_public=1 - upgrade=1 - # 7.2.0 - upgrade=1 from_commit=738ba505f581ddd72889c889dcb34406250fea35 - # 7.3.0 - upgrade=1 from_commit=1677cb9fa9d95ab788a6acd5b310b09c7d2ab7df -;;; Options -Email=kemenaran@gmail.com -Notification=none -;;; Upgrade options - ; commit=738ba505f581ddd72889c889dcb34406250fea35 - name=7.2.0 - ; commit=1677cb9fa9d95ab788a6acd5b310b09c7d2ab7df - name=7.3.0 - \ No newline at end of file diff --git a/conf/config.json b/conf/config.json index 78ee9b4..eac81e0 100644 --- a/conf/config.json +++ b/conf/config.json @@ -61,6 +61,7 @@ "EnableGifPicker": true, "GfycatAPIKey": "2_KtH_W5", "GfycatAPISecret": "3wLVZPiswc3DnaiaFoLkDvB4X0IV6CpMkj4tf2inJRsBY6-FnkT08zGmppWFgeof", + "GiphySdkKey": "", "EnableCustomEmoji": true, "EnableEmojiPicker": true, "PostEditTimeLimit": -1, @@ -89,7 +90,12 @@ "EnableSVGs": false, "EnableLatex": false, "EnableInlineLatex": true, - "PostPriority": false, + "PostPriority": true, + "AllowPersistentNotifications": true, + "AllowPersistentNotificationsForGuests": false, + "PersistentNotificationIntervalMinutes": 5, + "PersistentNotificationMaxCount": 6, + "PersistentNotificationMaxRecipients": 5, "EnableAPIChannelDeletion": false, "EnableLocalMode": true, "LocalModeSocketLocation": "/var/run/__APP__/mattermost_local.socket", @@ -148,7 +154,8 @@ "QueryTimeout": 30, "DisableDatabaseSearch": false, "MigrationsStatementTimeoutSeconds": 100000, - "ReplicaLagSettings": [] + "ReplicaLagSettings": [], + "ReplicaMonitorIntervalSeconds": 5 }, "LogSettings": { "EnableConsole": true, @@ -163,6 +170,7 @@ "EnableDiagnostics": true, "VerboseDiagnostics": false, "EnableSentry": true, + "AdvancedLoggingJSON": {}, "AdvancedLoggingConfig": "" }, "ExperimentalAuditSettings": { @@ -173,6 +181,7 @@ "FileMaxBackups": 0, "FileCompress": false, "FileMaxQueueSize": 1000, + "AdvancedLoggingJSON": {}, "AdvancedLoggingConfig": "" }, "NotificationLogSettings": { @@ -184,6 +193,7 @@ "FileLevel": "INFO", "FileJson": true, "FileLocation": "/var/log/__APP__", + "AdvancedLoggingJSON": {}, "AdvancedLoggingConfig": "" }, "PasswordSettings": { @@ -191,7 +201,8 @@ "Lowercase": false, "Number": false, "Uppercase": false, - "Symbol": false + "Symbol": false, + "EnableForgotLink": true }, "FileSettings": { "EnableFileAttachments": true, @@ -201,7 +212,7 @@ "MaxImageResolution": 33177600, "MaxImageDecoderConcurrency": -1, "DriverName": "local", - "Directory": "__DATA_PATH__", + "Directory": "__DATA_DIR__", "EnablePublicLink": false, "ExtractContent": false, "ArchiveRecursion": false, @@ -217,7 +228,22 @@ "AmazonS3SignV2": false, "AmazonS3SSE": false, "AmazonS3Trace": false, - "AmazonS3RequestTimeoutMilliseconds": 30000 + "AmazonS3RequestTimeoutMilliseconds": 30000, + "DedicatedExportStore": false, + "ExportDriverName": "local", + "ExportDirectory": "./data/", + "ExportAmazonS3AccessKeyId": "", + "ExportAmazonS3SecretAccessKey": "", + "ExportAmazonS3Bucket": "", + "ExportAmazonS3PathPrefix": "", + "ExportAmazonS3Region": "", + "ExportAmazonS3Endpoint": "s3.amazonaws.com", + "ExportAmazonS3SSL": true, + "ExportAmazonS3SignV2": false, + "ExportAmazonS3SSE": false, + "ExportAmazonS3Trace": false, + "ExportAmazonS3RequestTimeoutMilliseconds": 30000, + "ExportAmazonS3PresignExpiresSeconds": 21600 }, "EmailSettings": { "EnableSignUpWithEmail": true, @@ -249,8 +275,7 @@ "EmailNotificationContentsType": "full", "LoginButtonColor": "#0000", "LoginButtonBorderColor": "#2389D7", - "LoginButtonTextColor": "#2389D7", - "EnableInactivityEmail": true + "LoginButtonTextColor": "#2389D7" }, "RateLimitSettings": { "Enable": false, @@ -266,11 +291,12 @@ "ShowFullName": true }, "SupportSettings": { - "TermsOfServiceLink": "https://mattermost.com/terms-of-use/", - "PrivacyPolicyLink": "https://mattermost.com/privacy-policy/", - "AboutLink": "https://docs.mattermost.com/about/product.html/", - "HelpLink": "https://mattermost.com/default-help/", - "ReportAProblemLink": "https://mattermost.com/default-report-a-problem/", + "TermsOfServiceLink": "https://mattermost.com/pl/terms-of-use/", + "PrivacyPolicyLink": "https://mattermost.com/pl/privacy-policy/", + "AboutLink": "https://mattermost.com/pl/about-mattermomst", + "HelpLink": "https://mattermost.com/pl/help/", + "ReportAProblemLink": "https://mattermost.com/pl/report-a-bug", + "ForgotPasswordLink": "", "SupportEmail": "", "CustomTermsOfServiceEnabled": false, "CustomTermsOfServiceReAcceptancePeriod": 365, @@ -430,9 +456,9 @@ "mmauth://", "mmauthbeta://" ], - "AppDownloadLink": "https://mattermost.com/download/#mattermostApps", - "AndroidAppDownloadLink": "https://mattermost.com/mattermost-android-app/", - "IosAppDownloadLink": "https://mattermost.com/mattermost-ios-app/" + "AppDownloadLink": "https://mattermost.com/pl/download-apps", + "AndroidAppDownloadLink": "https://mattermost.com/pl/android-app/", + "IosAppDownloadLink": "https://mattermost.com/pl/ios-app/" }, "ClusterSettings": { "Enable": false, @@ -464,8 +490,9 @@ "UseNewSAMLLibrary": false, "EnableSharedChannels": false, "EnableRemoteClusterService": false, - "EnableAppBar": false, - "PatchPluginsReactDOM": false + "DisableAppBar": false, + "DisableRefetchingOnBrowserFocus": false, + "DelayChannelAutocomplete": false }, "AnalyticsSettings": { "MaxUsersForStatistics": 2500 @@ -491,7 +518,11 @@ "BatchSize": 10000, "RequestTimeoutSeconds": 30, "SkipTLSVerification": false, - "Trace": "" + "CA": "", + "ClientCert": "", + "ClientKey": "", + "Trace": "", + "IgnoredPurgeIndexes": "" }, "BleveSettings": { "IndexDir": "", @@ -508,7 +539,8 @@ "FileRetentionDays": 365, "BoardsRetentionDays": 365, "DeletionJobStartTime": "02:00", - "BatchSize": 3000 + "BatchSize": 3000, + "TimeBetweenBatchesMilliseconds": 100 }, "MessageExportSettings": { "EnableExport": false, @@ -531,9 +563,7 @@ "CleanupJobsThresholdDays": -1, "CleanupConfigThresholdDays": -1 }, - "ProductSettings": { - "EnablePublicSharedBoards": false - }, + "ProductSettings": {}, "PluginSettings": { "Enable": true, "EnableUploads": false, @@ -543,18 +573,12 @@ "ClientDirectory": "./client/plugins", "Plugins": {}, "PluginStates": { - "com.mattermost.apps": { - "Enable": true - }, "com.mattermost.calls": { "Enable": true }, "com.mattermost.nps": { "Enable": true }, - "focalboard": { - "Enable": true - }, "playbooks": { "Enable": true } @@ -573,6 +597,7 @@ }, "GuestAccountsSettings": { "Enable": false, + "HideTags": false, "AllowEmailAccounts": true, "EnforceMultifactorAuthentication": false, "RestrictCreationToDomains": "" @@ -584,8 +609,9 @@ "RemoteImageProxyOptions": "" }, "CloudSettings": { - "CWSURL": "https://customers.mattermost.com", - "CWSAPIURL": "https://portal.internal.prod.cloud.mattermost.com" + "CWSURL": "https://portal.test.cloud.mattermost.com", + "CWSAPIURL": "https://api.internal.test.cloud.mattermost.com", + "CWSMock": false }, "FeatureFlags": { "TestFeature": "off", @@ -596,25 +622,26 @@ "PluginApps": "", "PluginFocalboard": "", "PluginCalls": "", - "PermalinkPreviews": true, + "PermalinkPreviews": false, "CallsEnabled": true, "BoardsFeatureFlags": "", "BoardsDataRetention": false, "NormalizeLdapDNs": false, - "EnableInactivityCheckJob": true, - "UseCaseOnboarding": true, "GraphQL": false, - "InsightsEnabled": true, + "InsightsEnabled": false, "CommandPalette": false, - "BoardsProduct": false, - "SendWelcomePost": true, - "WorkTemplate": false, - "PostPriority": true, + "PostPriority": false, + "WysiwygEditor": false, "PeopleProduct": false, - "AnnualSubscription": false, "ReduceOnBoardingTaskList": false, + "OnboardingAutoShowLinkedBoard": false, "ThreadsEverywhere": false, - "GlobalDrafts": true + "GlobalDrafts": true, + "OnboardingTourTips": true, + "DeprecateCloudFree": false, + "CloudReverseTrial": false, + "EnableExportDirectDownload": false, + "DataRetentionConcurrencyEnabled": true }, "ImportSettings": { "Directory": "./import", diff --git a/conf/enterprise_amd64.src b/conf/enterprise_amd64.src deleted file mode 100644 index 3a4e796..0000000 --- a/conf/enterprise_amd64.src +++ /dev/null @@ -1,6 +0,0 @@ -SOURCE_URL=https://releases.mattermost.com/8.1.1/mattermost-enterprise-8.1.1-linux-amd64.tar.gz -SOURCE_SUM=5ce9090089601c5c7746768c9799cda8069b6116468d0377d603cd9116810911 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=mattermost.tar.gz diff --git a/conf/enterprise_arm64.src b/conf/enterprise_arm64.src deleted file mode 100644 index 08c0e5b..0000000 --- a/conf/enterprise_arm64.src +++ /dev/null @@ -1,6 +0,0 @@ -SOURCE_URL=https://releases.mattermost.com/8.1.1/mattermost-enterprise-8.1.1-linux-arm64.tar.gz -SOURCE_SUM=bca0bb54f257680fadbd3d568d870d6c1cd1352744dda419d71a07be82b7d2ca -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=mattermost.tar.gz diff --git a/conf/systemd.service b/conf/systemd.service index 1215b5d..735fe4b 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -1,5 +1,5 @@ [Unit] -Description=Mattermost +Description=Mattermost: collaboration platform After=network.target Requires=postgresql.service @@ -7,11 +7,11 @@ Requires=postgresql.service Type=notify User=__APP__ Group=__APP__ -ExecStart=__FINALPATH__/bin/mattermost +ExecStart=__INSTALL_DIR__/bin/mattermost TimeoutStartSec=3600 Restart=always RestartSec=10 -WorkingDirectory=__FINALPATH__ +WorkingDirectory=__INSTALL_DIR__ RuntimeDirectory=__APP__ LimitNOFILE=49152 diff --git a/conf/team_amd64.src b/conf/team_amd64.src deleted file mode 100644 index a830590..0000000 --- a/conf/team_amd64.src +++ /dev/null @@ -1,6 +0,0 @@ -SOURCE_URL=https://releases.mattermost.com/8.1.1/mattermost-team-8.1.1-linux-amd64.tar.gz -SOURCE_SUM=1ca6b77cc34be7bd2cea57f9dfa064e19c5556ab59c5e24e93dfdf6d0dc39603 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=mattermost.tar.gz diff --git a/conf/team_arm64.src b/conf/team_arm64.src deleted file mode 100644 index 8659abb..0000000 --- a/conf/team_arm64.src +++ /dev/null @@ -1,6 +0,0 @@ -SOURCE_URL=https://releases.mattermost.com/8.1.1/mattermost-team-8.1.1-linux-arm64.tar.gz -SOURCE_SUM=0ca10276b140e814e352e7f5538de2de9545e11b4b2f3281159c5390f16c2f34 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=mattermost.tar.gz \ No newline at end of file diff --git a/conf/team_armhf.src b/conf/team_armhf.src deleted file mode 100644 index 1caa889..0000000 --- a/conf/team_armhf.src +++ /dev/null @@ -1,6 +0,0 @@ -SOURCE_URL=https://github.com/SmartHoneybee/ubiquitous-memory/releases/download/v7.5.2/mattermost-v7.5.2-linux-arm.tar.gz -SOURCE_SUM=b26a4b676ee92ac848fa2993aa67559238ba7d8c1d0e6f7ffdd79ad8fb4942f3 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=mattermost.tar.gz diff --git a/doc/ADMIN.md b/doc/ADMIN.md new file mode 100644 index 0000000..9168184 --- /dev/null +++ b/doc/ADMIN.md @@ -0,0 +1 @@ +You can change the istalled edition (Team <-> Enterprise) by modifying the setting file `__DATA_DIR__/__APP__/settings.yml` and replace the version to wich you want: Team or Enterprise. Update your apps and verify the *About* on your Mattermost diff --git a/doc/ADMIN_fr.md b/doc/ADMIN_fr.md new file mode 100644 index 0000000..0ea6ca1 --- /dev/null +++ b/doc/ADMIN_fr.md @@ -0,0 +1 @@ +Vous pouvez changer l'édition installée (Team <-> Enterprise) en éditant le fichier de configuration `__DATA_DIR__/__APP__/settings.yml` et remplacez la version avec celle que vous voulez : Team ou Enterprise. Mettez à jour votre application et vérifiez dans le *À Propos* sur la console système de votre application. diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md index db6e3ae..5ff53f4 100644 --- a/doc/DESCRIPTION.md +++ b/doc/DESCRIPTION.md @@ -1,9 +1,17 @@ ## Mattermost Team Edition -A free-to-use, open source, self-hosted alternative to proprietary SaaS messaging. Team Edition is your open source “virtual office”, offering all the core productivity benefits of competing SaaS solutions. It deploys as a single Linux binary with MySQL under an MIT license. + +A free-to-use, open source, self-hosted alternative to proprietary SaaS messaging. Team Edition is your open source “virtual office”, offering all the core productivity benefits of competing SaaS solutions. It deploys as a single Linux binary with PosgreSQL under an MIT license. ## Mattermost Enterprise Edition + To explore the benefits of Mattermost’s enterprise features, you can replace the Mattermost Team Edition binary with a Mattermost Enterprise Edition binary. This version supports upgrading to Mattermost Enterprise Edition E10 or E20. +## YunoHost specific features + +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). + +Mattermost Mobile and Desktop Apps are available [here](https://mattermost.com/download/) + ## Features include: - One-to-one and group messaging, file sharing, and unlimited search history @@ -15,4 +23,3 @@ To explore the benefits of Mattermost’s enterprise features, you can replace t - Extensive integration support via webhooks, APIs, drivers, and third-party extensions - Easily scalable to dozens of users per team - Runtime profiling data and system monitoring reports -- New features and improvements released regularly diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md index 3dd7b3d..bef60be 100644 --- a/doc/DESCRIPTION_fr.md +++ b/doc/DESCRIPTION_fr.md @@ -1,10 +1,17 @@ ## Mattermost Team Edition + Une alternative gratuite, open source et auto-hébergée à la messagerie SaaS propriétaire. Team Edition est votre « bureau virtuel » open source, offrant tous les principaux avantages de productivité des solutions SaaS concurrentes. ## Mattermost Entreprise Edition + Pour explorer les avantages des fonctionnalités d'entreprise de Mattermost, vous pouvez remplacer le binaire Mattermost Team Edition par un binaire Mattermost Enterprise Edition. Cette version prend en charge la mise à niveau vers Mattermost Enterprise Edition E10 ou E20. -## Les fonctionnalités incluent: +## 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). + + +## Les fonctionnalités incluent : - Messagerie individuelle et de groupe, partage de fichiers et historique de recherche illimité - Messagerie, emoji et emoji personnalisés @@ -15,4 +22,3 @@ Pour explorer les avantages des fonctionnalités d'entreprise de Mattermost, vou - Prise en charge étendue de l'intégration via des webhooks, des API, des pilotes et des extensions tierces - Facilement évolutif à des dizaines d'utilisateurs par équipe - Données de profilage d'exécution et rapports de surveillance du système -- Nouvelles fonctionnalités et améliorations publiées régulièrement diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md deleted file mode 100644 index e0fa03b..0000000 --- a/doc/DISCLAIMER.md +++ /dev/null @@ -1,18 +0,0 @@ -## Configuration - -* How to configure this app: From an admin panel, a plain file with SSH. -* How to change from edition version to another (Team<->Enterprise): Modify the `settings.yml` in the apps directory `/etc/yunohost/apps/mattermost_instance/settings.yml` and replace the version to wich you whant: Team or Enterprise. Update your apps and verify the *About* on your Mattermost - -## YunoHost specific features - -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). - -Mattermost Mobile and Desktop Apps are available [here](https://mattermost.com/download/) - -## Limitations - -* LDAP integration is not supported (see [#58](https://github.com/YunoHost-Apps/mattermost_ynh/issues/58)) - -## Additional information - -* This package can by installed on `ARM`, `ARM64` and `x86-64` architecture (only `x86-64` and `ARM64` if you choose to install the *Entreprise Edition*). diff --git a/doc/DISCLAIMER_fr.md b/doc/DISCLAIMER_fr.md deleted file mode 100644 index cd3857e..0000000 --- a/doc/DISCLAIMER_fr.md +++ /dev/null @@ -1,16 +0,0 @@ -## Configuration - -* Comment configurer cette application : via le panneau d'administration, un fichier brut en SSH. -* Comment changer d'une version à une autre (Team<->Enterprise) : Modifiez le `settings.yml` dans le répertoire de l'application `/etc/yunohost/apps/mattermost_instance/settings.yml` et remplacez la version avec celle que vous voulez : Team ou Enterprise. Mettez à jour votre application et vérifiez dans le *À Propos* sur la console système de votre application. - -## 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). - -## Limitations - -* L'intégration LDAP n'est pas gérée (see [#58](https://github.com/YunoHost-Apps/mattermost_ynh/issues/58)) - -## Informations additionnelles - -Ce paquet peut être installé sur les architectures `ARM`, `ARM64` et `x86-64` (mais uniquement `x86-64` et `ARM64` si vous choisissez d'installer la version *Enterprise Edition*). diff --git a/manifest.json b/manifest.json deleted file mode 100644 index fc56afb..0000000 --- a/manifest.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "name": "Mattermost", - "id": "mattermost", - "packaging_format": 1, - "description": { - "en": "Open source collaboration platform built for developers", - "fr": "Plateforme de collaboration open source conçue pour les développeurs" - }, - "version": "8.1.1~ynh1", - "url": "http://www.mattermost.org/", - "upstream": { - "license": "GPL-3.0-only", - "website": "http://www.mattermost.org/", - "admindoc": "https://docs.mattermost.com/guides/deployment.html", - "userdoc": "https://docs.mattermost.com/guides/messaging.html", - "code": "https://github.com/mattermost/mattermost-server", - "cpe": "cpe:2.3:a:mattermost:mattermost" - }, - "license": "GPL-3.0-only", - "maintainer": { - "name": "pmorinerie", - "email": "kemenaran@gmail.com" - }, - "multi_instance": true, - "services": [ - "nginx", - "mysql" - ], - "requirements": { - "yunohost": ">= 11.1.6" - }, - "arguments": { - "install": [ - { - "name": "domain", - "type": "domain" - }, - { - "name": "path", - "type": "path", - "example": "/mattermost", - "default": "/mattermost" - }, - { - "name": "is_public", - "type": "boolean", - "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 l’interface d’administration." - }, - "default": true - }, - { - "name": "admin", - "type": "user" - }, - { - "name": "password", - "type": "password" - }, - { - "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", - "ask": { - "en": "Choose the language of the chat for the admin", - "fr": "Choissisez la langue utilisée pour l'administrateur" - }, - "choices": [ - "de", - "en", - "es", - "fr", - "it", - "pt" - ], - "default": "en" - }, - { - "name": "team_display_name", - "type": "string", - "ask": { - "en": "Choose a Team name", - "fr": "Choisissez le nom de l’équipe" - }, - "example": "Team", - "default": "Team" - } - ] - } -} diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..b662fe1 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,104 @@ +packaging_format = 2 + +id = "mattermost" +name = "Mattermost" +description.en = "Open source collaboration platform built for developers" +description.fr = "Plateforme de collaboration open source conçue pour les développeurs" + +version = "8.1.1~ynh1" + +maintainers = ["pmorinerie"] + +[upstream] +license = "GPL-3.0-only" +website = "http://www.mattermost.org/" +admindoc = "https://docs.mattermost.com/guides/deployment.html" +userdoc = "https://docs.mattermost.com/guides/messaging.html" +code = "https://github.com/mattermost/mattermost-server" + +[integration] +yunohost = ">= 11.2" +architectures = ["amd64", "armhf", "arm64"] +multi_instance = true +ldap = false +sso = false +disk = "50M" +ram.build = "350M" +ram.runtime = "50M" + +[install] + [install.domain] + type = "domain" + + [install.path] + type = "path" + default = "/mattermost" + + [install.init_main_permission] + help.en = "If visitors selected, Mattermost will be accessible by users without a YunoHost account. This can be changed later via the webadmin." + help.fr = "Si « Visiteurs » est sélectionné, Mattermost sera accessible même par les utilisateurs n’ayant pas de compte YunoHost. Vous pourrez changer ce réglage plus tard dans l’interface d’administration." + type = "group" + default = "visitors" + + [install.admin] + type = "user" + + [install.password] + type = "password" + + [install.version] + ask.en = "Choose the version you want to install" + ask.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 and ARM64 support)" + help.fr = "Utilisez Team Edition pour la version open-source (prise en charge ARM, ARM64 et x86-64) ou Édition Enterprise si vous souhaitez utiliser une licence (prise en charge x86-64 et ARM64)" + type = "select" + choices = ["Enterprise", "Team"] + default = "Team" + + [install.language] + ask.en = "Choose the language of the chat for the admin" + ask.fr = "Choissisez la langue utilisée par le compte administrateur" + type = "select" + choices = ["de", "en", "es", "fr", "it", "pt"] + default = "en" + + [install.team_display_name] + ask.en = "Choose a Team name" + ask.fr = "Choisissez le nom de l’équipe" + type = "string" + example = "Team" + default = "Team" + +[resources] + [resources.sources] + + [resources.sources.main] + amd64.url = "https://releases.mattermost.com/8.1.1/mattermost-team-8.1.1-linux-amd64.tar.gz" + amd64.sha256 = "1ca6b77cc34be7bd2cea57f9dfa064e19c5556ab59c5e24e93dfdf6d0dc39603" + arm64.url = "https://releases.mattermost.com/8.1.1/mattermost-team-8.1.1-linux-arm64.tar.gz" + arm64.sha256 = "0ca10276b140e814e352e7f5538de2de9545e11b4b2f3281159c5390f16c2f34" + armhf.url = "https://github.com/SmartHoneybee/ubiquitous-memory/releases/download/v7.5.2/mattermost-v7.5.2-linux-arm.tar.gz" + armhf.sha256 = "b26a4b676ee92ac848fa2993aa67559238ba7d8c1d0e6f7ffdd79ad8fb4942f3" + + [resources.sources.enterprise] + amd64.url = "https://releases.mattermost.com/8.1.1/mattermost-enterprise-8.1.1-linux-amd64.tar.gz" + amd64.sha256 = "5ce9090089601c5c7746768c9799cda8069b6116468d0377d603cd9116810911" + arm64.url = "https://releases.mattermost.com/8.1.1/mattermost-enterprise-8.1.1-linux-arm64.tar.gz" + arm64.sha256 = "bca0bb54f257680fadbd3d568d870d6c1cd1352744dda419d71a07be82b7d2ca" + + [resources.system_user] + + [resources.install_dir] + + [resources.data_dir] + + [resources.ports] + + [resources.permissions] + main.url = "/" + + [resources.apt] + packages = "postgresql, pgloader" + + [resources.database] + type = "postgresql" diff --git a/scripts/_common.sh b/scripts/_common.sh index dce1e80..0d8f29f 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,9 +4,6 @@ # COMMON VARIABLES #================================================= -# dependencies used by the app -pkg_dependencies="postgresql postgresql-contrib pgloader" - #================================================= # PERSONAL HELPERS #================================================= @@ -15,27 +12,24 @@ mariadb-to-pg() { ynh_print_info --message="Migrating to PostgreSQL database..." + # Retrieve MySQL user and password mysqlpwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) - # In old instance db_user is `mmuser` mysql_db_user="$db_user" if ynh_mysql_connect_as --user="mmuser" --password="$mysqlpwd" 2> /dev/null <<< ";"; then + # On old instances db_user is `mmuser` mysql_db_user="mmuser" fi - # Initialize PostgreSQL database - ynh_psql_test_if_first_run - ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$mysqlpwd - psqlpwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) - - # Configure the new database and run Mattermost in order to create tables - ynh_write_var_in_file --file="$final_path/config/config.json" --key="DriverName" --value="postgres" --after="SqlSettings" - ynh_write_var_in_file --file="$final_path/config/config.json" --key="DataSource" --value="postgres://$db_user:$psqlpwd@localhost:5432/$db_name?sslmode=disable&connect_timeout=10" --after="SqlSettings" - cat "$final_path/config/config.json" - pushd $final_path + # The PostgreSQL database has already been created by Yunohost before running the script. + # Configure the new database and run Mattermost in order to create tables. + ynh_write_var_in_file --file="$install_dir/config/config.json" --key="DriverName" --value="postgres" --after="SqlSettings" + ynh_write_var_in_file --file="$install_dir/config/config.json" --key="DataSource" --value="postgres://$db_user:$db_pwd@localhost:5432/$db_name?sslmode=disable&connect_timeout=10" --after="SqlSettings" + cat "$install_dir/config/config.json" + pushd $install_dir ynh_systemd_action --service_name="$app" --action="stop" set +e - sudo -u mattermost timeout --preserve-status 300 "./bin/mattermost" + sudo -u $app timeout --preserve-status 300 "./bin/mattermost" if [ "$?" != "0" ] && [ "$?" != "143" ] ; then ynh_die --message="Failed to run Mattermost to create PostgreSQL database tables" --ret_code=1 fi @@ -63,7 +57,7 @@ mariadb-to-pg() { cat < $tmpdir/commands.load LOAD DATABASE FROM mysql://$mysql_db_user:$mysqlpwd@127.0.0.1:3306/$db_name - INTO postgresql://$db_user:$psqlpwd@127.0.0.1:5432/$db_name + INTO postgresql://$db_user:$db_pwd@127.0.0.1:5432/$db_name WITH include no drop, truncate, create no tables, create no indexes, preserve index names, no foreign keys, @@ -85,16 +79,15 @@ EOT ynh_psql_execute_as_root --sql='CREATE INDEX idx_fileinfo_content_txt ON public.fileinfo USING gin (to_tsvector('\''english'\''::regconfig, content))' --database=$db_name ynh_psql_execute_as_root --sql='CREATE INDEX idx_posts_message_txt ON public.posts USING gin (to_tsvector('\''english'\''::regconfig, (message)::text));' --database=$db_name - if ynh_compare_current_package_version --comparison eq --version 7.3.0~ynh1 then # There is a problem with version 7.3.0 and the database migration. # More information here: https://forum.mattermost.com/t/migrating-from-mariadb-to-postgresql-db/14194/6 ynh_psql_execute_as_root --sql="DELETE FROM db_migrations WHERE version=92;" --database=$db_name fi + # Remove the MariaDB database ynh_mysql_remove_db --db_user=$mysql_db_user --db_name=$db_name - } #================================================= diff --git a/scripts/backup b/scripts/backup index 7aa0fef..efc7f5d 100755 --- a/scripts/backup +++ b/scripts/backup @@ -6,28 +6,6 @@ source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - ynh_clean_check_starting -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_print_info --message="Loading installation settings..." - -app=$YNH_APP_INSTANCE_NAME - -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -domain=$(ynh_app_setting_get --app=$app --key=domain) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -data_path=$(ynh_app_setting_get --app=$app --key=data_path) - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= @@ -37,13 +15,13 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$final_path" +ynh_backup --src_path="$install_dir" #================================================= # BACKUP THE APP DATA #================================================= -ynh_backup --src_path="$data_path" --is_big +ynh_backup --src_path="$data_dir" --is_big #================================================= # BACKUP THE NGINX CONFIGURATION diff --git a/scripts/change_url b/scripts/change_url index 81f256a..06528f0 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -9,60 +9,6 @@ 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 #================================================= @@ -70,36 +16,14 @@ fi #================================================= 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" +ynh_systemd_action --service_name=$app --action=stop --log_path="systemd" #================================================= # 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 +ynh_change_url_nginx_config #================================================= # EDIT MATTERMOST CONFIG @@ -109,10 +33,10 @@ fi 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_replace_string --match_string="\"SiteURL\": \".*\"" --replace_string="\"SiteURL\": \"https://${new_domain}${new_path}\"" --target_file="$install_dir/config/config.json" +ynh_replace_string --match_string="\"FeedbackEmail\": \".*\"" --replace_string="\"FeedbackEmail\": \"no-reply@${new_domain}\"" --target_file="$install_dir/config/config.json" -ynh_store_file_checksum --file="$final_path/config/config.json" +ynh_store_file_checksum --file="$install_dir/config/config.json" #================================================= # GENERIC FINALISATION @@ -124,13 +48,6 @@ 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 #================================================= diff --git a/scripts/install b/scripts/install index 2416b9c..00c73b0 100644 --- a/scripts/install +++ b/scripts/install @@ -9,136 +9,22 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - ynh_clean_check_starting -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# RETRIEVE ARGUMENTS FROM THE MANIFEST -#================================================= - -domain=$YNH_APP_ARG_DOMAIN -path_url=$YNH_APP_ARG_PATH -is_public=$YNH_APP_ARG_IS_PUBLIC -admin=$YNH_APP_ARG_ADMIN -email=$(ynh_user_get_info --username=$admin --key=mail) -password=$YNH_APP_ARG_PASSWORD -language=$YNH_APP_ARG_LANGUAGE -team_display_name=$YNH_APP_ARG_TEAM_DISPLAY_NAME -version=$YNH_APP_ARG_VERSION - -app=$YNH_APP_INSTANCE_NAME - -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= -ynh_script_progression --message="Validating installation parameters..." --weight=1 - -final_path=/var/www/$app -test ! -e "$final_path" || ynh_die --message="This path already contains a folder" - -# Register (book) web path -ynh_webpath_register --app=$app --domain=$domain --path_url=$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=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 -#================================================= -ynh_script_progression --message="Finding an available port..." --weight=3 - -# Find an available port -port=$(ynh_find_port --port=8065) -ynh_app_setting_set --app=$app --key=port --value=$port - -#================================================= -# INSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Installing dependencies..." --weight=10 - -ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --weight=3 - -# Create a system user -ynh_system_user_create --username=$app --home_dir="$final_path" - -#================================================= -# CREATE A DATABASE -#================================================= -ynh_script_progression --message="Creating a database..." --weight=10 - -db_name=$(ynh_sanitize_dbid --db_name=$app) -db_user=$db_name -ynh_app_setting_set --app=$app --key=db_name --value=$db_name -ynh_psql_test_if_first_run -ynh_psql_setup_db --db_user=$db_user --db_name=$db_name - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=3 -ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src if [ "$version" = "Enterprise" ]; then # Get Enterprise binary path - ynh_setup_source --dest_dir="$final_path" --source_id="enterprise_$YNH_ARCH" + ynh_setup_source --dest_dir="$install_dir" --source_id="enterprise" elif [ "$version" = "Team" ]; then # Get Team binary path - ynh_setup_source --dest_dir="$final_path" --source_id="team_$YNH_ARCH" + ynh_setup_source --dest_dir="$install_dir" --source_id="main" fi -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" - -#================================================= -# CREATE DIRECTORY FOR DATA -#================================================= -ynh_script_progression --message="Creating the data directory..." --weight=1 - -data_path=/home/yunohost.app/$app -ynh_app_setting_set --app=$app --key=data_path --value=$data_path - -mkdir -p $data_path - -chmod 750 "$data_path" -chmod -R o-rwx "$data_path" -chown -R $app:www-data "$data_path" - -#================================================= -# HANDLE LOG FILES AND LOGROTATE -#================================================= -ynh_script_progression --message="Configuring log rotation..." --weight=1 - -# Create log directory -mkdir -p /var/log/$app -chown $app -R "/var/log/$app" - -# Setup logrotate -ynh_use_logrotate +chown -R $app:www-data "$install_dir" #================================================= # EDIT MATTERMOST CONFIG @@ -148,34 +34,30 @@ ynh_use_logrotate ynh_script_progression --message="Modifying a config file..." --weight=3 smtp_user_pwd=$(ynh_string_random --length=24) -url=https://$domain$path_url -db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +url=https://$domain$path -ynh_add_config --template="../conf/config.json" --destination="$final_path/config/config.json" +ynh_add_config --template="../conf/config.json" --destination="$install_dir/config/config.json" #================================================= -# NGINX CONFIGURATION +# SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Configuring NGINX web server..." --weight=2 +ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Configuring a systemd service..." --weight=2 - # Create a dedicated systemd config ynh_add_systemd_config -#================================================= -# 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" +# Create log directory +mkdir -p /var/log/$app +chown $app -R "/var/log/$app" + +# Setup logrotate +ynh_use_logrotate + #================================================= # START SYSTEMD SERVICE #================================================= @@ -190,39 +72,20 @@ ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_ ynh_script_progression --message="Create the first administrator and team..." --weight=1 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) -bin_mmctl="$final_path/bin/mmctl" +bin_mmctl="$install_dir/bin/mmctl" +email=$(ynh_user_get_info --username=$admin --key=mail) -# mmctl is not packaged with ARM versions yet -if [[ -f "$bin_mmctl" ]]; then - export MMCTL_LOCAL=true - export MMCTL_LOCAL_SOCKET_PATH="/var/run/${app}/mattermost_local.socket" +export MMCTL_LOCAL=true +export MMCTL_LOCAL_SOCKET_PATH="/var/run/${app}/mattermost_local.socket" - ynh_exec_warn_less sudo --preserve-env -u $app "$bin_mmctl" user create --username "$admin" --email "$email" --password "$password" --locale "$language" --email-verified --system-admin - ynh_exec_warn_less sudo --preserve-env -u $app "$bin_mmctl" team create --name "$team_name" --display_name "$team_display_name" --email "$email" - ynh_exec_warn_less sudo --preserve-env -u $app "$bin_mmctl" team users add "$team_name" "$admin" -fi +ynh_exec_warn_less sudo --preserve-env -u $app "$bin_mmctl" user create --username "$admin" --email "$email" --password "$password" --locale "$language" --email-verified --system-admin +ynh_exec_warn_less sudo --preserve-env -u $app "$bin_mmctl" team create --name "$team_name" --display_name "$team_display_name" --email "$email" +ynh_exec_warn_less sudo --preserve-env -u $app "$bin_mmctl" team users add "$team_name" "$admin" # Disable mmctl passwordless access -ynh_replace_string '"EnableLocalMode": true' '"EnableLocalMode": false' "$final_path/config/config.json" +ynh_replace_string '"EnableLocalMode": true' '"EnableLocalMode": false' "$install_dir/config/config.json" ynh_systemd_action --service_name=$app --action=restart --log_path=systemd --line_match="Started Mattermost" -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Configuring permissions..." --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 #================================================= diff --git a/scripts/remove b/scripts/remove index aa3f444..70d4055 100755 --- a/scripts/remove +++ b/scripts/remove @@ -10,23 +10,11 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# LOAD SETTINGS +# REMOVE SYSTEM CONFIGURATIONS #================================================= - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -port=$(ynh_app_setting_get --app=$app --key=port) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -data_path=$(ynh_app_setting_get --app=$app --key=data_path) - -#================================================= -# STANDARD REMOVE -#================================================= -# REMOVE SERVICE FROM ADMIN PANEL +# REMOVE SYSTEMD SERVICE #================================================= +ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 # Remove the service from the list of services known by YunoHost (added from `yunohost service add`) if ynh_exec_warn_less yunohost service status $app >/dev/null @@ -35,80 +23,27 @@ then yunohost service remove $app fi -#================================================= -# STOP AND REMOVE SERVICE -#================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1 - -# Remove the dedicated systemd config +# Stop the server, and remove the dedicated systemd config ynh_remove_systemd_config -#================================================= -# REMOVE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Removing logrotate configuration..." --weight=1 - # Remove the app-specific logrotate config ynh_remove_logrotate -#================================================= -# REMOVE THE DATABASE -#================================================= -ynh_script_progression --message="Removing the database..." --weight=2 - -# Remove a database if it exists, along with the associated user -ynh_psql_remove_db --db_user=$db_user --db_name=$db_name - -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies..." --weight=3 - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies - -#================================================= -# REMOVE APP MAIN DIR -#================================================= -ynh_script_progression --message="Removing $app main directory..." --weight=6 - -# Remove the app directory securely -ynh_secure_remove --file="$final_path" - -#================================================= -# REMOVE DATA DIR -#================================================= - -# Remove the data directory if --purge option is used -if [ "${YNH_APP_PURGE:-0}" -eq 1 ] -then - ynh_script_progression --message="Removing app data directory..." --weight=1 - ynh_secure_remove --file="$data_path" -fi - -#================================================= -# REMOVE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --weight=5 - # Remove the dedicated NGINX config ynh_remove_nginx_config -#================================================= -# SPECIFIC REMOVE -#================================================= -# REMOVE VARIOUS FILES -#================================================= -ynh_script_progression --message="Removing various files..." --weight=1 - +# Remove the log file ynh_secure_remove --file="/var/log/$app" -#================================================= -# REMOVE DEDICATED USER -#================================================= -ynh_script_progression --message="Removing the dedicated system user..." --weight=1 - -ynh_system_user_delete --username=$app +# If the user attempted to upgrade from an older MariaDB-based version, but the upgrade failed, +# the 'remove' action will automatically remove the PostgreSQL database – but doesn't know +# that a MariaDB database is still lying around. +# In that case, remove the MariaDB database manually. +if mysqlshow | grep -q "^| $db_name " +then + ynh_script_progression --message="Removing MariaDB database..." --weight=1 + ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name +fi #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index 87ea3d5..ea26060 100644 --- a/scripts/restore +++ b/scripts/restore @@ -9,141 +9,55 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - ynh_clean_check_starting -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -port=$(ynh_app_setting_get --app=$app --key=port) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name -data_path=$(ynh_app_setting_get --app=$app --key=data_path) - -#================================================= -# CHECK IF THE APP CAN BE RESTORED -#================================================= -ynh_script_progression --message="Validating restoration parameters..." --weight=1 - -test ! -d $final_path \ - || ynh_die --message="There is already a directory: $final_path " - -#================================================= -# STANDARD RESTORATION STEPS -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1 - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - -#================================================= -# 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 --home_dir="$final_path" - #================================================= # RESTORE THE APP MAIN DIR #================================================= ynh_script_progression --message="Restoring the app main directory..." --weight=2 -ynh_restore_file --origin_path="$final_path" +ynh_restore_file --origin_path="$install_dir" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chown -R $app:www-data "$install_dir" #================================================= # RESTORE THE DATA DIRECTORY #================================================= ynh_script_progression --message="Restoring the data directory..." --weight=4 -ynh_restore_file --origin_path="$data_path" --not_mandatory +ynh_restore_file --origin_path="$data_dir" --not_mandatory -mkdir -p $data_path - -chmod 750 "$data_path" -chmod -R o-rwx "$data_path" -chown -R $app:www-data "$data_path" +chown -R $app:www-data "$data_dir" #================================================= -# REINSTALL DEPENDENCIES +# RESTORE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=10 - -# Define and install dependencies -ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies - +# RESTORE THE PHP-FPM CONFIGURATION #================================================= -# RESTORE THE DATABASE -#================================================= -ynh_script_progression --message="Restoring the database..." --weight=6 +ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" -db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) -ynh_psql_test_if_first_run -ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name -#================================================= -# RESTORE USER RIGHTS -#================================================= - logs_path="/var/log/$app" mkdir -p $logs_path chown -R $app: $logs_path -#================================================= -# SPECIFIC RESTORATION -#================================================= -# RESTORE SYSTEMD -#================================================= - ynh_restore_file "/etc/systemd/system/$app.service" systemctl enable $app.service --quiet -#================================================= -# ADVERTISE SERVICE IN ADMIN PANEL -#================================================= - 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 #================================================= -# RELOAD NGINX +# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 + +# Start a systemd service +ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Started Mattermost" ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index aeb0f14..cab1ad3 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,110 +9,35 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - ynh_clean_check_starting -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - #================================================= # LOAD SETTINGS #================================================= ynh_script_progression --message="Loading installation settings..." --weight=2 -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) -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) -version=$(ynh_app_setting_get --app=$app --key=version) -data_path=$(ynh_app_setting_get --app=$app --key=data_path) -team_display_name=$(ynh_app_setting_get --app=$app --key=team_display_name) -admin=$(ynh_app_setting_get --app=$app --key=admin) -password=$(ynh_app_setting_get --app=$app --key=password) email=$(ynh_user_get_info --username=$admin --key=mail) -db_name=$(ynh_sanitize_dbid --db_name=$app) -db_user=$db_name #================================================= # CHECK VERSION #================================================= -ynh_script_progression --message="Checking version..." --weight=1 -previous_upstream_version="$(ynh_app_upstream_version --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json")" upgrade_type=$(ynh_check_app_version_changed) -#================================================= -# 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 () { - # Remove the PostgreSQL db in case of error during the migration. - if [ -n "$remove_psql_in_case_of_error" ]; then - ynh_psql_remove_db --db_user=$db_user --db_name=$db_name - fi - # Restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -# Save the port used if not present -if [ -z "$port" ]; then - port=8065 - ynh_app_setting_set --app=$app --key=port --value=$port -fi - # Save the language used if not present -if [ -z "$language" ]; then +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" +if [ -z "${version:-}" ]; then + version="Team" ynh_app_setting_set --app=$app --key=version --value=$version fi -if [ -z "$db_name" ]; then - db_name="$app" - ynh_app_setting_set --app=$app --key=db_name --value=$db_name -fi - -# If final_path doesn't exist, create it -if [ -z "$data_path" ]; then - data_path="/home/yunohost.app/$app" - ynh_app_setting_set --app=$app --key=data_path --value=$data_path -fi - -# Cleaning legacy permissions -if ynh_legacy_permissions_exists; then - ynh_legacy_permissions_delete_all - - ynh_app_setting_delete --app=$app --key=is_public -fi - -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=10 - -ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies - #================================================= # MIGRATING DATABASE #================================================= @@ -120,8 +45,8 @@ ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies # Check if using MariaDB # This migration should be done before the upgrade if mysqlshow | grep -q "^| $db_name "; then - # Mattermost only support MySQL and PostgreSQL (not MariaDB...) - # Migrate the database from MariaDB to PostgreSQL + # Mattermost recommands PostgreSQL over MySQL (and doesn't support MariaDB at all) + # Migrate the database from MySQL/MariaDB to PostgreSQL remove_psql_in_case_of_error=1 mariadb-to-pg fi @@ -133,15 +58,7 @@ fi #================================================= 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" - -#================================================= -# 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 --home_dir="$final_path" +ynh_systemd_action --service_name=$app --action=stop --log_path=systemd #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -155,51 +72,50 @@ then tmpdir="$(mktemp -d)" # Backup the config file and local plugins in the temp dir - cp -a "$final_path/config/config.json" "$tmpdir/config.json" - cp -ar "$final_path/plugins" "$tmpdir/plugins" + cp -a "$install_dir/config/config.json" "$tmpdir/config.json" + cp -ar "$install_dir/plugins" "$tmpdir/plugins" # Remove the app directory securely - ynh_secure_remove --file="$final_path" + ynh_secure_remove --file="$install_dir" if [ "$version" = "Enterprise" ]; then - ynh_setup_source --dest_dir="$final_path" --source_id="enterprise_$YNH_ARCH" + ynh_setup_source --dest_dir="$install_dir" --source_id="enterprise" elif [ "$version" = "Team" ]; then - ynh_setup_source --dest_dir="$final_path" --source_id="team_$YNH_ARCH" + ynh_setup_source --dest_dir="$install_dir" --source_id="main" fi # Copy the admin saved settings and plugins from tmp directory to final path - cp -a "$tmpdir/config.json" "$final_path/config/config.json" - cp -ar --no-clobber "$tmpdir/plugins" "$final_path/" + cp -a "$tmpdir/config.json" "$install_dir/config/config.json" + cp -ar --no-clobber "$tmpdir/plugins" "$install_dir/" # Remove the tmp directory securely ynh_secure_remove --file="$tmpdir" fi -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= -# NGINX CONFIGURATION +# REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=5 +ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=3 # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Upgrading systemd configuration..." --weight=2 - # Create a dedicated systemd config ynh_add_systemd_config +yunohost service add $app --description="Collaboration platform built for developers" --log="/var/log/$app/$app.log" + +# Use logrotate to manage app-specific logfile(s) +ynh_use_logrotate --non-append + #================================================= # Fix old migrations #================================================= # Crazy fix for old unupgraded version -# IMPORTANT: THIS fix should be done after setup new sources and running mattermost +# IMPORTANT: THIS fix should be done after setup new sources and running Mattermost if ynh_compare_current_package_version --comparison lt --version 5.37.1~ynh1 then read -r -d '' fix_old_version_sql << EOM @@ -214,27 +130,13 @@ UPDATE SidebarCategories SET muted=False where muted IS NULL; UPDATE SidebarCategories set sorting = 'manual' where sorting=''; UPDATE SidebarCategories set sorting = 'manual' where sorting IS NULL; EOM + ynh_psql_execute_as_root --sql="$fix_old_version_sql" --database=$db_name # Note: it's possible that some instances need other fixes # If nothing is displayed in the sidebar it may be needed to change the Id of SidebarCategories... fi -#================================================= -# 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 #================================================= @@ -243,13 +145,6 @@ 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 #================================================= diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..a015869 --- /dev/null +++ b/tests.toml @@ -0,0 +1,31 @@ +test_format = 1.0 + +[default] + + # ------------------------------- + # Default args to use for install + # ------------------------------- + + args.email = "john@gmail.com" + args.admin_password = "admin!42" + args.version = "Team" + args.team_display_name = "Mon équipe" + + # ------------------------------- + # Commits to test upgrade from + # ------------------------------- + + test_upgrade_from.4530e34.name = "Upgrade from 7.2.0" + test_upgrade_from.c88d6ea7.name = "Upgrade from 7.5.2" + test_upgrade_from.a67ddf1f.name = "Upgrade from 7.8.1" + +["Test-with-Enterprise-Edition"] + + only = ["install.subdir", "backup_restore", "upgrade" ] + + args.email = "john@gmail.com" + args.admin_password = "admin!42" + args.version = "Enterprise" + args.team_display_name = "Mon équipe" + + test_upgrade_from.c88d6ea7.name = "Upgrade from 7.5.2"