Explorar o código

Merge pull request #74 from YunoHost-Apps/upgrade

Upgrade to 6.0~ynh1
yalh76 hai 1 ano
pai
achega
8e4a3d0c65
Modificáronse 24 ficheiros con 441 adicións e 217 borrados
  1. 4 0
      ALL_README.md
  2. 4 2
      README.md
  3. 5 3
      README_es.md
  4. 4 2
      README_eu.md
  5. 4 2
      README_fr.md
  6. 4 2
      README_gl.md
  7. 49 0
      README_id.md
  8. 49 0
      README_nl.md
  9. 49 0
      README_pl.md
  10. 49 0
      README_ru.md
  11. 4 2
      README_zh_Hans.md
  12. 1 1
      conf/nginx.conf
  13. 41 0
      conf/zabbix-cli.toml
  14. 41 0
      conf/zabbix-cli_default.toml
  15. 3 13
      hooks/post_user_create
  16. 1 9
      hooks/post_user_delete
  17. 18 33
      manifest.toml
  18. 2 82
      scripts/_common.sh
  19. 3 0
      scripts/backup
  20. 60 36
      scripts/install
  21. 4 30
      scripts/remove
  22. 3 0
      scripts/restore
  23. 28 0
      scripts/upgrade
  24. 11 0
      tests.toml

+ 4 - 0
ALL_README.md

@@ -5,4 +5,8 @@
 - [Irakurri README euskaraz](README_eu.md)
 - [Lire le README en français](README_fr.md)
 - [Le o README en galego](README_gl.md)
+- [Baca README dalam bahasa bahasa Indonesia](README_id.md)
+- [Lees de README in het Nederlands](README_nl.md)
+- [Przeczytaj README w języku polski](README_pl.md)
+- [Прочитать README на русский](README_ru.md)
 - [阅读中文(简体)的 README](README_zh_Hans.md)

+ 4 - 2
README.md

@@ -5,7 +5,9 @@ It shall NOT be edited by hand.
 
 # Zabbix for YunoHost
 
-[![Integration level](https://dash.yunohost.org/integration/zabbix.svg)](https://dash.yunohost.org/appci/app/zabbix) ![Working status](https://ci-apps.yunohost.org/ci/badges/zabbix.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/zabbix.maintain.svg)
+[![Integration level](https://apps.yunohost.org/badge/integration/zabbix)](https://ci-apps.yunohost.org/ci/apps/zabbix/)
+![Working status](https://apps.yunohost.org/badge/state/zabbix)
+![Maintenance status](https://apps.yunohost.org/badge/maintained/zabbix)
 
 [![Install Zabbix with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=zabbix)
 
@@ -18,7 +20,7 @@ It shall NOT be edited by hand.
 
 A monitoring tool for diverse IT components, including networks, servers, VMs and cloud services.
 
-**Shipped version:** 5.0.41~ynh3
+**Shipped version:** 6.0~ynh1
 
 ## Screenshots
 

+ 5 - 3
README_es.md

@@ -5,7 +5,9 @@ No se debe editar a mano.
 
 # Zabbix para Yunohost
 
-[![Nivel de integración](https://dash.yunohost.org/integration/zabbix.svg)](https://dash.yunohost.org/appci/app/zabbix) ![Estado funcional](https://ci-apps.yunohost.org/ci/badges/zabbix.status.svg) ![Estado En Mantención](https://ci-apps.yunohost.org/ci/badges/zabbix.maintain.svg)
+[![Nivel de integración](https://apps.yunohost.org/badge/integration/zabbix)](https://ci-apps.yunohost.org/ci/apps/zabbix/)
+![Estado funcional](https://apps.yunohost.org/badge/state/zabbix)
+![Estado En Mantención](https://apps.yunohost.org/badge/maintained/zabbix)
 
 [![Instalar Zabbix con Yunhost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=zabbix)
 
@@ -18,7 +20,7 @@ No se debe editar a mano.
 
 A monitoring tool for diverse IT components, including networks, servers, VMs and cloud services.
 
-**Versión actual:** 5.0.41~ynh3
+**Versión actual:** 6.0~ynh1
 
 ## Capturas
 
@@ -34,7 +36,7 @@ A monitoring tool for diverse IT components, including networks, servers, VMs an
 
 ## Información para desarrolladores
 
-Por favor enviar sus correcciones a la [`branch testing`](https://github.com/YunoHost-Apps/zabbix_ynh/tree/testing
+Por favor enviar sus correcciones a la [rama `testing`](https://github.com/YunoHost-Apps/zabbix_ynh/tree/testing).
 
 Para probar la rama `testing`, sigue asÍ:
 

+ 4 - 2
README_eu.md

@@ -5,7 +5,9 @@ EZ editatu eskuz.
 
 # Zabbix YunoHost-erako
 
-[![Integrazio maila](https://dash.yunohost.org/integration/zabbix.svg)](https://dash.yunohost.org/appci/app/zabbix) ![Funtzionamendu egoera](https://ci-apps.yunohost.org/ci/badges/zabbix.status.svg) ![Mantentze egoera](https://ci-apps.yunohost.org/ci/badges/zabbix.maintain.svg)
+[![Integrazio maila](https://apps.yunohost.org/badge/integration/zabbix)](https://ci-apps.yunohost.org/ci/apps/zabbix/)
+![Funtzionamendu egoera](https://apps.yunohost.org/badge/state/zabbix)
+![Mantentze egoera](https://apps.yunohost.org/badge/maintained/zabbix)
 
 [![Instalatu Zabbix YunoHost-ekin](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=zabbix)
 
@@ -18,7 +20,7 @@ EZ editatu eskuz.
 
 A monitoring tool for diverse IT components, including networks, servers, VMs and cloud services.
 
-**Paketatutako bertsioa:** 5.0.41~ynh3
+**Paketatutako bertsioa:** 6.0~ynh1
 
 ## Pantaila-argazkiak
 

+ 4 - 2
README_fr.md

@@ -5,7 +5,9 @@ Il NE doit PAS être modifié à la main.
 
 # Zabbix pour YunoHost
 
-[![Niveau d’inté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://apps.yunohost.org/badge/integration/zabbix)](https://ci-apps.yunohost.org/ci/apps/zabbix/)
+![Statut du fonctionnement](https://apps.yunohost.org/badge/state/zabbix)
+![Statut de maintenance](https://apps.yunohost.org/badge/maintained/zabbix)
 
 [![Installer Zabbix avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=zabbix)
 
@@ -19,7 +21,7 @@ Il NE doit PAS être modifié à la main.
 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~ynh3
+**Version incluse :** 6.0~ynh1
 
 ## Captures d’écran
 

+ 4 - 2
README_gl.md

@@ -5,7 +5,9 @@ NON debe editarse manualmente.
 
 # Zabbix para YunoHost
 
-[![Nivel de integración](https://dash.yunohost.org/integration/zabbix.svg)](https://dash.yunohost.org/appci/app/zabbix) ![Estado de funcionamento](https://ci-apps.yunohost.org/ci/badges/zabbix.status.svg) ![Estado de mantemento](https://ci-apps.yunohost.org/ci/badges/zabbix.maintain.svg)
+[![Nivel de integración](https://apps.yunohost.org/badge/integration/zabbix)](https://ci-apps.yunohost.org/ci/apps/zabbix/)
+![Estado de funcionamento](https://apps.yunohost.org/badge/state/zabbix)
+![Estado de mantemento](https://apps.yunohost.org/badge/maintained/zabbix)
 
 [![Instalar Zabbix con YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=zabbix)
 
@@ -18,7 +20,7 @@ NON debe editarse manualmente.
 
 A monitoring tool for diverse IT components, including networks, servers, VMs and cloud services.
 
-**Versión proporcionada:** 5.0.41~ynh3
+**Versión proporcionada:** 6.0~ynh1
 
 ## Capturas de pantalla
 

+ 49 - 0
README_id.md

@@ -0,0 +1,49 @@
+<!--
+N.B.: README ini dibuat secara otomatis oleh <https://github.com/YunoHost/apps/tree/master/tools/readme_generator>
+Ini TIDAK boleh diedit dengan tangan.
+-->
+
+# Zabbix untuk YunoHost
+
+[![Tingkat integrasi](https://apps.yunohost.org/badge/integration/zabbix)](https://ci-apps.yunohost.org/ci/apps/zabbix/)
+![Status kerja](https://apps.yunohost.org/badge/state/zabbix)
+![Status pemeliharaan](https://apps.yunohost.org/badge/maintained/zabbix)
+
+[![Pasang Zabbix dengan YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=zabbix)
+
+*[Baca README ini dengan bahasa yang lain.](./ALL_README.md)*
+
+> *Paket ini memperbolehkan Anda untuk memasang Zabbix secara cepat dan mudah pada server YunoHost.*  
+> *Bila Anda tidak mempunyai YunoHost, silakan berkonsultasi dengan [panduan](https://yunohost.org/install) untuk mempelajari bagaimana untuk memasangnya.*
+
+## Ringkasan
+
+A monitoring tool for diverse IT components, including networks, servers, VMs and cloud services.
+
+**Versi terkirim:** 6.0~ynh1
+
+## Tangkapan Layar
+
+![Tangkapan Layar pada Zabbix](./doc/screenshots/screenshot1.png)
+
+## Dokumentasi dan sumber daya
+
+- Website aplikasi resmi: <https://www.zabbix.com>
+- Dokumentasi admin resmi: <https://www.zabbix.com/manuals>
+- Depot kode aplikasi hulu: <https://github.com/zabbix/zabbix>
+- Gudang YunoHost: <https://apps.yunohost.org/app/zabbix>
+- Laporkan bug: <https://github.com/YunoHost-Apps/zabbix_ynh/issues>
+
+## Info developer
+
+Silakan kirim pull request ke [`testing` branch](https://github.com/YunoHost-Apps/zabbix_ynh/tree/testing).
+
+Untuk mencoba branch `testing`, silakan dilanjutkan seperti:
+
+```bash
+sudo yunohost app install https://github.com/YunoHost-Apps/zabbix_ynh/tree/testing --debug
+atau
+sudo yunohost app upgrade zabbix -u https://github.com/YunoHost-Apps/zabbix_ynh/tree/testing --debug
+```
+
+**Info lebih lanjut mengenai pemaketan aplikasi:** <https://yunohost.org/packaging_apps>

+ 49 - 0
README_nl.md

@@ -0,0 +1,49 @@
+<!--
+NB: Deze README is automatisch gegenereerd door <https://github.com/YunoHost/apps/tree/master/tools/readme_generator>
+Hij mag NIET handmatig aangepast worden.
+-->
+
+# Zabbix voor Yunohost
+
+[![Integratieniveau](https://apps.yunohost.org/badge/integration/zabbix)](https://ci-apps.yunohost.org/ci/apps/zabbix/)
+![Mate van functioneren](https://apps.yunohost.org/badge/state/zabbix)
+![Onderhoudsstatus](https://apps.yunohost.org/badge/maintained/zabbix)
+
+[![Zabbix met Yunohost installeren](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=zabbix)
+
+*[Deze README in een andere taal lezen.](./ALL_README.md)*
+
+> *Met dit pakket kun je Zabbix snel en eenvoudig op een YunoHost-server installeren.*  
+> *Als je nog geen YunoHost hebt, lees dan [de installatiehandleiding](https://yunohost.org/install), om te zien hoe je 'm installeert.*
+
+## Overzicht
+
+A monitoring tool for diverse IT components, including networks, servers, VMs and cloud services.
+
+**Geleverde versie:** 6.0~ynh1
+
+## Schermafdrukken
+
+![Schermafdrukken van Zabbix](./doc/screenshots/screenshot1.png)
+
+## Documentatie en bronnen
+
+- Officiele website van de app: <https://www.zabbix.com>
+- Officiele beheerdersdocumentatie: <https://www.zabbix.com/manuals>
+- Upstream app codedepot: <https://github.com/zabbix/zabbix>
+- YunoHost-store: <https://apps.yunohost.org/app/zabbix>
+- Meld een bug: <https://github.com/YunoHost-Apps/zabbix_ynh/issues>
+
+## Ontwikkelaarsinformatie
+
+Stuur je pull request alsjeblieft naar de [`testing`-branch](https://github.com/YunoHost-Apps/zabbix_ynh/tree/testing).
+
+Om de `testing`-branch uit te proberen, ga als volgt te werk:
+
+```bash
+sudo yunohost app install https://github.com/YunoHost-Apps/zabbix_ynh/tree/testing --debug
+of
+sudo yunohost app upgrade zabbix -u https://github.com/YunoHost-Apps/zabbix_ynh/tree/testing --debug
+```
+
+**Verdere informatie over app-packaging:** <https://yunohost.org/packaging_apps>

+ 49 - 0
README_pl.md

@@ -0,0 +1,49 @@
+<!--
+To README zostało automatycznie wygenerowane przez <https://github.com/YunoHost/apps/tree/master/tools/readme_generator>
+Nie powinno być ono edytowane ręcznie.
+-->
+
+# Zabbix dla YunoHost
+
+[![Poziom integracji](https://apps.yunohost.org/badge/integration/zabbix)](https://ci-apps.yunohost.org/ci/apps/zabbix/)
+![Status działania](https://apps.yunohost.org/badge/state/zabbix)
+![Status utrzymania](https://apps.yunohost.org/badge/maintained/zabbix)
+
+[![Zainstaluj Zabbix z YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=zabbix)
+
+*[Przeczytaj plik README w innym języku.](./ALL_README.md)*
+
+> *Ta aplikacja pozwala na szybką i prostą instalację Zabbix na serwerze YunoHost.*  
+> *Jeżeli nie masz YunoHost zapoznaj się z [poradnikiem](https://yunohost.org/install) instalacji.*
+
+## Przegląd
+
+A monitoring tool for diverse IT components, including networks, servers, VMs and cloud services.
+
+**Dostarczona wersja:** 6.0~ynh1
+
+## Zrzuty ekranu
+
+![Zrzut ekranu z Zabbix](./doc/screenshots/screenshot1.png)
+
+## Dokumentacja i zasoby
+
+- Oficjalna strona aplikacji: <https://www.zabbix.com>
+- Oficjalna dokumentacja dla administratora: <https://www.zabbix.com/manuals>
+- Repozytorium z kodem źródłowym: <https://github.com/zabbix/zabbix>
+- Sklep YunoHost: <https://apps.yunohost.org/app/zabbix>
+- Zgłaszanie błędów: <https://github.com/YunoHost-Apps/zabbix_ynh/issues>
+
+## Informacje od twórców
+
+Wyślij swój pull request do [gałęzi `testing`](https://github.com/YunoHost-Apps/zabbix_ynh/tree/testing).
+
+Aby wypróbować gałąź `testing` postępuj zgodnie z instrukcjami:
+
+```bash
+sudo yunohost app install https://github.com/YunoHost-Apps/zabbix_ynh/tree/testing --debug
+lub
+sudo yunohost app upgrade zabbix -u https://github.com/YunoHost-Apps/zabbix_ynh/tree/testing --debug
+```
+
+**Więcej informacji o tworzeniu paczek aplikacji:** <https://yunohost.org/packaging_apps>

+ 49 - 0
README_ru.md

@@ -0,0 +1,49 @@
+<!--
+Важно: этот README был автоматически сгенерирован <https://github.com/YunoHost/apps/tree/master/tools/readme_generator>
+Он НЕ ДОЛЖЕН редактироваться вручную.
+-->
+
+# Zabbix для YunoHost
+
+[![Уровень интеграции](https://apps.yunohost.org/badge/integration/zabbix)](https://ci-apps.yunohost.org/ci/apps/zabbix/)
+![Состояние работы](https://apps.yunohost.org/badge/state/zabbix)
+![Состояние сопровождения](https://apps.yunohost.org/badge/maintained/zabbix)
+
+[![Установите Zabbix с YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=zabbix)
+
+*[Прочтите этот README на других языках.](./ALL_README.md)*
+
+> *Этот пакет позволяет Вам установить Zabbix быстро и просто на YunoHost-сервер.*  
+> *Если у Вас нет YunoHost, пожалуйста, посмотрите [инструкцию](https://yunohost.org/install), чтобы узнать, как установить его.*
+
+## Обзор
+
+A monitoring tool for diverse IT components, including networks, servers, VMs and cloud services.
+
+**Поставляемая версия:** 6.0~ynh1
+
+## Снимки экрана
+
+![Снимок экрана Zabbix](./doc/screenshots/screenshot1.png)
+
+## Документация и ресурсы
+
+- Официальный веб-сайт приложения: <https://www.zabbix.com>
+- Официальная документация администратора: <https://www.zabbix.com/manuals>
+- Репозиторий кода главной ветки приложения: <https://github.com/zabbix/zabbix>
+- Магазин YunoHost: <https://apps.yunohost.org/app/zabbix>
+- Сообщите об ошибке: <https://github.com/YunoHost-Apps/zabbix_ynh/issues>
+
+## Информация для разработчиков
+
+Пришлите Ваш запрос на слияние в [ветку `testing`](https://github.com/YunoHost-Apps/zabbix_ynh/tree/testing).
+
+Чтобы попробовать ветку `testing`, пожалуйста, сделайте что-то вроде этого:
+
+```bash
+sudo yunohost app install 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
+```
+
+**Больше информации о пакетировании приложений:** <https://yunohost.org/packaging_apps>

+ 4 - 2
README_zh_Hans.md

@@ -5,7 +5,9 @@
 
 # YunoHost 上的 Zabbix
 
-[![集成程度](https://dash.yunohost.org/integration/zabbix.svg)](https://dash.yunohost.org/appci/app/zabbix) ![工作状态](https://ci-apps.yunohost.org/ci/badges/zabbix.status.svg) ![维护状态](https://ci-apps.yunohost.org/ci/badges/zabbix.maintain.svg)
+[![集成程度](https://apps.yunohost.org/badge/integration/zabbix)](https://ci-apps.yunohost.org/ci/apps/zabbix/)
+![工作状态](https://apps.yunohost.org/badge/state/zabbix)
+![维护状态](https://apps.yunohost.org/badge/maintained/zabbix)
 
 [![使用 YunoHost 安装 Zabbix](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=zabbix)
 
@@ -18,7 +20,7 @@
 
 A monitoring tool for diverse IT components, including networks, servers, VMs and cloud services.
 
-**分发版本:** 5.0.41~ynh3
+**分发版本:** 6.0~ynh1
 
 ## 截图
 

+ 1 - 1
conf/nginx.conf

@@ -4,7 +4,7 @@ location __PATH__/ {
   # Path to source
   alias /usr/share/zabbix/;
 
-  index index_http.php;
+  index index.php;
 
   # Common parameter to increase upload size limit in conjunction with dedicated php-fpm file
   #client_max_body_size 50M;

+ 41 - 0
conf/zabbix-cli.toml

@@ -0,0 +1,41 @@
+[api]
+url = "https://__DOMAIN____PATH__"
+username = "__ZABBIX_USERNAME__"
+password = "__ZABBIX_PASSWORD__"
+auth_token = ""
+verify_ssl = false
+
+[app]
+default_hostgroups = [
+    "All-hosts",
+]
+default_admin_usergroups = []
+default_create_user_usergroups = []
+default_notification_users_usergroups = [
+    "All-notification-users",
+]
+export_directory = "/usr/share/zabbix-cli/exports"
+export_format = "json"
+export_timestamps = false
+use_auth_token_file = true
+auth_token_file = "/usr/share/zabbix-cli/.zabbix-cli_auth_token"
+auth_file = "/usr/share/zabbix-cli/.zabbix-cli_auth"
+history = true
+history_file = "/usr/share/zabbix-cli/history"
+bulk_mode = "strict"
+allow_insecure_auth_file = true
+legacy_json_format = false
+
+[app.output]
+format = "table"
+color = true
+paging = false
+theme = "default"
+
+[logging]
+enabled = true
+log_level = "INFO"
+log_file = "/usr/share/zabbix-cli/log/zabbix-cli.log"
+
+[plugins]
+

+ 41 - 0
conf/zabbix-cli_default.toml

@@ -0,0 +1,41 @@
+[api]
+url = "https://__DOMAIN____PATH__"
+username = "Admin"
+password = "zabbix"
+auth_token = ""
+verify_ssl = false
+
+[app]
+default_hostgroups = [
+    "All-hosts",
+]
+default_admin_usergroups = []
+default_create_user_usergroups = []
+default_notification_users_usergroups = [
+    "All-notification-users",
+]
+export_directory = "/usr/share/zabbix-cli/exports"
+export_format = "json"
+export_timestamps = false
+use_auth_token_file = true
+auth_token_file = "/usr/share/zabbix-cli/.zabbix-cli_auth_token"
+auth_file = "/usr/share/zabbix-cli/.zabbix-cli_auth"
+history = true
+history_file = "/usr/share/zabbix-cli/history"
+bulk_mode = "strict"
+allow_insecure_auth_file = true
+legacy_json_format = false
+
+[app.output]
+format = "table"
+color = true
+paging = false
+theme = "default"
+
+[logging]
+enabled = true
+log_level = "INFO"
+log_file = "/usr/share/zabbix-cli/log/zabbix-cli.log"
+
+[plugins]
+

+ 3 - 13
hooks/post_user_create

@@ -2,17 +2,7 @@
 source /usr/share/yunohost/helpers
 
 user=$1
-app=zabbix
 
-surname=$(ynh_user_get_info --username=$user --key=lastname)
-name=$(ynh_user_get_info --username=$user --key=firstname)
-db_name=$(ynh_app_setting_get --app=$app --key=db_name)
-db_user=$(ynh_app_setting_get --app=$app --key=db_user)
-db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
-language=$(ynh_app_setting_get --app=$app --key=language)
-
-mysqlconn="mysql --user=$db_user --password=$db_pwd --database=$db_name"
-
-lastid=$($mysqlconn -BN -e "select userid from users order by userid desc limit 1")
-lastid=$((lastid+1))
-$mysqlconn -e "INSERT INTO \`users\` (\`userid\`, \`alias\`, \`name\`, \`surname\`, \`passwd\`, \`url\`, \`autologin\`, \`autologout\`, \`lang\`, \`refresh\`, \`type\`, \`theme\`, \`attempt_failed\`, \`attempt_ip\`, \`attempt_clock\`, \`rows_per_page\`) VALUES ("$lastid",'"$user"', '"$name"', '"$surname"', '5fce1b3e34b520afeffb37ce08c7cd66', '', 0, '0', '"$language"', '30s', 1, 'default', 0, '', 0, 50);"
+lastname=$(ynh_user_get_info --username=$user --key=lastname)
+firstname=$(ynh_user_get_info --username=$user --key=firstname)
+/usr/share/zabbix-cli/bin/zabbix-cli --config /usr/share/zabbix-cli/zabbix-cli.toml create_user $user --firstname $firstname --lastname $lastname --role user --groups 8

+ 1 - 9
hooks/post_user_delete

@@ -1,13 +1,5 @@
 #!/bin/bash
-source /usr/share/yunohost/helpers
 
 user=$1
-app=zabbix
 
-db_name=$(ynh_app_setting_get --app=$app --key=db_name)
-db_user=$(ynh_app_setting_get --app=$app --key=db_user)
-db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
-
-mysqlconn="mysql --user=$db_user --password=$db_pwd --database=$db_name"
-
-$mysqlconn -e "DELETE FROM users WHERE alias=\"$1\";"
+/usr/share/zabbix-cli/bin/zabbix-cli --config /usr/share/zabbix-cli/zabbix-cli.toml  remove_user $user

+ 18 - 33
manifest.toml

@@ -7,7 +7,7 @@ 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~ynh3"
+version = "6.0~ynh1"
 
 maintainers = []
 
@@ -19,11 +19,14 @@ code = "https://github.com/zabbix/zabbix"
 cpe = "cpe:2.3:a:zabbix:zabbix"
 
 [integration]
-yunohost = ">= 11.2"
+yunohost = ">= 11.2.30"
 architectures = ["amd64"]
 multi_instance = false
+
 ldap = true
+
 sso = true
+
 disk = "500M"
 ram.build = "200M"
 ram.runtime = "200M"
@@ -54,52 +57,34 @@ ram.runtime = "200M"
 
 [resources]
     [resources.system_user]
+    # This will provision/deprovision a unix system user
 
     [resources.install_dir]
+    # This will create/remove the install dir as /var/www/$app
+    # and store the corresponding setting $install_dir
 
     [resources.permissions]
+    # This will configure SSOwat permission for $domain/$path/
+    # The initial allowed group of user is configured via the init_main_permission question (public=visitors, private=all_users)
     main.url = "/"
 
-    [resources.ports]
-    active-checks.default = 10051
-
     [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",
+        "php8.2-fpm",
         "mariadb-server",
+        "python3-venv",
     ]
 
     [resources.apt.extras.zabbix]
-    repo = "http://repo.zabbix.com/zabbix/5.0/debian __YNH_DEBIAN_VERSION__ main"
+    repo = "deb https://repo.zabbix.com/zabbix/6.0/debian __YNH_DEBIAN_VERSION__ main"
     key = "https://repo.zabbix.com/zabbix-official-repo.key"
     packages = [
-        "zabbix-agent",
-        "zabbix-frontend-php",
         "zabbix-server-mysql",
-    ]
+        "zabbix-frontend-php",
+        "zabbix-sql-scripts",
+        "zabbix-agent",
+        ]
 
     [resources.database]
+    # This will automatically provision/deprovison a DB and store the corresponding credentials in settings $db_user, $db_name, $db_pwd
     type = "mysql"

+ 2 - 82
scripts/_common.sh

@@ -89,67 +89,7 @@ import_template () {
 
 	systemctl restart zabbix-agent
 
-	# Temporarily enable visitors if needed...
-	local visitors_enabled=$(ynh_permission_has_user "main" "visitors" && echo yes || echo no)
-	if [[ $visitors_enabled == "no" ]]; then
-	    ynh_permission_update --permission "main" --add "visitors"
-	fi
- 
-	curlOptions="--noproxy $domain -k -s --cookie cookiejar.txt --cookie-jar cookiejar.txt --resolve $domain:443:127.0.0.1"
-
-	curl -L $curlOptions \
-					--form "enter=Sign+in" \
-					--form "name=Admin" \
-					--form "password=zabbix" \
-					"$zabbixFullpath/index.php"
-
-	if [ $? -eq 0 ]
-	then
-		sid=$(curl $curlOptions \
-						"$zabbixFullpath/conf.import.php?rules_preset=template" \
-						| grep -Po 'name="sid" value="\K([a-z0-9]{16})(?=")' )
-
-		importState=$(curl $curlOptions \
-						--form "config=1" \
-						--form "import_file=@$localpath" \
-						--form "rules[groups][createMissing]=1" \
-						--form "rules[templates][updateExisting]=1" \
-						--form "rules[templates][createMissing]=1" \
-						--form "rules[templateScreens][updateExisting]=1" \
-						--form "rules[templateScreens][createMissing]=1" \
-						--form "rules[templateLinkage][createMissing]=1" \
-						--form "rules[applications][createMissing]=1" \
-						--form "rules[items][updateExisting]=1" \
-						--form "rules[items][createMissing]=1" \
-						--form "rules[discoveryRules][updateExisting]=1" \
-						--form "rules[discoveryRules][createMissing]=1" \
-						--form "rules[triggers][updateExisting]=1" \
-						--form "rules[triggers][createMissing]=1" \
-						--form "rules[graphs][updateExisting]=1" \
-						--form "rules[graphs][createMissing]=1" \
-						--form "rules[httptests][updateExisting]=1" \
-						--form "rules[httptests][createMissing]=1" \
-						--form "rules[valueMaps][createMissing]=1" \
-						--form "import=Import" \
-						--form "backurl=templates.php" \
-						--form "form_refresh=1" \
-						--form "sid=${sid}" \ \
-						"${zabbixFullpath}/conf.import.php?rules_preset=template" \
-						| grep -c "Imported successfully")
-
-		if [ "$importState" -eq "1" ]
-		then
-			ynh_print_info --message="YunoHost template imported !"
-		else
-			ynh_print_warn --message="YunoHost template not imported !"
-		fi
-	else
-		ynh_print_warn --message="Admin user cannot connect to the interface !"
-	fi
-
-	if [[ $visitors_enabled == "no" ]]; then
-	    ynh_permission_update --permission "main" --remove "visitors"
-        fi
+	/usr/share/zabbix-cli/bin/zabbix-cli --config /usr/share/zabbix-cli/zabbix-cli.toml import_configuration $localpath
 }
 
 # Link YunoHost template to Zabbix server
@@ -157,27 +97,7 @@ import_template () {
 link_template () {
 	ynh_print_info --message="Link YunoHost template to Zabbix server"
 
-	# Temporarily enable visitors if needed...
-	local visitors_enabled=$(ynh_permission_has_user "main" "visitors" && echo yes || echo no)
-	if [[ $visitors_enabled == "no" ]]; then
-	    ynh_permission_update --permission "main" --add "visitors"
-	fi
-
-	#apply template to host
-	tokenapi=$(curl --noproxy $domain -k -s --resolve $domain:443:127.0.0.1 --header "Content-Type: application/json" --request POST --data '{ "jsonrpc": "2.0","method": "user.login","params": {"user": "Admin","password": "zabbix"},"id": 1,"auth": null}' "${zabbixFullpath}/api_jsonrpc.php" | jq -r '.result')
-	zabbixHostID=$(curl --noproxy $domain -k -s --resolve $domain:443:127.0.0.1 --header "Content-Type: application/json" --request POST --data '{"jsonrpc":"2.0","method":"host.get","params":{"filter":{"host":["Zabbix server"]}},"auth":"'"$tokenapi"'","id":1}' "${zabbixFullpath}/api_jsonrpc.php" | jq -r '.result[0].hostid')
-	zabbixTemplateID=$(curl --noproxy $domain -k -s --resolve $domain:443:127.0.0.1 --header "Content-Type: application/json" --request POST --data '{"jsonrpc":"2.0","method":"template.get","params":{"filter":{"host":["Template Yunohost"]}},"auth":"'"$tokenapi"'","id":1}' "${zabbixFullpath}/api_jsonrpc.php" | jq -r '.result[0].templateid')
-	applyTemplate=$(curl --noproxy $domain -k -s --resolve $domain:443:127.0.0.1 --header "Content-Type: application/json" --request POST --data '{"jsonrpc":"2.0","method":"host.massadd","params":{"hosts":[{"hostid":"'"$zabbixHostID"'"}],"templates":[{"templateid":"'"$zabbixTemplateID"'"}]},"auth":"'"$tokenapi"'","id":1}' "${zabbixFullpath}/api_jsonrpc.php" | jq -r '.result.hostids[]')
-	if [ "$applyTemplate" -eq "$zabbixHostID" ]
-	then
-		ynh_print_info --message="YunoHost template linked to Zabbix server !"
-	else
-		ynh_print_warn --message="YunoHost template not linked to Zabbix server !"
-	fi
-
- 	if [[ $visitors_enabled == "no" ]]; then
-	    ynh_permission_update --permission "main" --remove "visitors"
-        fi
+	/usr/share/zabbix-cli/bin/zabbix-cli --config /usr/share/zabbix-cli/zabbix-cli.toml link_template_to_host "Template Yunohost" "Zabbix server"
 }
 
 # Check if Zabbix server is started

+ 3 - 0
scripts/backup

@@ -39,6 +39,9 @@ ynh_backup --src_path="/etc/zabbix/zabbix_agentd.d"
 # Backup sudo file
 ynh_backup --src_path="/etc/sudoers.d/zabbix"
 
+# Backup zabbix-cli
+ynh_backup --src_path="/usr/share/zabbix-cli"
+
 #=================================================
 # BACKUP THE MYSQL DATABASE
 #=================================================

+ 60 - 36
scripts/install

@@ -7,6 +7,16 @@
 source _common.sh
 source /usr/share/yunohost/helpers
 
+#=================================================
+# INITIALIZE AND STORE SETTINGS
+#=================================================
+
+zabbix_username="svc_${app}_ldap"
+zabbix_password=$(ynh_string_random --length=32)
+
+ynh_app_setting_set --app="$app" --key=zabbix_username --value="$zabbix_username"
+ynh_app_setting_set --app="$app" --key=zabbix_password --value="$zabbix_password"
+
 #=================================================
 # DOWNLOAD, CHECK AND UNPACK SOURCE
 #=================================================
@@ -23,41 +33,14 @@ ynh_script_progression --message="Import default data in database..."
 export mysqlconn="mysql --user=$db_user --password=$db_pwd --database=$db_name"
 $mysqlconn -e "ALTER DATABASE $db_name CHARACTER SET utf8 COLLATE utf8_general_ci;"
 
-zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | $mysqlconn
+zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | $mysqlconn
 
 convert_ZabbixDB
 
-#sso integration
-$mysqlconn -e "UPDATE \`config\` SET \`http_auth_enabled\` = '1', \`http_login_form\` = '1' WHERE \`config\`.\`configid\` = 1;"
-
-#admin creation
-surname=$(ynh_user_get_info "$admin" lastname)
-name=$(ynh_user_get_info "$admin" firstname)
-
-$mysqlconn -e "INSERT INTO \`users\` (\`userid\`,\`alias\`, \`name\`, \`surname\`, \`passwd\`, \`url\`, \`autologin\`, \`autologout\`, \`lang\`, \`refresh\`, \`type\`, \`theme\`, \`attempt_failed\`, \`attempt_ip\`, \`attempt_clock\`, \`rows_per_page\`) VALUES (3,'$admin', '$admin', '$admin', '5fce1b3e34b520afeffb37ce08c7cd66', '', 0, '0', '$language', '30s', 3, 'default', 0, '', 0, 50);"
-$mysqlconn -e "INSERT INTO \`users_groups\` (\`id\`, \`usrgrpid\`, \`userid\`) VALUES (5, 7, 3);"
-
-#users creation in zabbix database
-i=4
-for user in $(ynh_user_list);
-do
-	if [ "$user" != "$admin" ]
-	then
-		surname=$(ynh_user_get_info --username="$user" --key=lastname)
-		name=$(ynh_user_get_info --username="$user" --key=firstname)
-		$mysqlconn -e "INSERT INTO \`users\` (\`userid\`, \`alias\`, \`name\`, \`surname\`, \`passwd\`, \`url\`, \`autologin\`, \`autologout\`, \`lang\`, \`refresh\`, \`type\`, \`theme\`, \`attempt_failed\`, \`attempt_ip\`, \`attempt_clock\`, \`rows_per_page\`) VALUES ($i,'$user', '$name', '$surname', '5fce1b3e34b520afeffb37ce08c7cd66', '', 0, '0', '$language', '30s', 1, 'default', 0, '', 0, 50);"
-		i=$((i+1))
-	fi
-done
-
-disable_guest_user
-
-set_mediatype_default_yunohost
-
 #=================================================
-# ADD A CONFIGURATION
+# APP INITIAL CONFIGURATION
 #=================================================
-ynh_script_progression --message="Adding a configuration file..."
+ynh_script_progression --message="Adding $app's configuration files..."
 
 ynh_add_config --template="../conf/etc_zabbix_web_zabbix.conf.php" --destination="/etc/zabbix/web/zabbix.conf.php"
 
@@ -76,10 +59,10 @@ ynh_script_progression --message="Adding system configurations related to $app..
 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
+# Create a PHP-FPM config (with conf/extra_php-fpm.conf being appended to it)
 ynh_add_fpm_config
 
-# Create a dedicated NGINX config
+# Create a dedicated NGINX config using the conf/nginx.conf template
 ynh_add_nginx_config
 
 change_timeoutAgent
@@ -93,16 +76,57 @@ yunohost service add zabbix-agent --description="Management Zabbix agent daemon
 update_initZabbixConf
 
 #=================================================
-# SETUP APPLICATION WITH CURL
+# SETUP APPLICATION
 #=================================================
-ynh_script_progression --message="Setting up application with CURL..."
+ynh_script_progression --message="Setting up application..."
 
-import_template
+ynh_print_info --message="Installing zabbix-cli"
+mkdir -p /usr/share/zabbix-cli
+python3 -m venv /usr/share/zabbix-cli
+/usr/share/zabbix-cli/bin/pip install zabbix-cli-uio
 
-link_template
+# ldap zabbix user creation
+ynh_print_info --message="Creating ldap zabbix user"
+yunohost user create "$zabbix_username" --fullname "${zabbix_username//_}" --domain "$domain" --password "$zabbix_password" -q 0
+ynh_add_config --template="zabbix-cli_default.toml" --destination="/usr/share/zabbix-cli/zabbix-cli.toml"
+/usr/share/zabbix-cli/bin/zabbix-cli --config /usr/share/zabbix-cli/zabbix-cli.toml create_user $zabbix_username --firstname $zabbix_username --lastname $zabbix_username --passwd $zabbix_password --role superadmin --groups 7
+ynh_add_config --template="zabbix-cli.toml" --destination="/usr/share/zabbix-cli/zabbix-cli.toml"
+ynh_secure_remove --file="/usr/share/zabbix-cli/.zabbix-cli_auth_token"
+
+# sso integration activation
+ynh_print_info --message="Enabling LDAP authentication"
+$mysqlconn -e "UPDATE \`config\` SET \`http_auth_enabled\` = '1', \`http_login_form\` = '1' WHERE \`config\`.\`configid\` = 1;"
+#Ldap integration activation
+$mysqlconn -e "UPDATE \`config\` SET \`authentication_type\` = '1', \`ldap_host\` = '127.0.0.1', \`ldap_port\` = '389', \`ldap_base_dn\` = 'ou=users,dc=yunohost,dc=org', \`ldap_search_attribute\` = 'uid' WHERE \`config\`.\`configid\` = 1;"
+
+# admin user creation
+ynh_print_info --message="Creating admin user"
+lastname=$(ynh_user_get_info "$admin" lastname)
+firstname=$(ynh_user_get_info "$admin" firstname)
+/usr/share/zabbix-cli/bin/zabbix-cli --config /usr/share/zabbix-cli/zabbix-cli.toml create_user $admin --firstname $firstname --lastname $lastname --role superadmin --groups 7
+
+# users creation
+ynh_print_info --message="Creating all users"
+for user in $(ynh_user_list);
+do
+	if [ "$user" != "$admin" ] && [ "$user" != "$zabbix_username" ] && [ "$user" != "admin" ] && [ "$user" != "guest" ]
+	then
+		lastname=$(ynh_user_get_info --username="$user" --key=lastname)
+		firstname=$(ynh_user_get_info --username="$user" --key=firstname)
+		/usr/share/zabbix-cli/bin/zabbix-cli --config /usr/share/zabbix-cli/zabbix-cli.toml create_user $user --firstname $firstname --lastname $lastname --role user --groups 8
+	fi
+done
+
+disable_guest_user
 
 disable_admin_user
 
+set_mediatype_default_yunohost
+
+import_template
+
+link_template
+
 #=================================================
 # START SYSTEMD SERVICE
 #=================================================

+ 4 - 30
scripts/remove

@@ -12,6 +12,8 @@ source /usr/share/yunohost/helpers
 #=================================================
 ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
 
+ynh_exec_warn_less yunohost user delete $zabbix_username --purge
+
 # 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"
@@ -24,48 +26,20 @@ yunohost service remove snmpd
 yunohost service remove zabbix-server
 yunohost service remove zabbix-agent
 
-# Remove the dedicated NGINX config
 ynh_remove_nginx_config
 
-# Remove the dedicated PHP-FPM config
 ynh_remove_fpm_config
 
-#=================================================
-# REMOVE DEPENDENCIES
-#=================================================
-ynh_script_progression --message="Removing $app's configuration..."
+# Remove other various files specific to the app... such as:
 
-# Remove config file detection
 delete_initZabbixConf
-
 ynh_secure_remove --file="/usr/share/$app"
-
-#=================================================
-# REMOVE VARIOUS FILES
-#=================================================
-ynh_script_progression --message="Removing various files..."
-
-# Remove a directory securely
 ynh_secure_remove --file="/etc/$app"
-
-# Remove the log files
-
 ynh_secure_remove --file="/run/$app"
 
 ynh_secure_remove --file="/etc/sudoers.d/$app"
 
-# 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)
-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
+ynh_secure_remove --file="/usr/share/zabbix-cli"
 
 #=================================================
 # END OF SCRIPT

+ 3 - 0
scripts/restore

@@ -51,6 +51,9 @@ fi
 # Restore sudo file
 ynh_restore_file --origin_path="/etc/sudoers.d/zabbix"
 
+# Restore zabbix-cli
+ynh_restore_file --origin_path="/usr/share/zabbix-cli"
+
 #=================================================
 # RESTORE SYSTEM CONFIGURATIONS
 #=================================================

+ 28 - 0
scripts/upgrade

@@ -93,6 +93,34 @@ yunohost service add zabbix-agent --description="Management Zabbix agent daemon
 
 update_initZabbixConf
 
+#=================================================
+# SETUP APPLICATION
+#=================================================
+ynh_script_progression --message="Setting up application..."
+
+if [ ! -d "/usr/share/zabbix-cli" ]; then
+    ynh_systemd_action --service_name="$app-server" --action="restart" --log_path="/var/log/$app/${app}_server.log" --line_match="server #0 started"
+    zabbix_username="svc_${app}_ldap"
+    zabbix_password=$(ynh_string_random --length=32)
+    ynh_app_setting_set --app="$app" --key=zabbix_username --value="$zabbix_username"
+    ynh_app_setting_set --app="$app" --key=zabbix_password --value="$zabbix_password"
+    yunohost user create "$zabbix_username" --fullname "${zabbix_username//_}" --domain "$domain" --password "$zabbix_password" -q 0
+
+    mkdir -p /usr/share/zabbix-cli
+    python3 -m venv /usr/share/zabbix-cli
+    /usr/share/zabbix-cli/bin/pip install zabbix-cli-uio
+    ynh_add_config --template="zabbix-cli_default.toml" --destination="/usr/share/zabbix-cli/zabbix-cli.toml"
+    enable_admin_user
+    /usr/share/zabbix-cli/bin/zabbix-cli --config /usr/share/zabbix-cli/zabbix-cli.toml create_user $zabbix_username --firstname $zabbix_username --lastname $zabbix_username --passwd $zabbix_password --role superadmin --groups 7
+    disable_admin_user
+    ynh_add_config --template="zabbix-cli.toml" --destination="/usr/share/zabbix-cli/zabbix-cli.toml"
+    ynh_secure_remove --file="/usr/share/zabbix-cli/.zabbix-cli_auth_token"
+fi
+
+import_template
+
+link_template
+
 #=================================================
 # START SYSTEMD SERVICE
 #=================================================

+ 11 - 0
tests.toml

@@ -8,4 +8,15 @@ test_format = 1.0
     # Tests to run
     # ------------
 
+    exclude = ["install.private"]
+
+    # -------------------------------
+    # Default args to use for install
+    # -------------------------------
+
+    # -------------------------------
+    # Commits to test upgrade from
+    # -------------------------------
+
     test_upgrade_from.8f8961c239f890069c867e40005db98465add0c9.name = "5.0.20~ynh2"
+    test_upgrade_from.2791ab29129baca48685277ce82ef763058b10cf.name = "5.0.41~ynh3"