Bläddra i källkod

Merge manifestv2 to testing

Félix Piédallu 1 år sedan
förälder
incheckning
a82f1d2166
19 ändrade filer med 266 tillägg och 856 borttagningar
  1. 0 71
      .github/workflows/updater.sh
  2. 0 49
      .github/workflows/updater.yml
  3. 0 12
      README.md
  4. 47 0
      README_de.md
  5. 4 19
      README_fr.md
  6. 1 1
      conf/nginx.conf
  7. 2 2
      conf/php-fpm.conf
  8. 0 2
      doc/ADMIN.md
  9. 1 3
      doc/ADMIN_fr.md
  10. 0 84
      manifest.json
  11. 103 0
      manifest.toml
  12. 3 24
      scripts/_common.sh
  13. 1 29
      scripts/backup
  14. 1 101
      scripts/change_url
  15. 22 142
      scripts/install
  16. 19 88
      scripts/remove
  17. 22 103
      scripts/restore
  18. 29 126
      scripts/upgrade
  19. 11 0
      tests.toml

+ 0 - 71
.github/workflows/updater.sh

@@ -1,71 +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.
-
-#=================================================
-# 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)
-i=1
-version=$(curl --silent "https://api.github.com/repos/$repo/tags?page=$i" | jq -r '.[] | select( .name | contains("rc") or contains("beta") or contains("alpha") or startswith("6") or startswith("7") | not ) | .name' | sort -V | tail -1)
-while [ -z $version ] ; do
-    sleep 10
-    i=$(($i + 1))
-    version=$(curl --silent "https://api.github.com/repos/$repo/tags?page=$i" | jq -r '.[] | select( .name | contains("rc") or contains("beta") or contains("alpha") or startswith("6") or startswith("7") | not ) | .name' | sort -V | tail -1)
-done
-
-# Later down the script, we assume the version has only digits and dots
-# Sometimes the release name starts with a "v", so let's filter it out.
-# You may need more tweaks here if the upstream repository has different naming conventions. 
-if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then
-    version=${version:1}
-fi
-
-# Setting up the environment variables
-echo "Current version: $current_version"
-echo "Latest release from upstream: $version"
-echo "VERSION=$version" >> $GITHUB_ENV
-echo "REPO=$repo" >> $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
-
-#=================================================
-# 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

+ 0 - 49
.github/workflows/updater.yml

@@ -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 <yunohost-bot@users.noreply.github.com>'
-          author: 'yunohost-bot <yunohost-bot@users.noreply.github.com>'
-          signoff: false
-          base: testing
-          branch: ci-auto-update-v${{ env.VERSION }}
-          delete-branch: true
-          title: 'Upgrade to version ${{ env.VERSION }}'
-          body: |
-            Upgrade to v${{ env.VERSION }}
-          draft: false

+ 0 - 12
README.md

@@ -17,24 +17,12 @@ It shall NOT be edited by hand.
 ## Overview
 ## Overview
 
 
 A monitoring tool for diverse IT components, including networks, servers, VMs and cloud services.
 A monitoring tool for diverse IT components, including networks, servers, VMs and cloud services.
-
 **Shipped version:** 5.0.41~ynh1
 **Shipped version:** 5.0.41~ynh1
 
 
 ## Screenshots
 ## Screenshots
 
 
 ![Screenshot of Zabbix](./doc/screenshots/screenshot1.png)
 ![Screenshot of Zabbix](./doc/screenshots/screenshot1.png)
 
 
-## Disclaimers / important information
-
-#### Known limitations or important informations
-
-* Only x86_64 architecture is supported
-* Single sign-on is supported
-* Do not change the default admin user password. The user is disabled just after the install but is used to update templates.
-* The Zabbix server port is not opened by default for external monitoring (active agent).
-* You can add your users in a group in Zabbix (for permissions/rights).
-* A YunoHost template is imported and linked to the host "Zabbix-server" (127.0.0.1) for basic monitoring for YunoHost.
-
 ## Documentation and resources
 ## Documentation and resources
 
 
 - Official app website: <https://www.zabbix.com>
 - Official app website: <https://www.zabbix.com>

+ 47 - 0
README_de.md

@@ -0,0 +1,47 @@
+<!--
+N.B.: Diese README wurde automatisch von <https://github.com/YunoHost/apps/tree/master/tools/readme_generator> generiert.
+Sie darf NICHT von Hand bearbeitet werden.
+-->
+
+# Zabbix für YunoHost
+
+[![Integrations-Level](https://dash.yunohost.org/integration/zabbix.svg)](https://dash.yunohost.org/appci/app/zabbix) ![Funktionsstatus](https://ci-apps.yunohost.org/ci/badges/zabbix.status.svg) ![Wartungsstatus](https://ci-apps.yunohost.org/ci/badges/zabbix.maintain.svg)
+
+[![Zabbix mit YunoHost installieren](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=zabbix)
+
+*[Dieses README in anderen Sprachen lesen.](./ALL_README.md)*
+
+> *Mit diesem Paket können Sie Zabbix schnell und einfach auf einem YunoHost-Server installieren.
+Wenn Sie YunoHost nicht haben, lesen Sie bitte [die Anleitung](https://yunohost.org/#/install), um zu erfahren, wie Sie es installieren.*
+
+## Übersicht
+
+A monitoring tool for diverse IT components, including networks, servers, VMs and cloud services.
+**Ausgelieferte Version:** 5.0.41~ynh1
+
+## Bildschirmfotos
+
+![Bildschirmfotos von Zabbix](./doc/screenshots/screenshot1.png)
+
+## Dokumentation und Ressourcen
+
+- Offizielle Website der App: <https://www.zabbix.com>
+- Offizielle Verwaltungsdokumentation: <https://www.zabbix.com/manuals>
+- Upstream App Repository: <https://github.com/zabbix/zabbix>
+- YunoHost-Shop: <https://apps.yunohost.org/app/zabbix>
+- Einen Fehler melden: <https://github.com/YunoHost-Apps/zabbix_ynh/issues>
+
+## Entwicklerinformationen
+
+Bitte senden Sie Ihren Pull-Request an den [testing branch](https://github.com/YunoHost-Apps/zabbix_ynh/tree/testing),
+
+
+Um den Testing-Branch auszuprobieren, gehen Sie bitte wie folgt vor.
+
+```bash
+sudo yunohost app install https://github.com/YunoHost-Apps/zabbix_ynh/tree/testing --debug
+oder
+sudo yunohost app upgrade zabbix -u https://github.com/YunoHost-Apps/zabbix_ynh/tree/testing --debug
+```
+
+**Weitere Informationen zur App-Paketierung:** <https://yunohost.org/packaging_apps>

+ 4 - 19
README_fr.md

@@ -5,7 +5,7 @@ Il NE doit PAS être modifié à la main.
 
 
 # Zabbix pour YunoHost
 # Zabbix pour YunoHost
 
 
-[![Niveau dintégration](https://dash.yunohost.org/integration/zabbix.svg)](https://dash.yunohost.org/appci/app/zabbix) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/zabbix.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/zabbix.maintain.svg)
+[![Niveau d'intégration](https://dash.yunohost.org/integration/zabbix.svg)](https://dash.yunohost.org/appci/app/zabbix) ![Status du fonctionnement](https://ci-apps.yunohost.org/ci/badges/zabbix.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/zabbix.maintain.svg)
 
 
 [![Installer Zabbix avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=zabbix)
 [![Installer Zabbix avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=zabbix)
 
 
@@ -14,27 +14,16 @@ Il NE doit PAS être modifié à la main.
 > *Ce package vous permet d’installer Zabbix rapidement et simplement sur un serveur YunoHost.*  
 > *Ce package vous permet d’installer Zabbix rapidement et simplement sur un serveur YunoHost.*  
 > *Si vous n’avez pas YunoHost, consultez [ce guide](https://yunohost.org/install) pour savoir comment l’installer et en profiter.*
 > *Si vous n’avez pas YunoHost, consultez [ce guide](https://yunohost.org/install) pour savoir comment l’installer et en profiter.*
 
 
-## Vue densemble
+## Vue d'ensemble
 
 
 Un outil de surveillance pour divers composants informatiques, notamment les réseaux, les serveurs, les machines virtuelles et les services en nuage.
 Un outil de surveillance pour divers composants informatiques, notamment les réseaux, les serveurs, les machines virtuelles et les services en nuage.
 
 
+**Version incluse :** 5.0.41~ynh1
 
 
 **Version incluse :** 5.0.41~ynh1
 **Version incluse :** 5.0.41~ynh1
 
 
-## Captures d’écran
+![Capture d'écran de Zabbix](./doc/screenshots/screenshot1.png)
 
 
-![Capture d’écran de Zabbix](./doc/screenshots/screenshot1.png)
-
-## Avertissements / informations importantes
-
-#### Limitations connues et autres informations importantes
-
-* Seule l'architecture x86_64 est prise en charge
-* L'authentification unique (SSO) fonctionne.
-* Ne modifiez pas le mot de passe de l'utilisateur administrateur par défaut. L'utilisateur est désactivé juste après l'installation mais il est utilisé pour mettre à jour les modèles.
-* Le port du serveur Zabbix n'est pas ouvert par défaut pour la surveillance externe (agent actif).
-* Vous pouvez ajouter vos utilisateurs dans un groupe dans Zabbix (pour les autorisations/droits).
-* Un modèle YunoHost est importé et lié à l'hôte "Zabbix-server" (127.0.0.1) pour la surveillance de base de YunoHost.
 ## Documentations et ressources
 ## Documentations et ressources
 
 
 - Site officiel de l’app : <https://www.zabbix.com>
 - Site officiel de l’app : <https://www.zabbix.com>
@@ -46,10 +35,6 @@ Un outil de surveillance pour divers composants informatiques, notamment les ré
 ## Informations pour les développeurs
 ## Informations pour les développeurs
 
 
 Merci de faire vos pull request sur la [branche `testing`](https://github.com/YunoHost-Apps/zabbix_ynh/tree/testing).
 Merci de faire vos pull request sur la [branche `testing`](https://github.com/YunoHost-Apps/zabbix_ynh/tree/testing).
-
-Pour essayer la branche `testing`, procédez comme suit :
-
-```bash
 sudo yunohost app install https://github.com/YunoHost-Apps/zabbix_ynh/tree/testing --debug
 sudo yunohost app install https://github.com/YunoHost-Apps/zabbix_ynh/tree/testing --debug
 ou
 ou
 sudo yunohost app upgrade zabbix -u https://github.com/YunoHost-Apps/zabbix_ynh/tree/testing --debug
 sudo yunohost app upgrade zabbix -u https://github.com/YunoHost-Apps/zabbix_ynh/tree/testing --debug

+ 1 - 1
conf/nginx.conf

@@ -2,7 +2,7 @@
 location __PATH__/ {
 location __PATH__/ {
 
 
   # Path to source
   # Path to source
-  alias __FINALPATH__/;
+  alias /usr/share/zabbix/;
 
 
   index index_http.php;
   index index_http.php;
 
 

+ 2 - 2
conf/php-fpm.conf

@@ -358,7 +358,7 @@ request_terminate_timeout = 1d
 ; Chdir to this directory at the start.
 ; Chdir to this directory at the start.
 ; Note: relative path can be used.
 ; Note: relative path can be used.
 ; Default Value: current directory or / when chroot
 ; Default Value: current directory or / when chroot
-chdir = __FINALPATH__
+chdir = /usr/share/zabbix
 
 
 ; Redirect worker stdout and stderr into main error log. If not set, stdout and
 ; Redirect worker stdout and stderr into main error log. If not set, stdout and
 ; stderr will be redirected to /dev/null according to FastCGI specs.
 ; stderr will be redirected to /dev/null according to FastCGI specs.
@@ -428,5 +428,5 @@ php_admin_value[max_execution_time] = 300
 php_admin_value[max_input_time] = 300
 php_admin_value[max_input_time] = 300
 ; php_admin_value[memory_limit] = 256M
 ; php_admin_value[memory_limit] = 256M
 ; php_admin_flag[short_open_tag] = On
 ; php_admin_flag[short_open_tag] = On
-php_admin_value[open_basedir] = /var/www/zabbix/:/usr/share/fonts/:/tmp:/etc/zabbix/web
+php_admin_value[open_basedir] = /usr/share/zabbix/:/usr/share/fonts/:/tmp:/etc/zabbix/web
 php_admin_value[date.timezone] = Europe/Paris
 php_admin_value[date.timezone] = Europe/Paris

+ 0 - 2
doc/DISCLAIMER.md → doc/ADMIN.md

@@ -1,7 +1,5 @@
 #### Known limitations or important informations
 #### Known limitations or important informations
 
 
-* Only x86_64 architecture is supported
-* Single sign-on is supported
 * Do not change the default admin user password. The user is disabled just after the install but is used to update templates.
 * Do not change the default admin user password. The user is disabled just after the install but is used to update templates.
 * The Zabbix server port is not opened by default for external monitoring (active agent).
 * The Zabbix server port is not opened by default for external monitoring (active agent).
 * You can add your users in a group in Zabbix (for permissions/rights).
 * You can add your users in a group in Zabbix (for permissions/rights).

+ 1 - 3
doc/DISCLAIMER_fr.md → doc/ADMIN_fr.md

@@ -1,8 +1,6 @@
 #### Limitations connues et autres informations importantes
 #### Limitations connues et autres informations importantes
 
 
-* Seule l'architecture x86_64 est prise en charge
-* L'authentification unique (SSO) fonctionne.
 * Ne modifiez pas le mot de passe de l'utilisateur administrateur par défaut. L'utilisateur est désactivé juste après l'installation mais il est utilisé pour mettre à jour les modèles.
 * Ne modifiez pas le mot de passe de l'utilisateur administrateur par défaut. L'utilisateur est désactivé juste après l'installation mais il est utilisé pour mettre à jour les modèles.
 * Le port du serveur Zabbix n'est pas ouvert par défaut pour la surveillance externe (agent actif).
 * Le port du serveur Zabbix n'est pas ouvert par défaut pour la surveillance externe (agent actif).
 * Vous pouvez ajouter vos utilisateurs dans un groupe dans Zabbix (pour les autorisations/droits).
 * Vous pouvez ajouter vos utilisateurs dans un groupe dans Zabbix (pour les autorisations/droits).
-* Un modèle YunoHost est importé et lié à l'hôte "Zabbix-server" (127.0.0.1) pour la surveillance de base de YunoHost.
+* Un modèle YunoHost est importé et lié à l'hôte "Zabbix-server" (127.0.0.1) pour la surveillance de base de YunoHost.

+ 0 - 84
manifest.json

@@ -1,84 +0,0 @@
-{
-    "name": "Zabbix",
-    "id": "zabbix",
-    "packaging_format": 1,
-    "description": {
-        "en": "Monitoring tool for diverse IT components, including networks, servers, VMs and cloud services",
-        "fr": "Outil pour monitorer des réseaux, des serveurs, des VMs et autres services en ligne"
-    },
-    "version": "5.0.41~ynh1",
-    "url": "https://www.zabbix.com",
-    "upstream": {
-        "license": "GPL-2.0-or-later",
-        "website": "https://www.zabbix.com",
-        "admindoc": "https://www.zabbix.com/manuals",
-        "code": "https://github.com/zabbix/zabbix"
-    },
-    "license": "GPL-2.0-or-later",
-    "maintainer": {
-        "name": "",
-        "email": ""
-    },
-    "requirements": {
-        "yunohost": ">= 11.2"
-    },
-    "multi_instance": false,
-    "services": [
-        "nginx",
-        "php7.4-fpm",
-        "mysql"
-    ],
-    "arguments": {
-        "install": [
-            {
-                "name": "domain",
-                "type": "domain"
-            },
-            {
-                "name": "path",
-                "type": "path",
-                "example": "/zabbix",
-                "default": "/zabbix"
-            },
-            {
-                "name": "is_public",
-                "type": "boolean",
-                "help": {
-                    "en": "A public app doesn't need SSO auth : the auth page is opened for everyone",
-                    "fr": "Une application publique ne nécessite pas une authentification SSO : sa page d'authentication est ouverte à tous"
-                },
-                "default": false
-            },
-            {
-                "name": "language",
-                "type": "select",
-                "ask": {
-                    "en": "Choose the application language",
-                    "fr": "Choisissez la langue de l'application"
-                },
-                "choices": [
-                    "en_GB",
-                    "en_US",
-                    "cz_CN",
-                    "cs_CZ",
-                    "fr_FR",
-                    "ko_KR",
-                    "ja_JP",
-                    "nb_NO",
-                    "pl_PL",
-                    "pt_BR",
-                    "pt_PT",
-                    "ru_RU",
-                    "sk_SK",
-                    "tr_TR",
-                    "uk_UA"
-                ],
-                "default": "en_US"
-            },
-            {
-                "name": "admin",
-                "type": "user"
-            }
-        ]
-    }
-}

+ 103 - 0
manifest.toml

@@ -0,0 +1,103 @@
+#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
+
+packaging_format = 2
+
+id = "zabbix"
+name = "Zabbix"
+description.en = "Monitoring tool for diverse IT components, including networks, servers, VMs and cloud services"
+description.fr = "Outil pour monitorer des réseaux, des serveurs, des VMs et autres services en ligne"
+
+version = "5.0.41~ynh1"
+
+maintainers = []
+
+[upstream]
+license = "GPL-2.0-or-later"
+website = "https://www.zabbix.com"
+admindoc = "https://www.zabbix.com/manuals"
+code = "https://github.com/zabbix/zabbix"
+cpe = "cpe:2.3:a:zabbix:zabbix"
+
+[integration]
+yunohost = ">= 11.2"
+architectures = ["amd64"]
+multi_instance = false
+ldap = true
+sso = true
+disk = "500M"
+ram.build = "200M"
+ram.runtime = "200M"
+
+[install]
+    [install.domain]
+    type = "domain"
+
+    [install.path]
+    type = "path"
+    default = "/zabbix"
+
+    [install.init_main_permission]
+    help.en = "A public app doesn't need SSO auth : the auth page is opened for everyone"
+    help.fr = "Une application publique ne nécessite pas une authentification SSO : sa page d'authentication est ouverte à tous"
+    type = "group"
+    default = false
+
+    [install.language]
+    ask.en = "Choose the application language"
+    ask.fr = "Choisissez la langue de l'application"
+    type = "select"
+    choices = ["en_GB", "en_US", "cz_CN", "cs_CZ", "fr_FR", "ko_KR", "ja_JP", "nb_NO", "pl_PL", "pt_BR", "pt_PT", "ru_RU", "sk_SK", "tr_TR", "uk_UA"]
+    default = "en_US"
+
+    [install.admin]
+    type = "user"
+
+[resources]
+    [resources.system_user]
+
+    [resources.install_dir]
+
+    [resources.permissions]
+    main.url = "/"
+
+    [resources.apt]
+    packages = [
+        "libapr1",
+        "libaprutil1",
+        "libaprutil1-dbd-sqlite3",
+        "libaprutil1-ldap",
+        "liblua5.2-0",
+        "fonts-dejavu-core",
+        "patch",
+        "smistrip",
+        "unzip",
+        "wget",
+        "fping",
+        "libcap2-bin",
+        "libiksemel3",
+        "libopenipmi0",
+        "libpam-cap",
+        "libsnmp-base",
+        "libsnmp40",
+        "snmptrapd",
+        "snmpd",
+        "libjs-prototype",
+        "jq",
+        "libssh-4",
+        "php7.4-fpm",
+        "php7.4-bcmath",
+
+        "mariadb-server",
+    ]
+
+    [resources.apt.extras.zabbix]
+    repo = "http://repo.zabbix.com/zabbix/5.0/debian bullseye main"
+    key = "https://repo.zabbix.com/zabbix-official-repo.key"
+    packages = [
+        "zabbix-agent",
+        "zabbix-frontend-php",
+        "zabbix-server-mysql",
+    ]
+
+    [resources.database]
+    type = "mysql"

+ 3 - 24
scripts/_common.sh

@@ -4,19 +4,6 @@
 # COMMON VARIABLES
 # COMMON VARIABLES
 #=================================================
 #=================================================
 
 
-YNH_PHP_VERSION="7.4"
-
-# dependencies used by the app
-if [ "$(lsb_release --codename --short)" = "bullseye" ]; then
-    libsnmpd_version="libsnmp40"
-else
-    libsnmpd_version="libsnmp30"
-fi
-
-pkg_dependencies="libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0 fonts-dejavu-core patch smistrip unzip wget fping libcap2-bin libiksemel3 libopenipmi0 libpam-cap libsnmp-base $libsnmpd_version snmptrapd snmpd libjs-prototype jq libssh-4 php${YNH_PHP_VERSION}-fpm php${YNH_PHP_VERSION}-bcmath"
-
-zabbix_pkg_dependencies="zabbix-agent zabbix-frontend-php zabbix-server-mysql"
-
 #=================================================
 #=================================================
 # PERSONAL HELPERS
 # PERSONAL HELPERS
 #=================================================
 #=================================================
@@ -67,7 +54,7 @@ get_state_admin_user () {
 # Disable admin user
 # Disable admin user
 #
 #
 disable_admin_user () {
 disable_admin_user () {
-	if [ $(get_state_admin_user) = "0" ] 
+	if [ $(get_state_admin_user) = "0" ]
 	then
 	then
 		ynh_print_info --message="Disable admin user"
 		ynh_print_info --message="Disable admin user"
 		lastid=$($mysqlconn -BN -e "SELECT max(id) from \`users_groups\`")
 		lastid=$($mysqlconn -BN -e "SELECT max(id) from \`users_groups\`")
@@ -97,7 +84,7 @@ enable_admin_user () {
 #
 #
 import_template () {
 import_template () {
 	ynh_print_info --message="Import YunoHost template in the agent"
 	ynh_print_info --message="Import YunoHost template in the agent"
-	zabbixFullpath=https://$domain$path_url
+	zabbixFullpath=https://$domain$path
 	localpath="../conf/Template_Yunohost.xml"
 	localpath="../conf/Template_Yunohost.xml"
 	sudoUserPpath="../conf/etc_sudoers.d_zabbix"
 	sudoUserPpath="../conf/etc_sudoers.d_zabbix"
 	confUserPpath="../conf/etc_zabbix_zabbix_agentd.d_userP_yunohost.conf"
 	confUserPpath="../conf/etc_zabbix_zabbix_agentd.d_userP_yunohost.conf"
@@ -133,7 +120,7 @@ import_template () {
 	then
 	then
 		sid=$(curl $curlOptions \
 		sid=$(curl $curlOptions \
 						"$zabbixFullpath/conf.import.php?rules_preset=template" \
 						"$zabbixFullpath/conf.import.php?rules_preset=template" \
-						| grep -Po 'name="sid" value="\K([a-z0-9]{16})(?=")' ) 
+						| grep -Po 'name="sid" value="\K([a-z0-9]{16})(?=")' )
 
 
 		importState=$(curl $curlOptions \
 		importState=$(curl $curlOptions \
 						--form "config=1" \
 						--form "config=1" \
@@ -217,14 +204,6 @@ check_proc_zabbixagent () {
 	fi
 	fi
 }
 }
 
 
-# Remove previous Zabbix installation
-#
-remove_previous_zabbix () {
-	ynh_print_info --message="Previous Zabbix installation will be purged !"
-	apt-get purge zabbix* -y
-	ynh_secure_remove --file="/var/cache/apt/archives/zabbix-server-mysql*"
-	ynh_print_info --message="Previous Zabbix installation purged !"
-}
 
 
 # Update Zabbix configuration initialisation
 # Update Zabbix configuration initialisation
 #
 #

+ 1 - 29
scripts/backup

@@ -1,7 +1,5 @@
 #!/bin/bash
 #!/bin/bash
 
 
-#=================================================
-# GENERIC START
 #=================================================
 #=================================================
 # IMPORT GENERIC HELPERS
 # IMPORT GENERIC HELPERS
 #=================================================
 #=================================================
@@ -10,43 +8,17 @@
 source ../settings/scripts/_common.sh
 source ../settings/scripts/_common.sh
 source /usr/share/yunohost/helpers
 source /usr/share/yunohost/helpers
 
 
-#=================================================
-# MANAGE SCRIPT FAILURE
-#=================================================
-
-ynh_clean_setup () {
-	true
-}
-# 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)
-phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
-
 #=================================================
 #=================================================
 # DECLARE DATA AND CONF FILES TO BACKUP
 # DECLARE DATA AND CONF FILES TO BACKUP
 #=================================================
 #=================================================
 ynh_print_info --message="Declaring files to be backed up..."
 ynh_print_info --message="Declaring files to be backed up..."
 
 
 #=================================================
 #=================================================
-# BACKUP THE NGINX CONFIGURATION
+# BACKUP THE SYSTEM CONFIGURATION
 #=================================================
 #=================================================
 
 
 ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
 ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
 
 
-#=================================================
-# BACKUP THE PHP-FPM CONFIGURATION
-#=================================================
-
 ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
 ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
 
 
 #=================================================
 #=================================================

+ 1 - 101
scripts/change_url

@@ -1,7 +1,5 @@
 #!/bin/bash
 #!/bin/bash
 
 
-#=================================================
-# GENERIC STARTING
 #=================================================
 #=================================================
 # IMPORT GENERIC HELPERS
 # IMPORT GENERIC HELPERS
 #=================================================
 #=================================================
@@ -9,110 +7,12 @@
 source _common.sh
 source _common.sh
 source /usr/share/yunohost/helpers
 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..."
-
-# Needed for helper "ynh_add_nginx_config"
-final_path=$(ynh_app_setting_get --app=$app --key=final_path)
-
-# Add settings here as needed by your application
-#db_name=$(ynh_app_setting_get --app=$app --key=db_name)
-#db_user=$db_name
-#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
-
-#=================================================
-# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
-#=================================================
-ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..."
-
-# Backup the current version of the app
-ynh_backup_before_upgrade
-ynh_clean_setup () {
-	ynh_clean_check_starting
-	# 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
 #=================================================
 #=================================================
 # MODIFY URL IN NGINX CONF
 # MODIFY URL IN NGINX CONF
 #=================================================
 #=================================================
 ynh_script_progression --message="Updating NGINX web server configuration..."
 ynh_script_progression --message="Updating NGINX web server configuration..."
 
 
-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
-
-#=================================================
-# SPECIFIC MODIFICATIONS
-#=================================================
-# ...
-#=================================================
-
-#=================================================
-# GENERIC FINALISATION
-#=================================================
-# RELOAD NGINX
-#=================================================
-ynh_script_progression --message="Reloading NGINX web server..."
-
-ynh_systemd_action --service_name=nginx --action=reload
+ynh_change_url_nginx_config
 
 
 #=================================================
 #=================================================
 # END OF SCRIPT
 # END OF SCRIPT

+ 22 - 142
scripts/install

@@ -1,7 +1,5 @@
 #!/bin/bash
 #!/bin/bash
 
 
-#=================================================
-# GENERIC START
 #=================================================
 #=================================================
 # IMPORT GENERIC HELPERS
 # IMPORT GENERIC HELPERS
 #=================================================
 #=================================================
@@ -9,105 +7,14 @@
 source _common.sh
 source _common.sh
 source /usr/share/yunohost/helpers
 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
-language=$YNH_APP_ARG_LANGUAGE
-admin=$YNH_APP_ARG_ADMIN
-
-app=$YNH_APP_INSTANCE_NAME
-
-#=================================================
-# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
-#=================================================
-ynh_script_progression --message="Validating installation parameters..."
-
-remove_previous_zabbix
-
-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..."
-
-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=language --value=$language
-ynh_app_setting_set --app=$app --key=admin --value=$admin
-
-#=================================================
-# STANDARD MODIFICATIONS
-#=================================================
-# INSTALL DEPENDENCIES
-#=================================================
-ynh_script_progression --message="Installing dependencies..."
-
-ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
-ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="http://repo.zabbix.com/zabbix/5.0/debian $(lsb_release -sc) main" --package="$zabbix_pkg_dependencies" --key="https://repo.zabbix.com/zabbix-official-repo.key"
-
-ynh_replace_string --match_string="# $language.UTF-8 UTF-8" --replace_string="$language.UTF-8 UTF-8" --target_file=/etc/locale.gen
-locale-gen
-
-#=================================================
-# CREATE A MYSQL DATABASE
-#=================================================
-ynh_script_progression --message="Creating a MySQL database..."
-
-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_mysql_setup_db --db_user=$db_user --db_name=$db_name
-
 #=================================================
 #=================================================
 # DOWNLOAD, CHECK AND UNPACK SOURCE
 # DOWNLOAD, CHECK AND UNPACK SOURCE
 #=================================================
 #=================================================
 ynh_script_progression --message="Setting up source files..."
 ynh_script_progression --message="Setting up source files..."
 
 
-ynh_app_setting_set --app=$app --key=final_path --value=$final_path
-ln -s "/usr/share/zabbix" "$final_path"
-
-chmod 750 "/usr/share/zabbix"
 chmod -R o-rwx "/usr/share/zabbix"
 chmod -R o-rwx "/usr/share/zabbix"
-chown -R $app:www-data "/usr/share/zabbix"
-
-#=================================================
-# PHP-FPM CONFIGURATION
-#=================================================
-ynh_script_progression --message="Configuring PHP-FPM..."
-
-# Create a dedicated PHP-FPM config
-ynh_add_fpm_config
-phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
-
-#=================================================
-# NGINX CONFIGURATION
-#=================================================
-ynh_script_progression --message="Configuring NGINX web server..."
-
-# Create a dedicated NGINX config
-ynh_add_nginx_config
+chown -R "$app:www-data" "/usr/share/zabbix"
 
 
-#=================================================
-# SPECIFIC SETUP
 #=================================================
 #=================================================
 # IMPORT DEFAULT DATA
 # IMPORT DEFAULT DATA
 #=================================================
 #=================================================
@@ -132,8 +39,8 @@ $mysqlconn -e "INSERT INTO \`users_groups\` (\`id\`, \`usrgrpid\`, \`userid\`) V
 
 
 #users creation in zabbix database
 #users creation in zabbix database
 i=4
 i=4
-for user in $(ynh_user_list); 
-do 
+for user in $(ynh_user_list);
+do
 	if [ "$user" != "$admin" ]
 	if [ "$user" != "$admin" ]
 	then
 	then
 		surname=$(ynh_user_get_info --username="$user" --key=lastname)
 		surname=$(ynh_user_get_info --username="$user" --key=lastname)
@@ -155,33 +62,40 @@ ynh_script_progression --message="Adding a configuration file..."
 ynh_add_config --template="../conf/etc_zabbix_web_zabbix.conf.php" --destination="/etc/zabbix/web/zabbix.conf.php"
 ynh_add_config --template="../conf/etc_zabbix_web_zabbix.conf.php" --destination="/etc/zabbix/web/zabbix.conf.php"
 
 
 chmod 400 "/etc/zabbix/web/zabbix.conf.php"
 chmod 400 "/etc/zabbix/web/zabbix.conf.php"
-chown $app:www-data "/etc/zabbix/web/zabbix.conf.php"
+chown "$app:www-data" "/etc/zabbix/web/zabbix.conf.php"
 
 
 ynh_replace_string --match_string="DBName=zabbix" --replace_string="DBName=$db_name" --target_file=/etc/zabbix/zabbix_server.conf
 ynh_replace_string --match_string="DBName=zabbix" --replace_string="DBName=$db_name" --target_file=/etc/zabbix/zabbix_server.conf
 ynh_replace_string --match_string="DBUser=zabbix" --replace_string="DBUser=$db_user" --target_file=/etc/zabbix/zabbix_server.conf
 ynh_replace_string --match_string="DBUser=zabbix" --replace_string="DBUser=$db_user" --target_file=/etc/zabbix/zabbix_server.conf
 ynh_replace_string --match_string="# DBPassword=" --replace_string="# DBPassword=\nDBPassword=$db_pwd" --target_file=/etc/zabbix/zabbix_server.conf
 ynh_replace_string --match_string="# DBPassword=" --replace_string="# DBPassword=\nDBPassword=$db_pwd" --target_file=/etc/zabbix/zabbix_server.conf
 
 
 #=================================================
 #=================================================
-# SETUP SYSTEMD
+# SYSTEM CONFIGURATION
 #=================================================
 #=================================================
-ynh_script_progression --message="Configuring a systemd service..."
+ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
+
+ynh_replace_string --match_string="# $language.UTF-8 UTF-8" --replace_string="$language.UTF-8 UTF-8" --target_file=/etc/locale.gen
+locale-gen
+
+# Create a dedicated PHP-FPM config
+ynh_add_fpm_config
+
+# Create a dedicated NGINX config
+ynh_add_nginx_config
 
 
 change_timeoutAgent
 change_timeoutAgent
 
 
 systemctl enable zabbix-agent --quiet
 systemctl enable zabbix-agent --quiet
 systemctl enable zabbix-server --quiet
 systemctl enable zabbix-server --quiet
+yunohost service add snmpd --description="Management of SNMP Daemon"
+yunohost service add zabbix-server --description="Management Zabbix server daemon : collect, agregate, compute and notify" --log="/var/log/$app/${app}_server.log"
+yunohost service add zabbix-agent --description="Management Zabbix agent daemon : send informations about this host to the server" --log="/var/log/$app/${app}_agent.log"
 
 
 update_initZabbixConf
 update_initZabbixConf
 
 
 #=================================================
 #=================================================
 # SETUP APPLICATION WITH CURL
 # SETUP APPLICATION WITH CURL
 #=================================================
 #=================================================
-ynh_script_progression --message="Setuping application with CURL..."
-
-# Set the app as temporarily public for curl call
-ynh_script_progression --message="Configuring SSOwat..."
-# Making the app public for curl
-ynh_permission_update --permission="main" --add="visitors"
+ynh_script_progression --message="Setting up application with CURL..."
 
 
 import_template
 import_template
 
 
@@ -189,48 +103,14 @@ link_template
 
 
 disable_admin_user
 disable_admin_user
 
 
-# Remove the public access
-ynh_permission_update --permission="main" --remove="visitors"
-
-#=================================================
-# GENERIC FINALIZATION
-#=================================================
-# INTEGRATE SERVICE IN YUNOHOST
-#=================================================
-ynh_script_progression --message="Integrating service in YunoHost..."
-
-yunohost service add snmpd --description="Management of SNMP Daemon"
-yunohost service add zabbix-server --description="Management Zabbix server daemon : collect, agregate, compute and notify" --log="/var/log/$app/${app}_server.log"
-yunohost service add zabbix-agent --description="Management Zabbix agent daemon : send informations about this host to the server" --log="/var/log/$app/${app}_agent.log"
-
 #=================================================
 #=================================================
 # START SYSTEMD SERVICE
 # START SYSTEMD SERVICE
 #=================================================
 #=================================================
-ynh_script_progression --message="Starting a systemd service..."
+ynh_script_progression --message="Starting $app's systemd service..."
 
 
 # Start a systemd service
 # Start a systemd service
-ynh_systemd_action --service_name=$app-server --action="restart" --log_path="/var/log/$app/${app}_server.log"
-ynh_systemd_action --service_name=$app-agent --action="restart" --log_path="/var/log/$app/${app}_agent.log"
-
-#=================================================
-# SETUP SSOWAT
-#=================================================
-ynh_script_progression --message="Configuring permissions..."
-
-# Make app public if necessary
-if [ $is_public -eq 1 ]
-then
-	# Everyone can access the app.
-	# The "main" permission is automatically created before the install script.
-	ynh_permission_update --permission="main" --add="visitors"
-fi
-
-#=================================================
-# RELOAD NGINX
-#=================================================
-ynh_script_progression --message="Reloading NGINX web server..."
-
-ynh_systemd_action --service_name=nginx --action=reload
+ynh_systemd_action --service_name="$app-server" --action="restart" --log_path="/var/log/$app/${app}_server.log"
+ynh_systemd_action --service_name="$app-agent" --action="restart" --log_path="/var/log/$app/${app}_agent.log"
 
 
 #=================================================
 #=================================================
 # END OF SCRIPT
 # END OF SCRIPT

+ 19 - 88
scripts/remove

@@ -1,7 +1,5 @@
 #!/bin/bash
 #!/bin/bash
 
 
-#=================================================
-# GENERIC START
 #=================================================
 #=================================================
 # IMPORT GENERIC HELPERS
 # IMPORT GENERIC HELPERS
 #=================================================
 #=================================================
@@ -10,94 +8,38 @@ source _common.sh
 source /usr/share/yunohost/helpers
 source /usr/share/yunohost/helpers
 
 
 #=================================================
 #=================================================
-# LOAD SETTINGS
-#=================================================
-ynh_script_progression --message="Loading installation settings..."
-
-app=$YNH_APP_INSTANCE_NAME
-
-domain=$(ynh_app_setting_get --app=$app --key=domain)
-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)
-
-#=================================================
-# STANDARD REMOVE
+# REMOVE SYSTEM CONFIGURATIONS
 #=================================================
 #=================================================
-# REMOVE SERVICE INTEGRATION IN YUNOHOST
-#=================================================
-
-ynh_script_progression --message="Removing snmpd service integration..."
-yunohost service remove snmpd
-
-ynh_script_progression --message="Removing Zabbix-server service integration..."
-yunohost service remove zabbix-server
-
-ynh_script_progression --message="Removing Zabbix-agent service integration..."
-yunohost service remove zabbix-agent
-
-#=================================================
-# STOP AND REMOVE SERVICE
-#=================================================
-ynh_script_progression --message="Stopping and removing the systemd service..."
+ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
 
 
 # Remove the dedicated systemd config
 # Remove the dedicated systemd config
-ynh_systemd_action --service_name=$app-server --action="stop" --log_path="/var/log/$app/${app}_server.log"
-ynh_systemd_action --service_name=$app-agent --action="stop" --log_path="/var/log/$app/${app}_agent.log"
-
+ynh_systemd_action --service_name="$app-server" --action="stop" --log_path="/var/log/$app/${app}_server.log"
+ynh_systemd_action --service_name="$app-agent" --action="stop" --log_path="/var/log/$app/${app}_agent.log"
 systemctl disable zabbix-server --quiet
 systemctl disable zabbix-server --quiet
 systemctl disable zabbix-agent --quiet
 systemctl disable zabbix-agent --quiet
-
 ynh_exec_warn_less killall zabbix_server
 ynh_exec_warn_less killall zabbix_server
 ynh_exec_warn_less killall zabbix_agentd
 ynh_exec_warn_less killall zabbix_agentd
 
 
-#=================================================
-# REMOVE THE MYSQL DATABASE
-#=================================================
-ynh_script_progression --message="Removing the MySQL database..."
-
-# Remove a database if it exists, along with the associated user
-ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
-
-#=================================================
-# REMOVE NGINX CONFIGURATION
-#=================================================
-ynh_script_progression --message="Removing NGINX web server configuration..."
+yunohost service remove snmpd
+yunohost service remove zabbix-server
+yunohost service remove zabbix-agent
 
 
 # Remove the dedicated NGINX config
 # Remove the dedicated NGINX config
 ynh_remove_nginx_config
 ynh_remove_nginx_config
 
 
-#=================================================
-# REMOVE PHP-FPM CONFIGURATION
-#=================================================
-ynh_script_progression --message="Removing PHP-FPM configuration..."
-
 # Remove the dedicated PHP-FPM config
 # Remove the dedicated PHP-FPM config
 ynh_remove_fpm_config
 ynh_remove_fpm_config
 
 
 #=================================================
 #=================================================
 # REMOVE DEPENDENCIES
 # REMOVE DEPENDENCIES
 #=================================================
 #=================================================
-ynh_script_progression --message="Removing dependencies..."
+ynh_script_progression --message="Removing $app's configuration..."
 
 
-#Remove config file detection
+# Remove config file detection
 delete_initZabbixConf
 delete_initZabbixConf
 
 
-ynh_remove_app_dependencies
-
-ynh_remove_extra_repo --name=$app
-
-#=================================================
-# REMOVE APP MAIN DIR
-#=================================================
-ynh_script_progression --message="Removing app main directory..."
-
-# Remove the app directory securely
-ynh_secure_remove --file="$final_path"
 ynh_secure_remove --file="/usr/share/$app"
 ynh_secure_remove --file="/usr/share/$app"
 
 
-#=================================================
-# SPECIFIC REMOVE
 #=================================================
 #=================================================
 # REMOVE VARIOUS FILES
 # REMOVE VARIOUS FILES
 #=================================================
 #=================================================
@@ -113,30 +55,19 @@ ynh_secure_remove --file="/run/$app"
 
 
 ynh_secure_remove --file="/etc/sudoers.d/$app"
 ynh_secure_remove --file="/etc/sudoers.d/$app"
 
 
-#REMOVE NONFREE PART PATCH IF NEEDED (snmp-mibs-downloader (non-free) installed in version 1)
+# FIXME: useless?
+# REMOVE NONFREE PART PATCH IF NEEDED (snmp-mibs-downloader (non-free) installed in version 1)
 nonfreepackagelist=$(dpkg-query -W -f='${Section}\t${Package}\n' | grep ^non-free)
 nonfreepackagelist=$(dpkg-query -W -f='${Section}\t${Package}\n' | grep ^non-free)
-if [ $(echo $nonfreepackagelist | wc -l) -eq 1 ] && [ $(echo $nonfreepackagelist | grep -c "snmp-mibs-downloader") -eq 1 ]
-then 
-	ynh_print_info --message="Removing snmp-mibs-downloader (non-free package)"
-	cp /var/lib/dpkg/status{,.$(date "+%m%d%y")}
-	ynh_replace_string --match_string=" snmp-mibs-downloader," --replace_string="" --target_file=/var/lib/dpkg/status
-	DEBIAN_FRONTEND=noninteractive apt purge snmp-mibs-downloader -y
-	if [ -f /etc/apt/sources.list.d/non-free.list ]
-	then
-		ynh_secure_remove --file="/etc/apt/sources.list.d/non-free.list"
-	fi
+if [ "$(echo $nonfreepackagelist | wc -l)" -eq 1 ] && [ "$(echo $nonfreepackagelist | grep -c "snmp-mibs-downloader")" -eq 1 ]; then
+    ynh_print_info --message="Removing snmp-mibs-downloader (non-free package)"
+    cp /var/lib/dpkg/status{,.$(date "+%m%d%y")}
+    ynh_replace_string --match_string=" snmp-mibs-downloader," --replace_string="" --target_file=/var/lib/dpkg/status
+    DEBIAN_FRONTEND=noninteractive apt purge snmp-mibs-downloader -y
+    if [ -f /etc/apt/sources.list.d/non-free.list ]; then
+        ynh_secure_remove --file="/etc/apt/sources.list.d/non-free.list"
+    fi
 fi
 fi
 
 
-#=================================================
-# GENERIC FINALIZATION
-#=================================================
-# REMOVE DEDICATED USER
-#=================================================
-ynh_script_progression --message="Removing the dedicated system user..."
-
-# Delete a system user
-ynh_system_user_delete --username=$app
-
 #=================================================
 #=================================================
 # END OF SCRIPT
 # END OF SCRIPT
 #=================================================
 #=================================================

+ 22 - 103
scripts/restore

@@ -1,7 +1,5 @@
 #!/bin/bash
 #!/bin/bash
 
 
-#=================================================
-# GENERIC START
 #=================================================
 #=================================================
 # IMPORT GENERIC HELPERS
 # IMPORT GENERIC HELPERS
 #=================================================
 #=================================================
@@ -10,90 +8,20 @@
 source ../settings/scripts/_common.sh
 source ../settings/scripts/_common.sh
 source /usr/share/yunohost/helpers
 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..."
-
-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)
-db_name=$(ynh_app_setting_get --app=$app --key=db_name)
-db_user=$db_name
-phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
-language=$(ynh_app_setting_get --app=$app --key=language)
-
-#=================================================
-# CHECK IF THE APP CAN BE RESTORED
-#=================================================
-ynh_script_progression --message="Validating restoration parameters..."
-
-remove_previous_zabbix
-
-test ! -d $final_path \
-	|| ynh_die --message="There is already a directory: $final_path "
-
-#=================================================
-# STANDARD RESTORATION STEPS
-#=================================================
-# SPECIFIC RESTORATION
-#=================================================
-# REINSTALL DEPENDENCIES
-#=================================================
-ynh_script_progression --message="Reinstalling dependencies..."
-
-# Define and install dependencies
-ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
-ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="http://repo.zabbix.com/zabbix/5.0/debian $(lsb_release -sc) main" --package="$zabbix_pkg_dependencies" --key="https://repo.zabbix.com/zabbix-official-repo.key"
-
-ynh_replace_string --match_string="# $language.UTF-8 UTF-8" --replace_string="$language.UTF-8 UTF-8" --target_file=/etc/locale.gen
-locale-gen
-
 #=================================================
 #=================================================
 # RESTORE THE APP MAIN DIR
 # RESTORE THE APP MAIN DIR
 #=================================================
 #=================================================
 ynh_script_progression --message="Restoring the app main directory..."
 ynh_script_progression --message="Restoring the app main directory..."
 
 
-ln -s /usr/share/zabbix "$final_path"
-
-chmod 750 "/usr/share/zabbix"
 chmod -R o-rwx "/usr/share/zabbix"
 chmod -R o-rwx "/usr/share/zabbix"
-chown -R $app:www-data "/usr/share/zabbix"
-
-#=================================================
-# RESTORE THE PHP-FPM CONFIGURATION
-#=================================================
-ynh_script_progression --message="Restoring the PHP-FPM configuration..."
-
-ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
-
-#=================================================
-# RESTORE THE NGINX CONFIGURATION
-#=================================================
-ynh_script_progression --message="Restoring the NGINX web server configuration..."
-
-ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
+chown -R "$app:www-data" "/usr/share/zabbix"
 
 
 #=================================================
 #=================================================
 # RESTORE THE MYSQL DATABASE
 # RESTORE THE MYSQL DATABASE
 #=================================================
 #=================================================
-ynh_script_progression --message="Restoring the MySQL database..."
+ynh_script_progression --message="Restoring the MySQL database..." --weight=1
 
 
-db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
-ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
-ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
+ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql
 
 
 export mysqlconn="mysql --user=$db_user --password=$db_pwd --database=$db_name"
 export mysqlconn="mysql --user=$db_user --password=$db_pwd --database=$db_name"
 convert_ZabbixDB
 convert_ZabbixDB
@@ -103,65 +31,56 @@ convert_ZabbixDB
 #=================================================
 #=================================================
 ynh_script_progression --message="Restoring various files..."
 ynh_script_progression --message="Restoring various files..."
 
 
-if [ -f "/etc/zabbix/web/zabbix.conf.php" ]
-then
-	ynh_secure_remove --file="/etc/zabbix/web/zabbix.conf.php"
+if [ -f "/etc/zabbix/web/zabbix.conf.php" ]; then
+    ynh_secure_remove --file="/etc/zabbix/web/zabbix.conf.php"
 fi
 fi
-
 ynh_restore_file --origin_path="/etc/zabbix/web/zabbix.conf.php"
 ynh_restore_file --origin_path="/etc/zabbix/web/zabbix.conf.php"
 
 
 chmod 400 "/etc/zabbix/web/zabbix.conf.php"
 chmod 400 "/etc/zabbix/web/zabbix.conf.php"
-chown $app:www-data "/etc/zabbix/web/zabbix.conf.php"
+chown "$app:www-data" "/etc/zabbix/web/zabbix.conf.php"
 
 
 ynh_restore_file --origin_path="/etc/apt/apt.conf.d/100update_force_init_zabbix_frontend_config"
 ynh_restore_file --origin_path="/etc/apt/apt.conf.d/100update_force_init_zabbix_frontend_config"
 
 
 ynh_restore_file --origin_path="/etc/zabbix/zabbix_server.conf"
 ynh_restore_file --origin_path="/etc/zabbix/zabbix_server.conf"
 ynh_restore_file --origin_path="/etc/zabbix/zabbix_agentd.conf"
 ynh_restore_file --origin_path="/etc/zabbix/zabbix_agentd.conf"
 
 
-if [ ! -L /etc/zabbix/zabbix_agentd.d ]
-then
-	ln -s /etc/zabbix/zabbix_agentd.conf.d /etc/zabbix/zabbix_agentd.d
+if [ ! -L /etc/zabbix/zabbix_agentd.d ]; then
+    ln -s /etc/zabbix/zabbix_agentd.conf.d /etc/zabbix/zabbix_agentd.d
 fi
 fi
 
 
 # Restore sudo file
 # Restore sudo file
 ynh_restore_file --origin_path="/etc/sudoers.d/zabbix"
 ynh_restore_file --origin_path="/etc/sudoers.d/zabbix"
 
 
 #=================================================
 #=================================================
-# RESTORE SYSTEMD
+# RESTORE SYSTEM CONFIGURATIONS
 #=================================================
 #=================================================
-ynh_script_progression --message="Restoring the systemd configuration..."
+ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
+
+ynh_replace_string --match_string="# $language.UTF-8 UTF-8" --replace_string="$language.UTF-8 UTF-8" --target_file=/etc/locale.gen
+locale-gen
+
+ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
+
+ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
 
 
 change_timeoutAgent
 change_timeoutAgent
 
 
 systemctl enable zabbix-agent --quiet
 systemctl enable zabbix-agent --quiet
 systemctl enable zabbix-server --quiet
 systemctl enable zabbix-server --quiet
-
-#=================================================
-# INTEGRATE SERVICE IN YUNOHOST
-#=================================================
-ynh_script_progression --message="Integrating service in YunoHost..."
-
 yunohost service add snmpd --description="Management of SNMP Daemon"
 yunohost service add snmpd --description="Management of SNMP Daemon"
 yunohost service add zabbix-server --description="Management Zabbix server daemon : collect, agregate, compute and notify" --log="/var/log/$app/${app}_server.log"
 yunohost service add zabbix-server --description="Management Zabbix server daemon : collect, agregate, compute and notify" --log="/var/log/$app/${app}_server.log"
 yunohost service add zabbix-agent --description="Management Zabbix agent daemon : send informations about this host to the server" --log="/var/log/$app/${app}_agent.log"
 yunohost service add zabbix-agent --description="Management Zabbix agent daemon : send informations about this host to the server" --log="/var/log/$app/${app}_agent.log"
 
 
 #=================================================
 #=================================================
-# START SYSTEMD SERVICE
+# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
 #=================================================
 #=================================================
-ynh_script_progression --message="Starting a systemd service..."
+ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
 
 
 # Start a systemd service
 # Start a systemd service
-ynh_systemd_action --service_name=$app-server --action="restart" --log_path="/var/log/$app/${app}_server.log"
-ynh_systemd_action --service_name=$app-agent --action="restart" --log_path="/var/log/$app/${app}_agent.log"
-
-#=================================================
-# GENERIC FINALIZATION
-#=================================================
-# RELOAD NGINX AND PHP-FPM
-#=================================================
-ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..."
+ynh_systemd_action --service_name="$app-server" --action="restart" --log_path="/var/log/$app/${app}_server.log"
+ynh_systemd_action --service_name="$app-agent" --action="restart" --log_path="/var/log/$app/${app}_agent.log"
 
 
-ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
+ynh_systemd_action --service_name="php$phpversion-fpm" --action=reload
 ynh_systemd_action --service_name=nginx --action=reload
 ynh_systemd_action --service_name=nginx --action=reload
 
 
 #=================================================
 #=================================================

+ 29 - 126
scripts/upgrade

@@ -1,7 +1,5 @@
 #!/bin/bash
 #!/bin/bash
 
 
-#=================================================
-# GENERIC START
 #=================================================
 #=================================================
 # IMPORT GENERIC HELPERS
 # IMPORT GENERIC HELPERS
 #=================================================
 #=================================================
@@ -9,91 +7,35 @@
 source _common.sh
 source _common.sh
 source /usr/share/yunohost/helpers
 source /usr/share/yunohost/helpers
 
 
-#=================================================
-# LOAD SETTINGS
-#=================================================
-ynh_script_progression --message="Loading installation settings..."
-
-app=$YNH_APP_INSTANCE_NAME
-
-domain=$(ynh_app_setting_get --app=$app --key=domain)
-path_url=$(ynh_app_setting_get --app=$app --key=path)
-language=$(ynh_app_setting_get --app=$app --key=language)
-final_path=$(ynh_app_setting_get --app=$app --key=final_path)
-db_name=$(ynh_app_setting_get --app=$app --key=db_name)
-db_user=$db_name
-db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
-
-trustedversion="5.0.0-1+stretch"
-
-#=================================================
-# CHECK VERSION
-#=================================================
-ynh_script_progression --message="Checking version..."
-
-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)..."
-
-# Backup the current version of the app
-ynh_backup_before_upgrade
-ynh_clean_setup () {
-	ynh_clean_check_starting
-	# 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
 # STOP SYSTEMD SERVICE
 #=================================================
 #=================================================
-ynh_script_progression --message="Stopping a systemd service..."
+ynh_script_progression --message="Stopping $app's systemd service..."
 
 
-ynh_systemd_action --service_name=$app-server --action="stop" --log_path="/var/log/$app/${app}_server.log"
-ynh_systemd_action --service_name=$app-agent --action="stop" --log_path="/var/log/$app/${app}_agent.log"
+ynh_systemd_action --service_name="$app-server" --action="stop" --log_path="/var/log/$app/${app}_server.log"
+ynh_systemd_action --service_name="$app-agent" --action="stop" --log_path="/var/log/$app/${app}_agent.log"
 
 
 #=================================================
 #=================================================
 # ENSURE DOWNWARD COMPATIBILITY
 # ENSURE DOWNWARD COMPATIBILITY
 #=================================================
 #=================================================
 ynh_script_progression --message="Ensuring downward compatibility..."
 ynh_script_progression --message="Ensuring downward compatibility..."
 
 
-# If db_name doesn't exist, create it
-if [ -z "$db_name" ]; then
-	db_name=$(ynh_sanitize_dbid --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 "$final_path" ]; then
-	final_path=/var/www/$app
-	ynh_app_setting_set --app=$app --key=final_path --value=$final_path
+if [ "$language" == "fr" ]; then
+    language="fr_FR"
+    ynh_app_setting_set --app="$app" --key="language" --value="$language"
 fi
 fi
 
 
-if [ "$language" == "fr" ]
-then
-	language="fr_FR"
-	ynh_app_setting_set --app=$app --key=language --value=$language
-fi
-
-if [ "$language" == "en" ]
-then
-	language="en_GB"
-	ynh_app_setting_set --app=$app --key=language --value=$language
+if [ "$language" == "en" ]; then
+    language="en_GB"
+    ynh_app_setting_set --app="$app" --key="language" --value="$language"
 fi
 fi
 
 
 export mysqlconn="mysql --user=$db_user --password=$db_pwd --database=$db_name"
 export mysqlconn="mysql --user=$db_user --password=$db_pwd --database=$db_name"
 
 
 # patch to remove old zabbix-client service
 # patch to remove old zabbix-client service
-if [ ! -z "$(yunohost service status | grep zabbix-client)" ]
-then 
-	ynh_script_progression --message="remove zabbix-client old service"
-	yunohost service remove zabbix-client
+if yunohost service status | grep zabbix-client; then
+    ynh_script_progression --message="remove zabbix-client old service"
+    yunohost service remove zabbix-client
 fi
 fi
 
 
 ynh_remove_logrotate
 ynh_remove_logrotate
@@ -105,49 +47,19 @@ ynh_package_update
 ynh_add_config --template="../conf/etc_zabbix_web_zabbix.conf.php" --destination="/etc/zabbix/web/zabbix.conf.php"
 ynh_add_config --template="../conf/etc_zabbix_web_zabbix.conf.php" --destination="/etc/zabbix/web/zabbix.conf.php"
 
 
 chmod 400 "/etc/zabbix/web/zabbix.conf.php"
 chmod 400 "/etc/zabbix/web/zabbix.conf.php"
-chown $app:www-data "/etc/zabbix/web/zabbix.conf.php"
+chown "$app:www-data" "/etc/zabbix/web/zabbix.conf.php"
 
 
-if [ -f "/usr/share/zabbix/conf/zabbix.conf.php" ]
-then
-	ynh_secure_remove --file="/usr/share/zabbix/conf/zabbix.conf.php"
+if [ -f "/usr/share/zabbix/conf/zabbix.conf.php" ]; then
+    ynh_secure_remove --file="/usr/share/zabbix/conf/zabbix.conf.php"
 fi
 fi
 
 
 ln -s "/etc/zabbix/web/zabbix.conf.php" "/usr/share/zabbix/conf/zabbix.conf.php"
 ln -s "/etc/zabbix/web/zabbix.conf.php" "/usr/share/zabbix/conf/zabbix.conf.php"
 
 
 ynh_remove_extra_repo --name=zabbix
 ynh_remove_extra_repo --name=zabbix
 
 
-#=================================================
-# UPGRADE DEPENDENCIES
-#=================================================
-
-if [ "$upgrade_type" == "UPGRADE_APP" ]
-then
-	ynh_script_progression --message="Upgrading dependencies..."
-
-	ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
-	ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="http://repo.zabbix.com/zabbix/5.0/debian $(lsb_release -sc) main" --package="$zabbix_pkg_dependencies" --key="https://repo.zabbix.com/zabbix-official-repo.key"
-fi
-
 chmod 750 "/usr/share/zabbix"
 chmod 750 "/usr/share/zabbix"
 chmod -R o-rwx "/usr/share/zabbix"
 chmod -R o-rwx "/usr/share/zabbix"
-chown -R $app:www-data "/usr/share/zabbix"
-
-#=================================================
-# PHP-FPM CONFIGURATION
-#=================================================
-ynh_script_progression --message="Upgrading PHP-FPM configuration..."
-
-# Create a dedicated PHP-FPM config
-ynh_add_fpm_config
-phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
-
-#=================================================
-# NGINX CONFIGURATION
-#=================================================
-ynh_script_progression --message="Upgrading NGINX web server configuration..."
-
-# Create a dedicated NGINX config
-ynh_add_nginx_config
+chown -R "$app:www-data" "/usr/share/zabbix"
 
 
 #=================================================
 #=================================================
 # SPECIFIC UPGRADE
 # SPECIFIC UPGRADE
@@ -161,43 +73,34 @@ convert_ZabbixDB
 set_mediatype_default_yunohost
 set_mediatype_default_yunohost
 
 
 #=================================================
 #=================================================
-# SETUP SYSTEMD
+# REAPPLY SYSTEM CONFIGURATIONS
 #=================================================
 #=================================================
-ynh_script_progression --message="Upgrading systemd configuration..."
+ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
+
+# Create a dedicated PHP-FPM config
+ynh_add_fpm_config
+
+# Create a dedicated NGINX config
+ynh_add_nginx_config
 
 
 change_timeoutAgent
 change_timeoutAgent
 
 
 systemctl enable zabbix-agent --quiet
 systemctl enable zabbix-agent --quiet
 systemctl enable zabbix-server --quiet
 systemctl enable zabbix-server --quiet
-
-update_initZabbixConf
-
-#=================================================
-# GENERIC FINALIZATION
-#=================================================
-# INTEGRATE SERVICE IN YUNOHOST
-#=================================================
-ynh_script_progression --message="Integrating service in YunoHost..."
-
 yunohost service add snmpd --description="Management of SNMP Daemon"
 yunohost service add snmpd --description="Management of SNMP Daemon"
 yunohost service add zabbix-server --description="Management Zabbix server daemon : collect, agregate, compute and notify" --log="/var/log/$app/${app}_server.log"
 yunohost service add zabbix-server --description="Management Zabbix server daemon : collect, agregate, compute and notify" --log="/var/log/$app/${app}_server.log"
 yunohost service add zabbix-agent --description="Management Zabbix agent daemon : send informations about this host to the server" --log="/var/log/$app/${app}_agent.log"
 yunohost service add zabbix-agent --description="Management Zabbix agent daemon : send informations about this host to the server" --log="/var/log/$app/${app}_agent.log"
 
 
+update_initZabbixConf
+
 #=================================================
 #=================================================
 # START SYSTEMD SERVICE
 # START SYSTEMD SERVICE
 #=================================================
 #=================================================
-ynh_script_progression --message="Starting a systemd service..."
+ynh_script_progression --message="Starting $app's systemd service..." --weight=1
 
 
 # Start a systemd service
 # Start a systemd service
-ynh_systemd_action --service_name=$app-server --action="restart" --log_path="/var/log/$app/${app}_server.log" --line_match="server #0 started"
-ynh_systemd_action --service_name=$app-agent --action="restart" --log_path="/var/log/$app/${app}_agent.log"
-
-#=================================================
-# RELOAD NGINX
-#=================================================
-ynh_script_progression --message="Reloading NGINX web server..."
-
-ynh_systemd_action --service_name=nginx --action=reload
+ynh_systemd_action --service_name="$app-server" --action="restart" --log_path="/var/log/$app/${app}_server.log" --line_match="server #0 started"
+ynh_systemd_action --service_name="$app-agent" --action="restart" --log_path="/var/log/$app/${app}_agent.log"
 
 
 #=================================================
 #=================================================
 # END OF SCRIPT
 # END OF SCRIPT

+ 11 - 0
tests.toml

@@ -0,0 +1,11 @@
+#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json
+
+test_format = 1.0
+
+[default]
+
+    # ------------
+    # Tests to run
+    # ------------
+
+    test_upgrade_from.8f8961c239f890069c867e40005db98465add0c9.name = "5.0.20~ynh2"