diff --git a/README.md b/README.md
index a3ae056..d44d077 100644
--- a/README.md
+++ b/README.md
@@ -1,32 +1,54 @@
-
+Monitorix for YunoHost
+======================
-# Monitorix for YunoHost
+[![Integration level](https://dash.yunohost.org/integration/monitorix.svg)](https://dash.yunohost.org/appci/app/monitorix) ![](https://ci-apps.yunohost.org/ci/badges/monitorix.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/monitorix.maintain.svg)
+[![Install monitorix with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=monitorix)
-[![Integration level](https://dash.yunohost.org/integration/monitorix.svg)](https://dash.yunohost.org/appci/app/monitorix) ![Working status](https://ci-apps.yunohost.org/ci/badges/monitorix.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/monitorix.maintain.svg)
-[![Install Monitorix with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=monitorix)
+> *This package allow you to install monitorix quickly and simply on a YunoHost server.
+If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.*
-*[Lire ce readme en français.](./README_fr.md)*
-
-> *This package allows you to install Monitorix quickly and simply on a YunoHost server.
-If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
-
-## Overview
+Overview
+--------
Monitorix is a free, open source, lightweight system monitoring tool designed to monitor as many services and system resources as possible. It has been created to be used under production Linux/UNIX servers, but due to its simplicity and small size can be used on embedded devices as well.
+**Shipped version:** 3.12
-**Shipped version:** 3.12.0~ynh2
+Screenshots
+-----------
-**Demo:** https://www.fibranet.cat/monitorix/
+![](https://www.monitorix.org/imgs/mail.png)
-## Screenshots
+Demo
+----
-![Screenshot of Monitorix](./doc/screenshots/mail.png)
+* [Official demo](https://www.fibranet.cat/monitorix/)
-## Disclaimers / important information
+Documentation
+-------------
+
+ * Official documentation: https://www.monitorix.org/documentation.html
+ * YunoHost documentation: There no other documentations, feel free to contribute.
+
+YunoHost specific features
+--------------------------
+
+### Multi-users support
+
+This app have no specific authentification and no specific user management.
+
+### Supported architectures
+
+* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/monitorix%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/monitorix/)
+* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/monitorix%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/monitorix/)
+
+
+
+Additional informations
+-----------------------
### More sensor
@@ -128,13 +150,13 @@ priority = 5
# -----------------------------------------------------------------------------
- 0 = /, /home, /var, /$tempdir, swap
+ 0 = /, /home, /var, /tmp, swap
/ = Root FS
/home = home
/var = var
- /$tempdir = tmp
+ /tmp = tmp
@@ -144,7 +166,7 @@ priority = 5
/ = 3600, 98, /etc/monitorix/monitorix_alerts_scripts/fs_rootfs.sh
/home = 3600, 98, /etc/monitorix/monitorix_alerts_scripts/fs_home.sh
/var = 3600, 98, /etc/monitorix/monitorix_alerts_scripts/fs_var.sh
- /$tempdir = 3600, 98, /etc/monitorix/monitorix_alerts_scripts/fs_tmp.sh
+ /tmp = 3600, 98, /etc/monitorix/monitorix_alerts_scripts/fs_tmp.sh
swap = 3600, 98, /etc/monitorix/monitorix_alerts_scripts/fs_swap.sh
@@ -243,24 +265,40 @@ In this config we have :
- We check some process.
- We send every day, week, month and year a rapport.
-## Documentation and resources
+Links
+-----
-* Official app website:
-* Official admin documentation:
-* Upstream app code repository:
-* YunoHost documentation for this app:
-* Report a bug:
+ * Report a bug: https://github.com/YunoHost-Apps/monitorix_ynh/issues
+ * App website: Link to the official website of this app
+ * YunoHost website: https://yunohost.org/
-## Developer info
+---
-Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/monitorix_ynh/tree/testing).
+Install
+-------
+
+From command line:
+
+`sudo yunohost app install -l monitorix https://github.com/YunoHost-Apps/monitorix_ynh`
+
+Upgrade
+-------
+
+From command line:
+
+`sudo yunohost app upgrade monitorix -u https://github.com/YunoHost-Apps/monitorix_ynh`
+
+Developers infos
+----------------
To try the testing branch, please proceed like that.
-
-``` bash
+```
sudo yunohost app install https://github.com/YunoHost-Apps/monitorix_ynh/tree/testing --debug
or
sudo yunohost app upgrade monitorix -u https://github.com/YunoHost-Apps/monitorix_ynh/tree/testing --debug
```
-**More info regarding app packaging:**
+License
+-------
+
+Monitorix is published under the GNU General Public License v2.0 License : http://www.monitorix.org/license.html
diff --git a/README_fr.md b/README_fr.md
deleted file mode 100644
index 25edec4..0000000
--- a/README_fr.md
+++ /dev/null
@@ -1,266 +0,0 @@
-
-
-# Monitorix pour YunoHost
-
-[![Niveau d'intégration](https://dash.yunohost.org/integration/monitorix.svg)](https://dash.yunohost.org/appci/app/monitorix) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/monitorix.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/monitorix.maintain.svg)
-[![Installer Monitorix avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=monitorix)
-
-*[Read this readme in english.](./README.md)*
-
-> *Ce package vous permet d'installer Monitorix rapidement et simplement sur un serveur YunoHost.
-Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.*
-
-## Vue d'ensemble
-
-Monitorix is a free, open source, lightweight system monitoring tool designed to monitor as many services and system resources as possible. It has been created to be used under production Linux/UNIX servers, but due to its simplicity and small size can be used on embedded devices as well.
-
-
-**Version incluse :** 3.12.0~ynh2
-
-**Démo :** https://www.fibranet.cat/monitorix/
-
-## Captures d'écran
-
-![Capture d'écran de Monitorix](./doc/screenshots/mail.png)
-
-## Avertissements / informations importantes
-
-### More sensor
-
-If you want to see the temperature of some sensor you can install the `lm-sensor` packet. For disk temperature you can instal the `hddtemp` packet.
-
-### Custom config
-
-If you want do custom the monitorix config for more personnal information you can add a file in `/etc/monitorix/conf.d/`. This config file will be overwritte the original config in `/etc/monitorix/monitorix.conf`.
-
-You will have a full complete documentation for monitorix config here : https://www.monitorix.org/documentation.html
-
-By example you can extends the basic config by this :
-
-```
-priority = 5
-
-
-
- disk = y
- lmsens = y
- gensens = y
- mail = y
-
-
-# LMSENS graph
-# -----------------------------------------------------------------------------
-
-
- core0 = temp1
- core1 =
- mb0 =
- cpu0 =
- fan0 =
- fan1 =
- fan2 =
- volt0 =
- volt1 =
- volt2 =
- volt3 =
- volt4 =
- volt5 =
- volt6 =
- volt7 =
-
-
-
-# GENSENS graph
-# -----------------------------------------------------------------------------
-
-
- 0 = cpu_temp
- 1 = cpu0_freq, cpu1_freq, cpu2_freq, cpu3_freq
-
-
- cpu_temp = /sys/class/thermal/thermal_zone0/temp
- cpu0_freq = /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
- cpu1_freq = /sys/devices/system/cpu/cpu1/cpufreq/cpuinfo_cur_freq
- cpu2_freq = /sys/devices/system/cpu/cpu2/cpufreq/cpuinfo_cur_freq
- cpu3_freq = /sys/devices/system/cpu/cpu3/cpufreq/cpuinfo_cur_freq
-
-
- cpu_temp = 1000
- cpu0_freq = 0.001
- cpu1_freq = 0.001
- cpu2_freq = 0.001
- cpu3_freq = 0.001
-
-
-
- cpu_temp = 300, 65, /etc/monitorix/monitorix_alerts_scripts/cpu_temp.sh
-
-
-
-# DISK graph
-# -----------------------------------------------------------------------------
-
-
- 0 = /dev/sda
-
-
- realloc_enabled = y
- realloc_timeintvl = 0
- realloc_threshold = 1
- realloc_script = /etc/monitorix/monitorix_alerts_scripts/disk_realloc.sh
- pendsect_enabled = y
- pendsect_timeintvl = 0
- pendsect_threshold = 1
- pendsect_script = /etc/monitorix/monitorix_alerts_scripts/disk_pendsect.sh
-
-
-
-# FS graph
-# -----------------------------------------------------------------------------
-
-
- 0 = /, /home, /var, /$tempdir, swap
-
-
- / = Root FS
- /home = home
- /var = var
- /$tempdir = tmp
-
-
-
- rigid = 2, 0, 2, 0
- limit = 100, 1000, 100, 1000
-
- / = 3600, 98, /etc/monitorix/monitorix_alerts_scripts/fs_rootfs.sh
- /home = 3600, 98, /etc/monitorix/monitorix_alerts_scripts/fs_home.sh
- /var = 3600, 98, /etc/monitorix/monitorix_alerts_scripts/fs_var.sh
- /$tempdir = 3600, 98, /etc/monitorix/monitorix_alerts_scripts/fs_tmp.sh
- swap = 3600, 98, /etc/monitorix/monitorix_alerts_scripts/fs_swap.sh
-
-
-
-
-# MAIL graph
-# -----------------------------------------------------------------------------
-
- mta = postfix
- greylist = postgrey
- stats_rate = real
- rigid = 0, 0, 0, 0, 0
- limit = 1, 1000, 1000, 1000, 1000
-
- delvd_enabled = y
- delvd_timeintvl = 60
- delvd_threshold = 100
- delvd_script = /etc/monitorix/monitorix_alerts_scripts/mail_delvd.sh
- mqueued_enabled = y
- mqueued_timeintvl = 3600
- mqueued_threshold = 100
- mqueued_script = /etc/monitorix/monitorix_alerts_scripts/mail_mqueued.sh
-
-
-
-
-# NET graph
-# -----------------------------------------------------------------------------
-
- list = eth0,lo
-
- eth0 = FastEthernet LAN, 0, 10000000
- lo = loopback, 0, 10000000
-
-
- gateway = eth0
-
-
-# PROCESS graph
-# -----------------------------------------------------------------------------
-
-
- 0 = sshd, ntpd, monitorix, monitorix-httpd
- 1 = openvpn, ...
- ...
- 6 = mysqld, slapd, postgresql
-
-
- master = Postfix
- imap = Dovecot
-
- rigid = 2, 0, 0, 0, 0, 0, 0, 0
- limit = 100, 1000, 1000, 1000, 1000, 1000, 1000, 1000
-
-
-
-
-
- enabled = y
- url_prefix = http://127.0.0.1:8081/monitorix
- smtp_hostname = localhost
- from_address = noreply@domain.tld
- hour = 2
- minute = 7
-
- enabled = y
- graphs = system, fs, gensens, disk, netstat, port, nginx
- to = user@domain.tld
-
-
- enabled = y
- graphs = system, fs, gensens, disk, kern, proc, net, netstat, process, serv, port, user, nginx, mysql, fail2ban, int
- to = user@domain.tld
-
-
- enabled = y
- graphs = system, fs, gensens, disk, kern, proc, net, netstat, process, serv, port, user, nginx, mysql, fail2ban, int
- to = user@domain.tld
-
-
- enabled = y
- graphs = system, fs, gensens, disk, kern, proc, net, netstat, process, serv, port, user, nginx, mysql, fail2ban, int
- to = user@domain.tld
-
-
-
-```
-
-In this config we have :
-- We set the process priority to 5 (which mean that it will be lower priority than the other process).
-- We get the lmsensor sensor data.
-- We get some sensors data not accessible with lmsensor (with gensens)
-- We check the disk health and send an email if any error happens. For that you need to make some script. An example is available in `/usr/share/doc/monitorix/monitorix-alert.sh`.
-- We check the filesystem.
-- We check the traffic in the network card.
-- We check some process.
-- We send every day, week, month and year a rapport.
-
-## Documentations et ressources
-
-* Site officiel de l'app :
-* Documentation officielle de l'admin :
-* Dépôt de code officiel de l'app :
-* Documentation YunoHost pour cette app :
-* Signaler un bug :
-
-## Informations pour les développeurs
-
-Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/monitorix_ynh/tree/testing).
-
-Pour essayer la branche testing, procédez comme suit.
-
-``` bash
-sudo yunohost app install https://github.com/YunoHost-Apps/monitorix_ynh/tree/testing --debug
-ou
-sudo yunohost app upgrade monitorix -u https://github.com/YunoHost-Apps/monitorix_ynh/tree/testing --debug
-```
-
-**Plus d'infos sur le packaging d'applications :**
diff --git a/check_process b/check_process
index 68812c6..f83c2c0 100644
--- a/check_process
+++ b/check_process
@@ -1,21 +1,24 @@
-;; Test complet
- ; Manifest
- domain="domain.tld"
- path="/path"
- ; Checks
- pkg_linter=1
- setup_sub_dir=1
- setup_root=1
- setup_nourl=0
- setup_private=0
- setup_public=0
- upgrade=1
- # 3.12.0~ynh1
- upgrade=1 from_commit=c09953008a913b5e1d46be561a10a746eab6d23e
- backup_restore=1
- multi_instance=0
- port_already_use=0
- change_url=1
-;;; Options
-Email=
-Notification=none
+;; General
+ auto_remove=1
+# Commentaire ignoré
+ ; Manifest
+ domain="domain.tld" (DOMAIN)
+ path="/path" (PATH)
+ ; Checks
+ pkg_linter=1
+ setup_sub_dir=1
+ setup_root=1
+ setup_nourl=0
+ setup_private=0
+ setup_public=0
+ upgrade=1
+ backup_restore=1
+ multi_instance=0
+ wrong_user=0
+ wrong_path=1
+ incorrect_path=1
+ corrupt_source=1
+ fail_download_source=1
+ port_already_use=1 (8080)
+ final_path_already_use=1
+ change_url=1
diff --git a/conf/app.src b/conf/app.src
index 368ba43..959d6ab 100644
--- a/conf/app.src
+++ b/conf/app.src
@@ -1,7 +1,17 @@
SOURCE_URL=http://www.monitorix.org/old-versions/monitorix_3.12.0-izzy1_all.deb
SOURCE_SUM=4fb9fa233463e036020e71aa2e545f5dc2c1106f2c8397017de5c3cb17de1263
+# (Optional) Program to check the integrity (sha256sum, md5sum...)
+# default: sha256
SOURCE_SUM_PRG=sha256sum
+# (Optional) Archive format
+# default: tar.gz
SOURCE_FORMAT=deb
+# (Optional) Put false if sources are directly in the archive root
+# default: true
+# Instead of true, SOURCE_IN_SUBDIR could be the number of sub directories
+# to remove.
SOURCE_IN_SUBDIR=false
-SOURCE_FILENAME=
+# (Optional) If it set as false don't extract the source.
+# (Useful to get a debian package or a python wheel.)
+# default: true
SOURCE_EXTRACT=false
diff --git a/conf/monitorix.conf b/conf/monitorix.conf
index 76a218b..e069317 100644
--- a/conf/monitorix.conf
+++ b/conf/monitorix.conf
@@ -21,13 +21,13 @@ include_dir = /etc/monitorix/conf.d
base_dir = /var/lib/monitorix/www/
base_lib = /var/lib/monitorix/
-base_url = __PATH_URL__
-base_cgi = __PATH_URL_SLASH_LESS__/cgi
+base_url = __YNH_WWW_PATH__
+base_cgi = __YNH_WWW_PATH__/cgi
enabled = y
host = localhost
- port = __PORT__
+ port = __SERVICE_PORT__
user = www-data
group = nogroup
log_file = /var/log/monitorix-httpd
@@ -289,7 +289,7 @@ secure_log_date_format = %b %e
list = System, Users
- 0 = /var/spool/mail, /var/spool/mqueue, /etc, /var/ftp, /$tempdir
+ 0 = /var/spool/mail, /var/spool/mqueue, /etc, /var/ftp, /tmp
1 = /home/ace, /home/gene, /home/paul, /home/peter
@@ -475,7 +475,7 @@ secure_log_date_format = %b %e
conn_type = socket
list = /run/mysqld/mysqld.sock
- /run/mysqld/mysqld.sock = 3306, __DB_USER__, __DB_PWD__
+ /run/mysqld/mysqld.sock = 3306, __MYSQL_USER__, __MYSQL_PASSWORD__
rigid = 0, 2, 0, 0, 0, 0
limit = 100, 100, 100, 100, 100, 100
@@ -591,7 +591,7 @@ secure_log_date_format = %b %e
2 = [postfix], [postfix-sasl], [dovecot]
3 = [nginx-http-auth]
4 = [sshd], [sshd-ddos]
- 5 = __ADDITIONAL_JAIL__
+ 5 = __F2B_ADDITIONAL_JAIL__
graphs_per_row = 2
rigid = 0
@@ -743,9 +743,9 @@ secure_log_date_format = %b %e
# -----------------------------------------------------------------------------
enabled = n
- url_prefix = http://127.0.0.1:__PORT____PATH_URL__
+ url_prefix = http://127.0.0.1:__SERVICE_PORT____YNH_WWW_PATH__
smtp_hostname = localhost
- from_address = noreply@__DOMAIN__
+ from_address = noreply@__YNH_DOMAIN__
hour = 0
minute = 0
diff --git a/conf/nginx.conf b/conf/nginx.conf
index fda0f6c..7c64fe4 100644
--- a/conf/nginx.conf
+++ b/conf/nginx.conf
@@ -1,21 +1,21 @@
location __PATH__ {
- proxy_pass http://127.0.0.1:__PORT____PATH__;
- allow 127.0.0.0/8;
+ proxy_pass http://127.0.0.1:__PORT____PATH__;
+ allow 127.0.0.0/8;
- location ~ ^__PATH__/(.+\.png)$ {
- alias /var/lib/monitorix/www/$1;
- }
-
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header X-Forwarded-Proto $scheme;
-
- proxy_connect_timeout 600;
- proxy_send_timeout 600;
- proxy_read_timeout 600;
- send_timeout 600;
+ location ~ ^__PATH__/(.+\.png)$ {
+ alias /var/lib/monitorix/www/$1;
+ }
- # Include SSOWAT user panel.
- include conf.d/yunohost_panel.conf.inc;
-}
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header X-Forwarded-Proto $scheme;
+
+ proxy_connect_timeout 600;
+ proxy_send_timeout 600;
+ proxy_read_timeout 600;
+ send_timeout 600;
+
+ # Include SSOWAT user panel.
+ include conf.d/yunohost_panel.conf.inc;
+}
\ No newline at end of file
diff --git a/conf/nginx_status.conf b/conf/nginx_status.conf
index 29cc4da..e877c13 100644
--- a/conf/nginx_status.conf
+++ b/conf/nginx_status.conf
@@ -1,15 +1,15 @@
server {
- listen __NGINX_STATUS_PORT__;
- listen [::]:__NGINX_STATUS_PORT__;
+ listen __PORT__;
+ listen [::]:__PORT__;
- access_log /var/log/nginx/localhost-nginx_status_monitorix.lan-access.log;
- error_log /var/log/nginx/localhost-nginx_status_monitorix.lan-error.log;
+ access_log /var/log/nginx/localhost-nginx_status_monitorix.lan-access.log;
+ error_log /var/log/nginx/localhost-nginx_status_monitorix.lan-error.log;
- location /nginx_status_monitorix {
- stub_status on;
- access_log off;
- allow 127.0.0.1;
- allow ::1;
- deny all;
- }
-}
+ location /nginx_status_monitorix {
+ stub_status on;
+ access_log off;
+ allow 127.0.0.1;
+ allow ::1;
+ deny all;
+ }
+}
\ No newline at end of file
diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md
deleted file mode 100644
index 1324d1f..0000000
--- a/doc/DESCRIPTION.md
+++ /dev/null
@@ -1 +0,0 @@
-Monitorix is a free, open source, lightweight system monitoring tool designed to monitor as many services and system resources as possible. It has been created to be used under production Linux/UNIX servers, but due to its simplicity and small size can be used on embedded devices as well.
diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md
deleted file mode 100644
index dc8886c..0000000
--- a/doc/DISCLAIMER.md
+++ /dev/null
@@ -1,214 +0,0 @@
-### More sensor
-
-If you want to see the temperature of some sensor you can install the `lm-sensor` packet. For disk temperature you can instal the `hddtemp` packet.
-
-### Custom config
-
-If you want do custom the monitorix config for more personnal information you can add a file in `/etc/monitorix/conf.d/`. This config file will be overwritte the original config in `/etc/monitorix/monitorix.conf`.
-
-You will have a full complete documentation for monitorix config here : https://www.monitorix.org/documentation.html
-
-By example you can extends the basic config by this :
-
-```
-priority = 5
-
-
-
- disk = y
- lmsens = y
- gensens = y
- mail = y
-
-
-# LMSENS graph
-# -----------------------------------------------------------------------------
-
-
- core0 = temp1
- core1 =
- mb0 =
- cpu0 =
- fan0 =
- fan1 =
- fan2 =
- volt0 =
- volt1 =
- volt2 =
- volt3 =
- volt4 =
- volt5 =
- volt6 =
- volt7 =
-
-
-
-# GENSENS graph
-# -----------------------------------------------------------------------------
-
-
- 0 = cpu_temp
- 1 = cpu0_freq, cpu1_freq, cpu2_freq, cpu3_freq
-
-
- cpu_temp = /sys/class/thermal/thermal_zone0/temp
- cpu0_freq = /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
- cpu1_freq = /sys/devices/system/cpu/cpu1/cpufreq/cpuinfo_cur_freq
- cpu2_freq = /sys/devices/system/cpu/cpu2/cpufreq/cpuinfo_cur_freq
- cpu3_freq = /sys/devices/system/cpu/cpu3/cpufreq/cpuinfo_cur_freq
-
-
- cpu_temp = 1000
- cpu0_freq = 0.001
- cpu1_freq = 0.001
- cpu2_freq = 0.001
- cpu3_freq = 0.001
-
-
-
- cpu_temp = 300, 65, /etc/monitorix/monitorix_alerts_scripts/cpu_temp.sh
-
-
-
-# DISK graph
-# -----------------------------------------------------------------------------
-
-
- 0 = /dev/sda
-
-
- realloc_enabled = y
- realloc_timeintvl = 0
- realloc_threshold = 1
- realloc_script = /etc/monitorix/monitorix_alerts_scripts/disk_realloc.sh
- pendsect_enabled = y
- pendsect_timeintvl = 0
- pendsect_threshold = 1
- pendsect_script = /etc/monitorix/monitorix_alerts_scripts/disk_pendsect.sh
-
-
-
-# FS graph
-# -----------------------------------------------------------------------------
-
-
- 0 = /, /home, /var, /$tempdir, swap
-
-
- / = Root FS
- /home = home
- /var = var
- /$tempdir = tmp
-
-
-
- rigid = 2, 0, 2, 0
- limit = 100, 1000, 100, 1000
-
- / = 3600, 98, /etc/monitorix/monitorix_alerts_scripts/fs_rootfs.sh
- /home = 3600, 98, /etc/monitorix/monitorix_alerts_scripts/fs_home.sh
- /var = 3600, 98, /etc/monitorix/monitorix_alerts_scripts/fs_var.sh
- /$tempdir = 3600, 98, /etc/monitorix/monitorix_alerts_scripts/fs_tmp.sh
- swap = 3600, 98, /etc/monitorix/monitorix_alerts_scripts/fs_swap.sh
-
-
-
-
-# MAIL graph
-# -----------------------------------------------------------------------------
-
- mta = postfix
- greylist = postgrey
- stats_rate = real
- rigid = 0, 0, 0, 0, 0
- limit = 1, 1000, 1000, 1000, 1000
-
- delvd_enabled = y
- delvd_timeintvl = 60
- delvd_threshold = 100
- delvd_script = /etc/monitorix/monitorix_alerts_scripts/mail_delvd.sh
- mqueued_enabled = y
- mqueued_timeintvl = 3600
- mqueued_threshold = 100
- mqueued_script = /etc/monitorix/monitorix_alerts_scripts/mail_mqueued.sh
-
-
-
-
-# NET graph
-# -----------------------------------------------------------------------------
-
- list = eth0,lo
-
- eth0 = FastEthernet LAN, 0, 10000000
- lo = loopback, 0, 10000000
-
-
- gateway = eth0
-
-
-# PROCESS graph
-# -----------------------------------------------------------------------------
-
-
- 0 = sshd, ntpd, monitorix, monitorix-httpd
- 1 = openvpn, ...
- ...
- 6 = mysqld, slapd, postgresql
-
-
- master = Postfix
- imap = Dovecot
-
- rigid = 2, 0, 0, 0, 0, 0, 0, 0
- limit = 100, 1000, 1000, 1000, 1000, 1000, 1000, 1000
-
-
-
-
-
- enabled = y
- url_prefix = http://127.0.0.1:8081/monitorix
- smtp_hostname = localhost
- from_address = noreply@domain.tld
- hour = 2
- minute = 7
-
- enabled = y
- graphs = system, fs, gensens, disk, netstat, port, nginx
- to = user@domain.tld
-
-
- enabled = y
- graphs = system, fs, gensens, disk, kern, proc, net, netstat, process, serv, port, user, nginx, mysql, fail2ban, int
- to = user@domain.tld
-
-
- enabled = y
- graphs = system, fs, gensens, disk, kern, proc, net, netstat, process, serv, port, user, nginx, mysql, fail2ban, int
- to = user@domain.tld
-
-
- enabled = y
- graphs = system, fs, gensens, disk, kern, proc, net, netstat, process, serv, port, user, nginx, mysql, fail2ban, int
- to = user@domain.tld
-
-
-
-```
-
-In this config we have :
-- We set the process priority to 5 (which mean that it will be lower priority than the other process).
-- We get the lmsensor sensor data.
-- We get some sensors data not accessible with lmsensor (with gensens)
-- We check the disk health and send an email if any error happens. For that you need to make some script. An example is available in `/usr/share/doc/monitorix/monitorix-alert.sh`.
-- We check the filesystem.
-- We check the traffic in the network card.
-- We check some process.
-- We send every day, week, month and year a rapport.
diff --git a/doc/screenshots/.gitkeep b/doc/screenshots/.gitkeep
deleted file mode 100644
index e69de29..0000000
diff --git a/doc/screenshots/mail.png b/doc/screenshots/mail.png
deleted file mode 100644
index 0497a3f..0000000
Binary files a/doc/screenshots/mail.png and /dev/null differ
diff --git a/manifest.json b/manifest.json
index 45a924a..f21d53c 100644
--- a/manifest.json
+++ b/manifest.json
@@ -6,22 +6,15 @@
"en": "A monitoring tools",
"fr": "Un outils de monitoring"
},
- "version": "3.12.0~ynh2",
+ "version": "3.12.0~ynh1",
"url": "http://monitorix.org",
- "upstream": {
- "license": "GPL-2.0",
- "website": "http://monitorix.org",
- "demo": "https://www.fibranet.cat/monitorix/",
- "admindoc": "https://www.monitorix.org/documentation.html",
- "code": "https://github.com/mikaku/Monitorix"
- },
"license": "GPL-2.0",
"maintainer": {
"name": "Josué Tille",
"email": "josue@familletille.ch"
},
"requirements": {
- "yunohost": ">= 4.3.0"
+ "yunohost": ">= 4.0.0"
},
"multi_instance": false,
"services": [
@@ -29,14 +22,23 @@
"mysql"
],
"arguments": {
- "install": [
+ "install" : [
{
"name": "domain",
- "type": "domain"
+ "type": "domain",
+ "ask": {
+ "en": "Choose a domain name for Monitorix",
+ "fr": "Choisissez un nom de domaine pour Monitorix"
+ },
+ "example": "example.com"
},
{
"name": "path",
"type": "path",
+ "ask": {
+ "en": "Choose a path for Monitorix",
+ "fr": "Choisissez un chemin pour Monitorix"
+ },
"example": "/monitorix",
"default": "/monitorix"
}
diff --git a/scripts/_common.sh b/scripts/_common.sh
index e93da42..22be3cb 100644
--- a/scripts/_common.sh
+++ b/scripts/_common.sh
@@ -1,21 +1,22 @@
-#!/bin/bash
-
#=================================================
-# COMMON VARIABLES
+# SET ALL CONSTANTS
#=================================================
-# dependencies used by the app
-pkg_dependencies="rrdtool perl libwww-perl libmailtools-perl libmime-lite-perl librrds-perl libdbi-perl libxml-simple-perl libhttp-server-simple-perl libconfig-general-perl pflogsumm libxml-libxml-perl"
+app=$YNH_APP_INSTANCE_NAME
#=================================================
# DEFINE ALL COMMON FONCTIONS
#=================================================
+install_dependances() {
+ ynh_install_app_dependencies rrdtool perl libwww-perl libmailtools-perl libmime-lite-perl librrds-perl libdbi-perl libxml-simple-perl libhttp-server-simple-perl libconfig-general-perl pflogsumm libxml-libxml-perl
+}
+
get_install_source() {
- ynh_setup_source --dest_dir /$tempdir
+ ynh_setup_source --dest_dir /tmp
ynh_package_update
- dpkg --force-confdef --force-confold -i /$tempdir/app.deb
+ dpkg --force-confdef --force-confold -i /tmp/app.deb
ynh_secure_remove --file=/etc/monitorix/conf.d/00-debian.conf
ynh_package_install -f
}
@@ -44,8 +45,16 @@ config_monitorix() {
fi
done
- path_url_slash_less=${path_url%/}
- ynh_add_config --template="../conf/monitorix.conf" --destination="/etc/monitorix/monitorix.conf"
+ monitorix_conf=/etc/monitorix/monitorix.conf
+ cp ../conf/monitorix.conf $monitorix_conf
+ ynh_replace_string --match_string __SERVICE_PORT__ --replace_string $port --target_file $monitorix_conf
+ ynh_replace_string --match_string __YNH_DOMAIN__ --replace_string $domain --target_file $monitorix_conf
+ ynh_replace_string --match_string __NGINX_STATUS_PORT__ --replace_string $nginx_status_port --target_file $monitorix_conf
+ ynh_replace_string --match_string __YNH_WWW_PATH__/ --replace_string "${path_url%/}/" --target_file $monitorix_conf
+ ynh_replace_string --match_string __YNH_WWW_PATH__ --replace_string $path_url --target_file $monitorix_conf
+ ynh_replace_string --match_string __MYSQL_USER__ --replace_string $dbuser --target_file $monitorix_conf
+ ynh_replace_string --match_string __MYSQL_PASSWORD__ --replace_string $dbpass --target_file $monitorix_conf
+ ynh_replace_string --match_string __F2B_ADDITIONAL_JAIL__ --replace_string "$additional_jail" --target_file $monitorix_conf
}
set_permission() {
diff --git a/scripts/backup b/scripts/backup
index 3ce82d7..7738d6f 100755
--- a/scripts/backup
+++ b/scripts/backup
@@ -3,64 +3,39 @@
#=================================================
# GENERIC START
#=================================================
-# IMPORT GENERIC HELPERS
-#=================================================
-# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
+# Import common cmd
+source ../settings/scripts/experimental_helper.sh
source ../settings/scripts/_common.sh
+
+# Source 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
+# Stop script if errors
ynh_abort_if_errors
-#=================================================
-# LOAD SETTINGS
-#=================================================
+# Retrieve arguments
ynh_print_info --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)
+domain=$(ynh_app_setting_get --app $app --key domain)
#=================================================
-# DECLARE DATA AND CONF FILES TO BACKUP
-#=================================================
-ynh_print_info --message="Declaring files to be backed up..."
-
-#=================================================
-# BACKUP THE NGINX CONFIGURATION
+# STANDARD BACKUP STEPS
#=================================================
-ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
-ynh_backup --src_path="/etc/nginx/conf.d/monitorix_status.conf"
+# Copy NGINX configuration
+ynh_print_info --message="Backing up configuration..."
+domain=$(ynh_app_setting_get --app $app --key domain)
+ynh_backup --src_path "/etc/nginx/conf.d/${domain}.d/${app}.conf"
+ynh_backup --src_path "/etc/nginx/conf.d/monitorix_status.conf"
-#=================================================
-# BACKUP VARIOUS FILES
-#=================================================
+# Copy hook
+ynh_backup --src_path "/etc/yunohost/hooks.d/post_iptable_rules/50-$app"
-ynh_backup --src_path="/etc/yunohost/hooks.d/post_iptable_rules/50-$app"
+# Copy Monitorix configuration
+ynh_backup --src_path "/etc/monitorix"
-ynh_backup --src_path="/etc/monitorix"
-
-ynh_backup --src_path="/var/lib/monitorix"
-
-#=================================================
-# BACKUP THE MYSQL DATABASE
-#=================================================
-ynh_print_info --message="Backing up the MySQL database..."
-
-ynh_mysql_dump_db --database="$db_name" > db.sql
-
-#=================================================
-# END OF SCRIPT
-#=================================================
+# Copy Monitorix data
+ynh_print_info --message="Backing up data..."
+ynh_backup --src_path "/var/lib/monitorix"
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
diff --git a/scripts/change_url b/scripts/change_url
index a43c407..2e1e383 100644
--- a/scripts/change_url
+++ b/scripts/change_url
@@ -1,163 +1,62 @@
#!/bin/bash
#=================================================
-# GENERIC STARTING
-#=================================================
-# IMPORT GENERIC HELPERS
+# GENERIC START
#=================================================
-source _common.sh
+# Import common cmd
+source ./experimental_helper.sh
+source ./_common.sh
+
+# Source 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
-port=$(ynh_app_setting_get --app=$app --key=port)
-nginx_status_port=$(ynh_app_setting_get --app=$app --key=nginx_status_port)
-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
+# Stop script if errors
ynh_abort_if_errors
-#=================================================
-# CHECK WHICH PARTS SHOULD BE CHANGED
-#=================================================
+ynh_script_progression --message="Loading installation settings..."
-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
+# Retrive arguments
+path_url=$(ynh_normalize_url_path --path_url $YNH_APP_NEW_PATH)
+old_domain=$YNH_APP_OLD_DOMAIN
+domain=$YNH_APP_NEW_DOMAIN
+port=$(ynh_app_setting_get --app $app --key http_port)
+nginx_status_port=$(ynh_app_setting_get --app $app --key nginx_status_port)
+dbuser=$app
+dbname=$app
+dbpass=$(ynh_app_setting_get --app $app --key mysqlpwd)
#=================================================
# STANDARD MODIFICATIONS
#=================================================
-# STOP SYSTEMD SERVICE
-#=================================================
-ynh_script_progression --message="Stopping a systemd service..."
-ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
+ynh_script_progression --message="Updating nginx configuration..."
-#=================================================
-# MODIFY URL IN NGINX CONF
-#=================================================
-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 ]
+# Update nginx config
+if [ "$old_domain" != "$domain" ]
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
+ # Delete file checksum for the old conf file location
+ ynh_delete_file_checksum --file "/etc/nginx/conf.d/$old_domain.d/$app.conf"
+
+ mv "/etc/nginx/conf.d/$old_domain.d/$app.conf" "/etc/nginx/conf.d/$domain.d/$app.conf"
+
+ # Store file checksum for the new config file location
+ ynh_store_file_checksum --file "/etc/nginx/conf.d/$domain.d/$app.conf"
fi
+config_nginx
-# Change the domain for NGINX
-if [ $change_domain -eq 1 ]
-then
- # Delete file checksum for the old conf file location
- ynh_delete_file_checksum --file="$nginx_conf_path"
- mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
- # Store file checksum for the new config file location
- ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
-fi
-ynh_add_config --template="../conf/nginx_status.conf" --destination="/etc/nginx/conf.d/monitorix_status.conf"
+ynh_script_progression --message="Updating monitorix configuration..."
-#=================================================
-# SPECIFIC MODIFICATIONS
-#=================================================
-# UPDATE A CONFIG FILE
-#=================================================
-ynh_script_progression --message="Updating a configuration file..."
+# Update monitorix configuration
+config_monitorix
-domain="$new_domain"
-path_url="$new_path"
-
-jail_list=$(fail2ban-client status | grep 'Jail list:' | sed 's/.*Jail list://' | sed 's/,//g')
-additional_jail=""
-for jail in $jail_list; do
- if ! [[ "$jail" =~ (recidive|pam-generic|yunohost|postfix|postfix-sasl|dovecot|nginx-http-auth|sshd|sshd-ddos) ]]; then
- if [ -z "$additional_jail" ]; then
- additional_jail="[$jail]"
- else
- additional_jail+=", [$jail]"
- fi
- fi
-done
-
-path_url_slash_less=${path_url%/}
-ynh_add_config --template="../conf/monitorix.conf" --destination="/etc/monitorix/monitorix.conf"
-
-chown www-data:root -R /etc/monitorix
-chmod u=rX,g=rwX,o= -R /etc/monitorix
-chown www-data:root -R /var/lib/monitorix
-chmod u=rwX,g=rwX,o= -R /var/lib/monitorix
-
-#=================================================
-# GENERIC FINALISATION
-#=================================================
-# START SYSTEMD SERVICE
-#=================================================
-ynh_script_progression --message="Starting a systemd service..." --weight=3
-
-# Start a systemd service
-ynh_systemd_action --service_name=$app --action="restart" --log_path="/var/log/monitorix" --line_match=" - Ok, ready."
-
-#=================================================
-# RELOAD NGINX
-#=================================================
-ynh_script_progression --message="Reloading NGINX web server..."
-
-ynh_systemd_action --service_name=nginx --action=reload
-
-#=================================================
-# END OF SCRIPT
-#=================================================
+ynh_script_progression --message="Restarting monitorix services..." --weight=3
+# Reload monitorix
+# While we stop monitorix sometime the built-in web server is not stopped cleanly. So are sure that everything is cleanly stoped by that
+# So this fix that
+systemctl stop monitorix.service
+sleep 1
+pkill -f "monitorix-httpd listening on" || true
+ynh_systemd_action -l ' - Ok, ready.' -p '/var/log/monitorix'
ynh_script_progression --message="Change of URL completed for $app" --last
diff --git a/doc/.gitkeep b/scripts/experimental_helper.sh
similarity index 100%
rename from doc/.gitkeep
rename to scripts/experimental_helper.sh
diff --git a/scripts/install b/scripts/install
index 605b127..af49246 100755
--- a/scripts/install
+++ b/scripts/install
@@ -3,145 +3,82 @@
#=================================================
# GENERIC START
#=================================================
-# IMPORT GENERIC HELPERS
-#=================================================
-source _common.sh
+# Import common cmd
+source ./experimental_helper.sh
+source ./_common.sh
+
+# Source 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
+# Stop script if errors
ynh_abort_if_errors
-#=================================================
-# RETRIEVE ARGUMENTS FROM THE MANIFEST
-#=================================================
+ynh_script_progression --message="Validating installation parameters..."
+# Retrieve arguments
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
-app=$YNH_APP_INSTANCE_NAME
+# Check domain/path availability
+test $(ynh_webpath_available --domain $domain --path_url $path_url) == 'True' || ynh_die --message "$domain$path_url is not available, please use an other domain or path."
+ynh_webpath_register $app $domain $path_url
-#=================================================
-# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
-#=================================================
-ynh_script_progression --message="Validating installation parameters..."
+# Find a port for built-in monitorix HTTP server
+ynh_script_progression --message="Finding available ports..."
+port=$(ynh_find_port --port 8080)
+nginx_status_port=$(ynh_find_port --port $(($port +1)))
-# Register (book) web path
-ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
-
-#=================================================
-# STORE SETTINGS FROM MANIFEST
-#=================================================
+# store config in yunohost
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 http_port --value $port
+ynh_app_setting_set --app $app --key nginx_status_port --value $nginx_status_port
#=================================================
# STANDARD MODIFICATIONS
#=================================================
-# FIND AND OPEN A PORT
-#=================================================
-ynh_script_progression --message="Finding an available port..."
-# Find an available port
-port=$(ynh_find_port --port=8080)
-ynh_app_setting_set --app=$app --key=port --value=$port
-nginx_status_port=$(ynh_find_port --port $(($port +1)))
-ynh_app_setting_set --app=$app --key=nginx_status_port --value=$nginx_status_port
-
-#=================================================
-# INSTALL DEPENDENCIES
-#=================================================
+# Install package
ynh_script_progression --message="Installing dependencies..." --weight=7
+install_dependances
-ynh_install_app_dependencies $pkg_dependencies
-tempdir="$(mktemp -d)"
-ynh_setup_source --dest_dir="$tempdir"
-ynh_package_update
-dpkg --force-confdef --force-confold -i /$tempdir/app.deb
-ynh_package_install -f
-ynh_secure_remove --file="$tempdir"
+# Download package and install it
+ynh_script_progression --message="Installing sources files..." --weight=7
+get_install_source
-#=================================================
-# CREATE A MYSQL DATABASE
-#=================================================
-ynh_script_progression --message="Creating a MySQL database..."
+# # Generate MySQL user
+ynh_script_progression --message="Configuring MySQL database..."
+dbuser=$app
+dbpass=$(ynh_string_random 12)
+ynh_app_setting_set --app $app --key mysqlpwd --value "$dbpass"
+ynh_mysql_create_user $dbuser $dbpass
-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
+# Config nginx
+ynh_script_progression --message="Configuring nginx..." --weight=1
+config_nginx
-#=================================================
-# NGINX CONFIGURATION
-#=================================================
-ynh_script_progression --message="Configuring NGINX web server..." --weight=1
-
-# Create a dedicated NGINX config
-ynh_add_nginx_config
-ynh_add_config --template="../conf/nginx_status.conf" --destination="/etc/nginx/conf.d/monitorix_status.conf"
-
-#=================================================
-# SPECIFIC SETUP
-#=================================================
-# ADD A CONFIGURATION
-#=================================================
-ynh_script_progression --message="Adding a configuration file..." --weight=3
-
-jail_list=$(fail2ban-client status | grep 'Jail list:' | sed 's/.*Jail list://' | sed 's/,//g')
-additional_jail=""
-for jail in $jail_list; do
- if ! [[ "$jail" =~ (recidive|pam-generic|yunohost|postfix|postfix-sasl|dovecot|nginx-http-auth|sshd|sshd-ddos) ]]; then
- if [ -z "$additional_jail" ]; then
- additional_jail="[$jail]"
- else
- additional_jail+=", [$jail]"
- fi
- fi
-done
-
-path_url_slash_less=${path_url%/}
-ynh_add_config --template="../conf/monitorix.conf" --destination="/etc/monitorix/monitorix.conf"
-
-chown www-data:root -R /etc/monitorix
-chmod u=rX,g=rwX,o= -R /etc/monitorix
-chown www-data:root -R /var/lib/monitorix
-chmod u=rwX,g=rwX,o= -R /var/lib/monitorix
+# Update monitorix configuration
+ynh_script_progression --message="Configuring application..." --weight=3
+config_monitorix
#=================================================
# GENERIC FINALIZATION
#=================================================
-# INTEGRATE SERVICE IN YUNOHOST
-#=================================================
-ynh_script_progression --message="Integrating service in YunoHost..."
+# Set access
+ynh_script_progression --message="Protecting directory..."
+set_permission
+
+# register yunohost service
yunohost service add monitorix
-#=================================================
-# START SYSTEMD SERVICE
-#=================================================
-ynh_script_progression --message="Starting a systemd service..." --weight=3
-
-# Start a systemd service
-ynh_systemd_action --service_name=$app --action="restart" --log_path="/var/log/monitorix" --line_match=" - Ok, ready."
-
-#=================================================
-# RELOAD NGINX
-#=================================================
-ynh_script_progression --message="Reloading NGINX web server..."
-
-ynh_systemd_action --service_name=nginx --action=reload
-
-#=================================================
-# END OF SCRIPT
-#=================================================
+# Reload monitorix
+ynh_script_progression --message="Starting monitorix services..." --weight=3
+# While we stop monitorix sometime the built-in web server is not stopped cleanly. So are sure that everything is cleanly stoped by that
+# So this fix that
+systemctl stop monitorix.service
+sleep 1
+pkill -f "monitorix-httpd listening on" || true
+ynh_systemd_action -l ' - Ok, ready.' -p '/var/log/monitorix'
ynh_script_progression --message="Installation of $app completed" --last
diff --git a/scripts/remove b/scripts/remove
index 102d30c..dcf1a32 100755
--- a/scripts/remove
+++ b/scripts/remove
@@ -3,79 +3,48 @@
#=================================================
# GENERIC START
#=================================================
-# IMPORT GENERIC HELPERS
-#=================================================
-source _common.sh
+# Import common cmd
+source ./experimental_helper.sh
+source ./_common.sh
+
+# Source 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
+# Retrieve app settings
+domain=$(ynh_app_setting_get --app $app --key domain)
#=================================================
# STANDARD REMOVE
#=================================================
-# REMOVE SERVICE INTEGRATION IN YUNOHOST
-#=================================================
-# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
-if ynh_exec_warn_less yunohost service status $app >/dev/null
-then
- ynh_script_progression --message="Removing $app service integration..."
- yunohost service remove $app
-fi
+# Stop service
+ynh_script_progression --message="Stoping services..."
+systemctl stop monitorix.service
-#=================================================
-# STOP AND REMOVE SERVICE
-#=================================================
-ynh_script_progression --message="Stopping and removing the systemd service..."
-
-systemctl stop $app.service
-
-#=================================================
-# 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 APP MAIN DIR
-#=================================================
-ynh_script_progression --message="Removing app main directory..."
-
-# Remove the app directory securely
+# Drop MySQL database and user
+ynh_script_progression --message="Removing databases..."
+dbname=$app
+dbuser=$app
+ynh_mysql_drop_db "$dbname" || true
+ynh_mysql_drop_user "$dbuser" || true
+# Remove data
+ynh_script_progression --message="Removing logs..."
ynh_secure_remove --file=/var/lib/monitorix
-#=================================================
-# REMOVE NGINX CONFIGURATION
-#=================================================
-ynh_script_progression --message="Removing NGINX web server configuration..."
-
-# Remove the dedicated NGINX config
-
+# Remove nginx config
ynh_secure_remove --file="/etc/nginx/conf.d/monitorix_status.conf"
ynh_remove_nginx_config
-#=================================================
-# REMOVE DEPENDENCIES
-#=================================================
-ynh_script_progression --message="Removing dependencies..." --weight=10
+# Autoremove package
+ynh_script_progression --message="Removing dependencies" --weight=10
ynh_remove_app_dependencies
-ynh_package_autoremove $app
+ynh_package_autoremove monitorix
-#=================================================
-# END OF SCRIPT
-#=================================================
+yunohost service remove monitorix
ynh_script_progression --message="Removal of $app completed" --last
diff --git a/scripts/restore b/scripts/restore
index d2bb9d0..c4ebcf4 100755
--- a/scripts/restore
+++ b/scripts/restore
@@ -3,115 +3,71 @@
#=================================================
# GENERIC START
#=================================================
-# IMPORT GENERIC HELPERS
-#=================================================
-# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
+# Import common cmd
+source ../settings/scripts/experimental_helper.sh
source ../settings/scripts/_common.sh
+
+# Source 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
+# Stop script if errors
ynh_abort_if_errors
-#=================================================
-# LOAD SETTINGS
-#=================================================
-ynh_script_progression --message="Loading installation settings..."
+ynh_script_progression --message="Loading settings..."
-app=$YNH_APP_INSTANCE_NAME
+# Retrieve old app settings
+domain=$(ynh_app_setting_get --app $app --key domain)
+path_url=$(ynh_normalize_url_path --path_url $(ynh_app_setting_get --app $app --key path))
-domain=$(ynh_app_setting_get --app=$app --key=domain)
-path_url=$(ynh_app_setting_get --app=$app --key=path)
-db_name=$(ynh_app_setting_get --app=$app --key=db_name)
-db_user=$db_name
+# Check domain/path availability
+ynh_webpath_available --domain $domain --path_url $path_url || ynh_die --message "$domain/$path_url is not available, please use an other domain or path."
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
-#=================================================
-# SPECIFIC RESTORATION
-#=================================================
-# REINSTALL DEPENDENCIES
-#=================================================
+# Install package
ynh_script_progression --message="Reinstalling dependencies..." --weight=5
+install_dependances
-# Define and install dependencies
-ynh_install_app_dependencies $pkg_dependencies
-tempdir="$(mktemp -d)"
-ynh_setup_source --dest_dir="$tempdir"
-ynh_package_update
-dpkg --force-confdef --force-confold -i /$tempdir/app.deb
-ynh_secure_remove --file=/etc/monitorix/conf.d/00-debian.conf
-ynh_package_install -f
-ynh_secure_remove --file="$tempdir"
+# Download package and install it
+ynh_script_progression --message="Installing sources files..." --weight=7
+get_install_source
-#=================================================
-# 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"
-ynh_restore_file --origin_path="/etc/nginx/conf.d/monitorix_status.conf"
-
-#=================================================
-# RESTORE THE MYSQL DATABASE
-#=================================================
-ynh_script_progression --message="Restoring the MySQL database..."
-
-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
-
-#=================================================
-# RESTORE VARIOUS FILES
-#=================================================
-ynh_script_progression --message="Restoring various files..." --weight=10
+# Create user for database
+ynh_script_progression --message="Configuring MySQL database..."
+dbuser=$app
+dbpass=$(ynh_app_setting_get --app $app --key mysqlpwd)
+ynh_mysql_create_user $dbuser $dbpass
+# Restore all config and data
+ynh_script_progression --message="Restoring files..." --weight=10
ynh_secure_remove --file=/etc/monitorix # we remove the directory because if it is not empty the ynh_restore cmd fail
ynh_secure_remove --file=/var/lib/monitorix
-
-ynh_restore_file --origin_path="/etc/yunohost/hooks.d/post_iptable_rules/50-$app"
-ynh_restore_file --origin_path="/etc/monitorix"
-ynh_restore_file --origin_path="/var/lib/monitorix"
-
-chown www-data:root -R /etc/monitorix
-chmod u=rX,g=rwX,o= -R /etc/monitorix
-chown www-data:root -R /var/lib/monitorix
-chmod u=rwX,g=rwX,o= -R /var/lib/monitorix
-
-#=================================================
-# INTEGRATE SERVICE IN YUNOHOST
-#=================================================
-ynh_script_progression --message="Integrating service in YunoHost..."
-
-yunohost service add monitorix
-
-#=================================================
-# START SYSTEMD SERVICE
-#=================================================
-ynh_script_progression --message="Starting a systemd service..." --weight=3
-
-ynh_systemd_action --service_name=$app --action="restart" --log_path="/var/log/monitorix" --line_match=" - Ok, ready."
+ynh_restore
#=================================================
# GENERIC FINALIZATION
#=================================================
-# RELOAD NGINX
-#=================================================
-ynh_script_progression --message="Reloading NGINX web server..."
-ynh_systemd_action --service_name=nginx --action=reload
+# Set access
+ynh_script_progression --message="Protecting directory..."
+set_permission
-#=================================================
-# END OF SCRIPT
-#=================================================
+# register yunohost service
+yunohost service add monitorix
+
+# Reload nginx
+systemctl reload nginx.service
+
+# Reload monitorix
+ynh_script_progression --message="Starting monitorix services..." --weight=3
+# While we stop monitorix sometime the built-in web server is not stopped cleanly. So are sure that everything is cleanly stoped by that
+# So this fix that
+systemctl stop monitorix.service
+sleep 1
+pkill -f "monitorix-httpd listening on" || true
+ynh_systemd_action -l ' - Ok, ready.' -p '/var/log/monitorix'
ynh_script_progression --message="Restoration completed for $app" --last
diff --git a/scripts/upgrade b/scripts/upgrade
index 02d5867..a63538d 100755
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -3,44 +3,36 @@
#=================================================
# GENERIC START
#=================================================
-# IMPORT GENERIC HELPERS
-#=================================================
-source _common.sh
+# Import common cmd
+source ./experimental_helper.sh
+source ./_common.sh
+
+# Source YunoHost helpers
source /usr/share/yunohost/helpers
-#=================================================
-# LOAD SETTINGS
-#=================================================
+# Stop script if errors
+ynh_abort_if_errors
+
ynh_script_progression --message="Loading installation settings..."
-app=$YNH_APP_INSTANCE_NAME
+# Retrieve app settings
+domain=$(ynh_app_setting_get --app $app --key domain)
+path_url=$(ynh_normalize_url_path --path_url $(ynh_app_setting_get --app $app --key path))
+port=$(ynh_app_setting_get --app $app --key http_port)
+nginx_status_port=$(ynh_app_setting_get --app $app --key nginx_status_port)
+dbuser=$app
+dbname=$app
+dbpass=$(ynh_app_setting_get --app $app --key mysqlpwd)
-domain=$(ynh_app_setting_get --app=$app --key=domain)
-path_url=$(ynh_app_setting_get --app=$app --key=path)
-port=$(ynh_app_setting_get --app=$app --key=port)
-nginx_status_port=$(ynh_app_setting_get --app=$app --key=nginx_status_port)
-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)
-
-#=================================================
-# 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)..."
+# Stop services
+ynh_script_progression --message="Stoping services..."
+systemctl stop monitorix.service
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
- ynh_clean_check_starting
- # Restore it if the upgrade fails
+ # restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
@@ -49,106 +41,43 @@ ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
-# STOP SYSTEMD SERVICE
-#=================================================
-ynh_script_progression --message="Stopping a systemd service..."
-ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
+# Install package
+ynh_script_progression --message="Installing dependencies..." --weight=6
+install_dependances
-#=================================================
-# ENSURE DOWNWARD COMPATIBILITY
-#=================================================
-ynh_script_progression --message="Ensuring downward compatibility..."
+# Download package and install it
+ynh_script_progression --message="Upgrading source files..." --weight=6
+get_install_source
-# If db_name doesn't exist, create it
-if [ -z "$db_name" ]; then
- db_name=$(ynh_sanitize_dbid --db_name=$app)
- dbuser=$db_name
- ynh_app_setting_set --app=$app --key=db_name --value=$db_name
-fi
+# Update nginx config
+config_nginx
-# If port doesn't exist, create it
-if [ -z "$port" ]; then
- port=$(ynh_app_setting_get --app=$app --key=http_port)
- ynh_app_setting_set --app=$app --key=port --value=$port
- ynh_app_setting_delete --app=$app --key=http_port
-fi
+# Update monitorix configuration
+ynh_script_progression --message="Configuring application..."
+config_monitorix
# Remove old hook if exist
ynh_secure_remove --file=/usr/share/yunohost/hooks/post_iptable_rules/50-$app
-#=================================================
-# UPGRADE DEPENDENCIES
-#=================================================
-ynh_script_progression --message="Upgrading dependencies..." --weight=6
-
-ynh_install_app_dependencies $pkg_dependencies
-tempdir="$(mktemp -d)"
-ynh_setup_source --dest_dir="$tempdir"
-ynh_package_update
-dpkg --force-confdef --force-confold -i /$tempdir/app.deb
-ynh_package_install -f
-ynh_secure_remove --file="$tempdir"
-
-#=================================================
-# NGINX CONFIGURATION
-#=================================================
-ynh_script_progression --message="Upgrading NGINX web server configuration..."
-
-# Create a dedicated NGINX config
-ynh_add_nginx_config
-ynh_add_config --template="../conf/nginx_status.conf" --destination="/etc/nginx/conf.d/monitorix_status.conf"
-
-#=================================================
-# UPDATE A CONFIG FILE
-#=================================================
-ynh_script_progression --message="Updating a configuration file..."
-
-jail_list=$(fail2ban-client status | grep 'Jail list:' | sed 's/.*Jail list://' | sed 's/,//g')
-additional_jail=""
-for jail in $jail_list; do
- if ! [[ "$jail" =~ (recidive|pam-generic|yunohost|postfix|postfix-sasl|dovecot|nginx-http-auth|sshd|sshd-ddos) ]]; then
- if [ -z "$additional_jail" ]; then
- additional_jail="[$jail]"
- else
- additional_jail+=", [$jail]"
- fi
- fi
-done
-
-path_url_slash_less=${path_url%/}
-ynh_add_config --template="../conf/monitorix.conf" --destination="/etc/monitorix/monitorix.conf"
-
-chown www-data:root -R /etc/monitorix
-chmod u=rX,g=rwX,o= -R /etc/monitorix
-chown www-data:root -R /var/lib/monitorix
-chmod u=rwX,g=rwX,o= -R /var/lib/monitorix
-
#=================================================
# GENERIC FINALIZATION
#=================================================
-# INTEGRATE SERVICE IN YUNOHOST
-#=================================================
-ynh_script_progression --message="Integrating service in YunoHost..."
+# Set access
+ynh_script_progression --message="Protecting directory..."
+set_permission
+
+# register yunohost service
yunohost service add monitorix
-#=================================================
-# START SYSTEMD SERVICE
-#=================================================
-ynh_script_progression --message="Starting a systemd service..." --weight=3
-
-ynh_systemd_action --service_name=$app --action="restart" --log_path="/var/log/monitorix" --line_match=" - Ok, ready."
-
-#=================================================
-# RELOAD NGINX
-#=================================================
-ynh_script_progression --message="Reloading NGINX web server..."
-
-ynh_systemd_action --service_name=nginx --action=reload
-
-#=================================================
-# END OF SCRIPT
-#=================================================
+# Reload monitorix
+# While we stop monitorix sometime the built-in web server is not stopped cleanly. So are sure that everything is cleanly stoped by that
+# So this fix that
+ynh_script_progression --message="Starting monitorix services..." --weight=3
+systemctl stop monitorix.service
+sleep 1
+pkill -f "monitorix-httpd listening on" || true
+ynh_systemd_action -l ' - Ok, ready.' -p '/var/log/monitorix'
ynh_script_progression --message="Upgrade of $app completed" --last