diff --git a/README.md b/README.md
index d3fcba0..7318da4 100644
--- a/README.md
+++ b/README.md
@@ -15,10 +15,9 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
## Overview
-Network-wide ad blocking via your own DNS server
+The Pi-hole® is a DNS sinkhole that protects your devices from unwanted content without installing any client-side software.
-
-**Shipped version:** 5.6~ynh1
+**Shipped version:** 5.10~ynh1
@@ -35,8 +34,6 @@ Use the admin panel of your Pi-hole to configure this app. You may also need to
## Limitations
* Activate DHCP with Pi-hole needs manual configuration of your router.
-* Pi-Hole can't be updated beyond version 3.3.1, because higher versions use an integrated version of dnsmasq. This would require disabling the version of dnsmasq used by YunoHost.
-
## Using Pi-hole as your DHCP server
diff --git a/README_fr.md b/README_fr.md
index c48dd09..d3d3820 100644
--- a/README_fr.md
+++ b/README_fr.md
@@ -11,10 +11,9 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour
## Vue d'ensemble
-Network-wide ad blocking via your own DNS server
+The Pi-hole® is a DNS sinkhole that protects your devices from unwanted content without installing any client-side software.
-
-**Version incluse :** 5.6~ynh1
+**Version incluse :** 5.10~ynh1
@@ -31,8 +30,6 @@ Utiliser le panneau d'administration de votre Pi-hole pour configurer cette appl
## Limitations
* Activer DHCP avec Pi-hole nécessite une configuration manuelle de votre routeur.
-* Pi-Hole ne peut pas être mis à jour au-delà de la version 3.3.1, car les versions supérieures utilisent une version intégrée de dnsmasq. Ce qui oblige a désactiver la version de dnsmasq utilisée par YunoHost.
-
## Faire de Pi-hole votre serveur DHCP
diff --git a/actions.toml b/actions.toml
new file mode 100644
index 0000000..71fd449
--- /dev/null
+++ b/actions.toml
@@ -0,0 +1,45 @@
+[reset_default_setupvars]
+name = "Reset the config file and restore a default one."
+command = "/bin/bash scripts/actions/reset_default_config \"setupVars.conf\""
+# user = "root" # optional
+# cwd = "/" # optional
+# accepted_return_codes = [0, 1, 2, 3] # optional
+accepted_return_codes = [0]
+description = "Reset the config file setupVars.conf."
+
+[reset_default_ftl]
+name = "Reset the config file and restore a default one."
+command = "/bin/bash scripts/actions/reset_default_config \"pihole-FTL.conf\""
+# user = "root" # optional
+# cwd = "/" # optional
+# accepted_return_codes = [0, 1, 2, 3] # optional
+accepted_return_codes = [0]
+description = "Reset the config file pihole-FTL.conf."
+
+[reset_default_nginx]
+name = "Reset the nginx config for this app."
+command = "/bin/bash scripts/actions/reset_default_system nginx"
+# user = "root" # optional
+# cwd = "/" # optional
+# accepted_return_codes = [0, 1, 2, 3] # optional
+accepted_return_codes = [0]
+description = "Reset the nginx config for this app."
+
+[reset_default_phpfpm]
+name = "Reset the php-fpm config for this app."
+command = "/bin/bash scripts/actions/reset_default_system phpfpm"
+# user = "root" # optional
+# cwd = "/" # optional
+# accepted_return_codes = [0, 1, 2, 3] # optional
+accepted_return_codes = [0]
+description = "Reset the php-fpm config for this app."
+
+
+[reset_default_app]
+name = "Reset the app with a default configuration."
+command = "/bin/bash scripts/actions/reset_default_app"
+# user = "root" # optional
+# cwd = "/" # optional
+# accepted_return_codes = [0, 1, 2, 3] # optional
+accepted_return_codes = [0]
+description = "Reset the app to its default configuration to try to fix potential issues.
This action won't remove any data added to the app.
However, if you have modified any configuration, it will be overwritten."
diff --git a/check_process b/check_process
index 6ed8d48..8081413 100644
--- a/check_process
+++ b/check_process
@@ -5,7 +5,16 @@
admin="john"
query_logging=1
enable_dhcp=0
- pihole_version="Last available"
+ ; Config_panel
+ main.overwrite_files.overwrite_setupvars=0|1
+ main.overwrite_files.overwrite_ftl=0|1
+ main.overwrite_files.overwrite_nginx=0|1
+ main.overwrite_files.overwrite_phpfpm=0|1
+ main.global_config.email_type=0|1
+ main.php_fpm_config.footprint=low|medium|high
+ main.php_fpm_config.free_footprint=20
+ main.php_fpm_config.usage=low|medium|high
+ main.php_fpm_config.force_max_children=20|0
; Checks
pkg_linter=1
setup_sub_dir=1
@@ -14,34 +23,16 @@
setup_private=1
setup_public=0
upgrade=1
+ upgrade=1 from_commit=cfa9c5a3dbcfb765dcca3b2e7d179756afe26def
backup_restore=1
multi_instance=0
port_already_use=1
change_url=1
actions=0
config_panel=0
-;; Test version 3
- ; Manifest
- domain="domain.tld"
- path="/path"
- admin="john"
- query_logging=1
- enable_dhcp=0
- pihole_version="Last 3.X"
- ; Checks
- setup_sub_dir=1
- setup_root=1
- upgrade=1
- # 3.3.1~ynh1
- upgrade=1 from_commit=d79ec131b3038ff4695c3317b5d3ee4eda9c8932
- # 5.4~ynh1
- upgrade=1 from_commit=cfa9c5a3dbcfb765dcca3b2e7d179756afe26def
- backup_restore=1
- actions=1
;;; Options
Email=
-Notification=change
+Notification=none
;;; Upgrade options
- ; commit=d79ec131b3038ff4695c3317b5d3ee4eda9c8932
- name= Stretch fix
- manifest_arg=domain=DOMAIN&path=PATH&admin=USER&query_logging=1&
+ ; commit=cfa9c5a3dbcfb765dcca3b2e7d179756afe26def
+ name=Merge pull request #66
diff --git a/conf/FTL.src b/conf/FTL.src
new file mode 100644
index 0000000..b0ef874
--- /dev/null
+++ b/conf/FTL.src
@@ -0,0 +1,5 @@
+SOURCE_URL=https://github.com/pi-hole/FTL/archive/v5.12.tar.gz
+SOURCE_SUM=cc0864cdf7c10b82f04049e97dafef2eacb2b8155e7cb11e0383482f5dc0f1d6
+SOURCE_SUM_PRG=sha256sum
+SOURCE_FORMAT=tar.gz
+SOURCE_IN_SUBDIR=true
diff --git a/conf/FTL_3.src b/conf/FTL_3.src
deleted file mode 100644
index 5c35de5..0000000
--- a/conf/FTL_3.src
+++ /dev/null
@@ -1,5 +0,0 @@
-SOURCE_URL=https://github.com/pi-hole/FTL/archive/v3.0.tar.gz
-SOURCE_SUM=8c3d55eb3054698172e59ae81b8562ce235d73da461389840da62d90b32f0057
-SOURCE_SUM_PRG=sha256sum
-SOURCE_FORMAT=tar.gz
-SOURCE_IN_SUBDIR=true
diff --git a/conf/FTL_last.src b/conf/FTL_last.src
deleted file mode 100644
index bb6cd85..0000000
--- a/conf/FTL_last.src
+++ /dev/null
@@ -1,6 +0,0 @@
-SOURCE_URL=https://github.com/pi-hole/FTL/archive/v5.11.tar.gz
-SOURCE_SUM=e7f1ec8b12629ae4b1b5453f18f5247cb7c68037094c6cf7f8e046e18ce2c283
-SOURCE_SUM_PRG=sha256sum
-SOURCE_FORMAT=tar.gz
-SOURCE_IN_SUBDIR=true
-SOURCE_FILENAME=
diff --git a/conf/admin_dashboard.src b/conf/admin_dashboard.src
new file mode 100644
index 0000000..0013f5c
--- /dev/null
+++ b/conf/admin_dashboard.src
@@ -0,0 +1,5 @@
+SOURCE_URL=https://github.com/pi-hole/AdminLTE/archive/v5.12.tar.gz
+SOURCE_SUM=c770daaf5360c659ab3b9c07a118f0170307dd1e7857ece5d02ef5e3f1ead057
+SOURCE_SUM_PRG=sha256sum
+SOURCE_FORMAT=tar.gz
+SOURCE_IN_SUBDIR=true
diff --git a/conf/admin_dashboard_3.src b/conf/admin_dashboard_3.src
deleted file mode 100644
index d892835..0000000
--- a/conf/admin_dashboard_3.src
+++ /dev/null
@@ -1,5 +0,0 @@
-SOURCE_URL=https://github.com/pi-hole/AdminLTE/archive/v3.3.tar.gz
-SOURCE_SUM=caba2129fe8753b0c7aaf611b7c7b2146ff1ac56d5ac58987053b1553d09c49f
-SOURCE_SUM_PRG=sha256sum
-SOURCE_FORMAT=tar.gz
-SOURCE_IN_SUBDIR=true
diff --git a/conf/admin_dashboard_last.src b/conf/admin_dashboard_last.src
deleted file mode 100644
index 879e895..0000000
--- a/conf/admin_dashboard_last.src
+++ /dev/null
@@ -1,5 +0,0 @@
-SOURCE_URL=https://github.com/pi-hole/AdminLTE/archive/v5.8.tar.gz
-SOURCE_SUM=b594374bd3d6361ad5fa35958b17a08965fcc77d3ef4c4a7938410116b0cf5be
-SOURCE_SUM_PRG=sha256sum
-SOURCE_FORMAT=tar.gz
-SOURCE_IN_SUBDIR=true
diff --git a/conf/app.src b/conf/app.src
new file mode 100644
index 0000000..dc69b66
--- /dev/null
+++ b/conf/app.src
@@ -0,0 +1,5 @@
+SOURCE_URL=https://github.com/pi-hole/pi-hole/archive/v5.10.tar.gz
+SOURCE_SUM=fb995f62ab83713222d538e0836557de651a94f61622bf930aa88187b70ae2ee
+SOURCE_SUM_PRG=sha256sum
+SOURCE_FORMAT=tar.gz
+SOURCE_IN_SUBDIR=true
diff --git a/conf/app_3.src b/conf/app_3.src
deleted file mode 100644
index ac08837..0000000
--- a/conf/app_3.src
+++ /dev/null
@@ -1,6 +0,0 @@
-SOURCE_URL=https://github.com/pi-hole/pi-hole/archive/v3.3.1.tar.gz
-SOURCE_SUM=6a80e4b6b38fc65df83459fe52f3a61623763709a077645f25ac9e29247e6d6d
-SOURCE_SUM_PRG=sha256sum
-SOURCE_FORMAT=tar.gz
-SOURCE_IN_SUBDIR=true
-SOURCE_FILENAME=
diff --git a/conf/app_last.src b/conf/app_last.src
deleted file mode 100644
index 452929e..0000000
--- a/conf/app_last.src
+++ /dev/null
@@ -1,5 +0,0 @@
-SOURCE_URL=https://github.com/pi-hole/pi-hole/archive/v5.6.tar.gz
-SOURCE_SUM=c65f31418bdbfbf9ed482e5380f0b7f8370e69817dd1db70bea98f337198bf47
-SOURCE_SUM_PRG=sha256sum
-SOURCE_FORMAT=tar.gz
-SOURCE_IN_SUBDIR=true
diff --git a/conf/dnsmasq_regenconf_hook b/conf/dnsmasq_regenconf_hook
index e181ac4..54419ff 100755
--- a/conf/dnsmasq_regenconf_hook
+++ b/conf/dnsmasq_regenconf_hook
@@ -37,9 +37,10 @@ fi
#
ynh_replace_string --match_string="^cache-size=" --replace_string="#pihole# cache-size=" --target_file="${pending_conf}/etc/dnsmasq.conf"
-ynh_replace_string --match_string="^listen-address=" --replace_string="#pihole# cache-size=" --target_file="${pending_conf}/etc/dnsmasq.conf"
+ynh_replace_string --match_string="^listen-address=" --replace_string="#pihole# listen-address=" --target_file="${pending_conf}/etc/dnsmasq.conf"
-echo "conf-dir=/etc/dnsmasq.d/" >> "${pending_conf}/etc/dnsmasq.conf"
+echo "
+conf-dir=/etc/dnsmasq.d/" >> "${pending_conf}/etc/dnsmasq.conf"
#
# Regen /etc/dnsmasq.d/02-pihole-dhcp.conf
diff --git a/conf/nginx.conf b/conf/nginx.conf
index 43f743e..fa7d4e8 100644
--- a/conf/nginx.conf
+++ b/conf/nginx.conf
@@ -6,17 +6,16 @@ location __PATH__/ {
index index.html index.php;
- try_files $uri $uri/ index.php;
- location ~ [^/]\.php(/|$) {
- fastcgi_split_path_info ^(.+?\.php)(/.*)$;
- fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
-
- fastcgi_index index.php;
- include fastcgi_params;
- fastcgi_param REMOTE_USER $remote_user;
- fastcgi_param PATH_INFO $fastcgi_path_info;
- fastcgi_param SCRIPT_FILENAME $request_filename;
- }
+ try_files $uri $uri/ index.php;
+ location ~ [^/]\.php(/|$) {
+ fastcgi_split_path_info ^(.+?\.php)(/.*)$;
+ fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
+ fastcgi_index index.php;
+ include fastcgi_params;
+ fastcgi_param REMOTE_USER $remote_user;
+ fastcgi_param PATH_INFO $fastcgi_path_info;
+ fastcgi_param SCRIPT_FILENAME $request_filename;
+ }
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
diff --git a/config_panel.toml.example b/config_panel.toml.example
new file mode 100644
index 0000000..d8518a1
--- /dev/null
+++ b/config_panel.toml.example
@@ -0,0 +1,70 @@
+version = "0.1"
+name = "PiHole configuration panel"
+
+[main]
+name = "PiHole configuration"
+
+ [main.overwrite_files]
+ name = "Overwriting config files"
+
+ [main.overwrite_files.overwrite_setupvars]
+ ask = "Overwrite the config file setupVars.conf?"
+ type = "boolean"
+ default = true
+ help = "If the file is overwritten, a backup will be created."
+
+ [main.overwrite_files.overwrite_ftl]
+ ask = "Overwrite the config file pihole-FTL.conf?"
+ type = "boolean"
+ default = true
+ help = "If the file is overwritten, a backup will be created."
+
+ [main.overwrite_files.overwrite_nginx]
+ ask = "Overwrite the nginx config file?"
+ type = "boolean"
+ default = true
+ help = "If the file is overwritten, a backup will be created."
+
+ [main.overwrite_files.overwrite_phpfpm]
+ ask = "Overwrite the php-fpm config file?"
+ type = "boolean"
+ default = true
+ help = "If the file is overwritten, a backup will be created."
+
+
+ [main.global_config]
+ name = "Global configuration"
+
+ [main.global_config.email_type]
+ ask = "Send HTML email to admin?"
+ type = "boolean"
+ default = true
+ help = "Allow app scripts to send HTML mails instead of plain text."
+
+
+ [main.php_fpm_config]
+ name = "PHP-FPM configuration"
+
+ [main.php_fpm_config.footprint]
+ ask = "Memory footprint of the service?"
+ choices = ["low", "medium", "high", "specific"]
+ default = "low"
+ help = "low <= 20Mb per pool. medium between 20Mb and 40Mb per pool. high > 40Mb per pool.
Use specific to set a value with the following option."
+
+ [main.php_fpm_config.free_footprint]
+ ask = "Memory footprint of the service?"
+ type = "number"
+ default = "0"
+ help = "Free field to specify exactly the footprint in Mb if you don't want to use one of the three previous values."
+
+ [main.php_fpm_config.usage]
+ ask = "Expected usage of the service?"
+ choices = ["low", "medium", "high"]
+ default = "low"
+ help = "low: Personal usage, behind the sso. No RAM footprint when not used, but the impact on the processor can be high if many users are using the service.
medium: Low usage, few people or/and publicly accessible. Low RAM footprint, medium processor footprint when used.
high: High usage, frequently visited website. High RAM footprint, but lower on processor usage and quickly responding."
+
+ [main.php_fpm_config.force_max_children]
+ ask = "Force the value of pm.max_children?"
+ type = "number"
+ default = "0"
+ help = "Do not change this value unless you're sure about what you're doing !
pm.max_children is automatically defined by this formula: $max_ram / 2 / $footprint
You can force that value, and ignore the formula by changing the value here.
To reset to the default value, set to 0."
diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md
index a88ba06..819bf5b 100644
--- a/doc/DESCRIPTION.md
+++ b/doc/DESCRIPTION.md
@@ -1 +1 @@
-Network-wide ad blocking via your own DNS server
+The Pi-hole® is a DNS sinkhole that protects your devices from unwanted content without installing any client-side software.
\ No newline at end of file
diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md
index 02f09ba..fdd0fd7 100644
--- a/doc/DISCLAIMER.md
+++ b/doc/DISCLAIMER.md
@@ -5,8 +5,6 @@ Use the admin panel of your Pi-hole to configure this app. You may also need to
## Limitations
* Activate DHCP with Pi-hole needs manual configuration of your router.
-* Pi-Hole can't be updated beyond version 3.3.1, because higher versions use an integrated version of dnsmasq. This would require disabling the version of dnsmasq used by YunoHost.
-
## Using Pi-hole as your DHCP server
diff --git a/doc/DISCLAIMER_fr.md b/doc/DISCLAIMER_fr.md
index b5f17f2..a8c55e6 100644
--- a/doc/DISCLAIMER_fr.md
+++ b/doc/DISCLAIMER_fr.md
@@ -5,8 +5,6 @@ Utiliser le panneau d'administration de votre Pi-hole pour configurer cette appl
## Limitations
* Activer DHCP avec Pi-hole nécessite une configuration manuelle de votre routeur.
-* Pi-Hole ne peut pas être mis à jour au-delà de la version 3.3.1, car les versions supérieures utilisent une version intégrée de dnsmasq. Ce qui oblige a désactiver la version de dnsmasq utilisée par YunoHost.
-
## Faire de Pi-hole votre serveur DHCP
diff --git a/manifest.json b/manifest.json
index e0a4f7c..a7e68f9 100644
--- a/manifest.json
+++ b/manifest.json
@@ -6,7 +6,7 @@
"en": "Network-wide ad blocking via your own DNS server",
"fr": "Filtrage publicitaire via votre propre serveur DNS"
},
- "version": "5.6~ynh1",
+ "version": "5.10~ynh1",
"url": "https://pi-hole.net/",
"upstream": {
"license": "EUPL-1.2",
@@ -72,20 +72,6 @@
"fr": "Si vous voulez faire ça, vous devez vraiment lire cela avant !"
},
"default": false
- },
- {
- "name": "pihole_version",
- "type": "string",
- "ask": {
- "en": "Which version of Pi-Hole do you want to install?",
- "fr": "Quelle version de Pi-Hole voulez-vous installer ?"
- },
- "help": {
- "en": "The last 3.X version is the last version available with the Debian version of dnsmasq. The last available version will replace the Debian version of dnsmasq by FTLDNS.
See the readme for more information.",
- "fr": "La dernière version 3.X est la dernière version disponible avec la version Debian de dnsmasq. La dernière version disponible remplacera la version Debian de dnsmasq par FTLDNS.
Voir le readme pour plus d'informations."
- },
- "choices": ["Last 3.X","Last available"],
- "default": "Last 3.X"
}
]
}
diff --git a/scripts/_common.sh b/scripts/_common.sh
index 7659999..319f747 100755
--- a/scripts/_common.sh
+++ b/scripts/_common.sh
@@ -4,11 +4,17 @@
# COMMON VARIABLES
#=================================================
-# dependencies used by the app
-pkg_dependencies="sqlite3 idn2 php7.3-sqlite3 nettle-dev libcap2-bin build-essential libgmp-dev m4 cmake libidn11-dev libreadline-dev xxd"
+YNH_PHP_VERSION="7.3"
+
+# Dependencies
+pkg_dependencies="sqlite3 idn2 php${YNH_PHP_VERSION}-sqlite3 nettle-dev libcap2-bin build-essential libgmp-dev m4 cmake libidn11-dev libreadline-dev xxd"
+
+pihole_core_version=5.9
+dashboard_version=5.11
+FTL_version=5.14
#=================================================
-# PERSONAL HELPERS
+# FUTUR OFFICIAL HELPERS
#=================================================
#=================================================
diff --git a/scripts/_variables b/scripts/_variables
deleted file mode 100644
index 7368c4e..0000000
--- a/scripts/_variables
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/bash
-
-if [ "$YNH_APP_ARG_PIHOLE_VERSION" == "Last 3.X" ]
-then
- pihole_core_version=3.3.1
- dashboard_version=3.3
- FTL_version=3.0
-else
- pihole_core_version=5.6
- dashboard_version=5.8
- FTL_version=5.11
-fi
diff --git a/scripts/actions/reset_default_app b/scripts/actions/reset_default_app
index adbebb1..6fab71d 100755
--- a/scripts/actions/reset_default_app
+++ b/scripts/actions/reset_default_app
@@ -7,8 +7,6 @@
#=================================================
# Load common variables for all scripts.
-source scripts/_variables
-
source scripts/_common.sh
source /usr/share/yunohost/helpers
@@ -32,7 +30,6 @@ app=$YNH_APP_INSTANCE_NAME
path_url=$(ynh_app_setting_get --app=$app --key=path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
-pihole_version="$(ynh_app_setting_get --app=$app --key=pihole_version)"
#=================================================
# SPECIFIC ACTION
@@ -58,21 +55,14 @@ ynh_script_progression --message="Resetting source files..." --weight=1
# Download, check integrity, uncompress and patch the source from app.src
pihole_local_repo="/etc/.pihole"
-(cd scripts
-if [ "$pihole_version" == "Last 3.X" ]
-then
- # Overwrite the version 3.3.1
- YNH_CWD=$PWD ynh_setup_source --dest_dir="$pihole_local_repo" --source_id=app_3
- # Overwrite admin dashboard
- YNH_CWD=$PWD ynh_setup_source --dest_dir="$final_path" --source_id=admin_dashboard_3
-else
+(
+ cd scripts
# Overwrite the last version available
- YNH_CWD=$PWD ynh_setup_source --dest_dir="$pihole_local_repo" --source_id=app_last
+ YNH_CWD=$PWD ynh_setup_source --dest_dir="$pihole_local_repo" --source_id=app
# Overwrite admin dashboard
- YNH_CWD=$PWD ynh_setup_source --dest_dir="$final_path" --source_id=admin_dashboard_last
-fi
+ YNH_CWD=$PWD ynh_setup_source --dest_dir="$final_path" --source_id=admin_dashboard
-chown $app:www-data "$final_path"
+ chown $app:www-data "$final_path"
)
@@ -133,12 +123,7 @@ chown $dnsmasq_user:root /var/log/{pihole,pihole-FTL}.log
#=================================================
# This sudoers config allow pihole to execute /usr/local/bin/pihole as root without password. Nothing more.
-if [ "$pihole_version" == "Last 3.X" ]
-then
- cp "$pihole_local_repo/advanced/pihole.sudo" /etc/sudoers.d/pihole
-else
- cp "$pihole_local_repo/advanced/Templates/pihole.sudo" /etc/sudoers.d/pihole
-fi
+cp "$pihole_local_repo/advanced/Templates/pihole.sudo" /etc/sudoers.d/pihole
echo "$app ALL=NOPASSWD: /usr/local/bin/pihole" >> /etc/sudoers.d/pihole
# echo "Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin" >> /etc/sudoers.d/pihole
chmod 0440 /etc/sudoers.d/pihole
@@ -147,12 +132,7 @@ chmod 0440 /etc/sudoers.d/pihole
# REINSTALL LOGROTATE SCRIPT FOR PI-HOLE
#=================================================
-if [ "$pihole_version" == "Last 3.X" ]
-then
- cp "$pihole_local_repo/advanced/logrotate" "$pihole_storage/logrotate"
-else
- cp "$pihole_local_repo/advanced/Templates/logrotate" "$pihole_storage/logrotate"
-fi
+cp "$pihole_local_repo/advanced/Templates/logrotate" "$pihole_storage/logrotate"
sed -i "/# su #/d;" "$pihole_storage/logrotate"
#=================================================
@@ -162,19 +142,15 @@ ynh_script_progression --message="Reinstalling PiHole-FTL..." --weight=30
# Get the source of Pi-Hole-FTL
FTL_temp_path=$(mktemp -d)
-if [ "$pihole_version" == "Last 3.X" ]
-then
- # Install the version 3.3.1
- ynh_setup_source --dest_dir="$FTL_temp_path" --source_id=FTL_3
-else
- # Install the last version available
- ynh_setup_source --dest_dir="$FTL_temp_path" --source_id=FTL_last
-fi
+# Install the last version available
+ynh_setup_source --dest_dir="$FTL_temp_path" --source_id=FTL
# Instead of downloading a binary file, we're going to compile it
-( cd "$FTL_temp_path"
-ynh_exec_warn_less make
-ynh_exec_warn_less make install )
+(
+ cd "$FTL_temp_path"
+ ynh_exec_warn_less make
+ ynh_exec_warn_less make install
+)
ynh_secure_remove --file="$FTL_temp_path"
cp "../conf/dns-servers.conf" "$pihole_storage"
@@ -182,20 +158,12 @@ cp "../conf/dns-servers.conf" "$pihole_storage"
# Restore the default pihole-FTL.conf
yunohost app action run $app reset_default_ftl
-if [ "$pihole_version" == "Last 3.X" ]
-then
- # Version 3.3.1
- cp -a $pihole_local_repo/advanced/pihole-FTL.service /etc/init.d/pihole-FTL
- chmod +x /etc/init.d/pihole-FTL
- ynh_exec_warn_less systemctl enable pihole-FTL
-else
- cp -a $pihole_local_repo/advanced/Templates/pihole-FTL.service /etc/init.d/pihole-FTL
- chmod +x /etc/init.d/pihole-FTL
- ynh_exec_warn_less systemctl enable pihole-FTL
+cp -a $pihole_local_repo/advanced/Templates/pihole-FTL.service /etc/init.d/pihole-FTL
+chmod +x /etc/init.d/pihole-FTL
+ynh_exec_warn_less systemctl enable pihole-FTL
- # Reload systemd config
- systemctl daemon-reload
-fi
+# Reload systemd config
+systemctl daemon-reload
#=================================================
# RESET THE VARIABLES FILE
@@ -215,12 +183,7 @@ yunohost app action run $app reset_default_dnsmasq
# REINSTALL CRON JOB
#=================================================
-if [ "$pihole_version" == "Last 3.X" ]
-then
- cp $pihole_local_repo/advanced/pihole.cron /etc/cron.d/pihole
-else
- cp $pihole_local_repo/advanced/Templates/pihole.cron /etc/cron.d/pihole
-fi
+cp $pihole_local_repo/advanced/Templates/pihole.cron /etc/cron.d/pihole
# Remove git usage for version. Which fails because we use here a release instead of master.
ynh_replace_string --match_string=".*updatechecker.*" --replace_string="#&" --target_file=/etc/cron.d/pihole
diff --git a/scripts/config b/scripts/config
new file mode 100644
index 0000000..fef8388
--- /dev/null
+++ b/scripts/config
@@ -0,0 +1,174 @@
+#!/bin/bash
+
+#=================================================
+# GENERIC STARTING
+#=================================================
+# IMPORT GENERIC HELPERS
+#=================================================
+
+source _common.sh
+source /usr/share/yunohost/helpers
+
+#=================================================
+# RETRIEVE ARGUMENTS
+#=================================================
+
+app=$YNH_APP_INSTANCE_NAME
+
+fpm_config_dir=$(ynh_app_setting_get --app=$app --key=fpm_config_dir)
+final_path=$(ynh_app_setting_get --app=$app --key=final_path)
+
+#=================================================
+# SPECIFIC CODE
+#=================================================
+# LOAD VALUES
+#=================================================
+
+# Load the real value from the app config or elsewhere.
+# Then get the value from the form.
+# If the form has a value for a variable, take the value from the form,
+# Otherwise, keep the value from the app config.
+
+# Overwrite setupVars.conf file
+old_overwrite_setupvars="$(ynh_app_setting_get --app=$app --key=overwrite_setupvars)"
+overwrite_setupvars="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETUPVARS:-$old_overwrite_setupvars}"
+
+# Overwrite pihole-FTL.conf file
+old_overwrite_ftl="$(ynh_app_setting_get --app=$app --key=overwrite_ftl)"
+overwrite_ftl="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_FTL:-$old_overwrite_ftl}"
+
+# Overwrite nginx configuration
+old_overwrite_nginx="$(ynh_app_setting_get --app=$app --key=overwrite_nginx)"
+overwrite_nginx="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX:-$old_overwrite_nginx}"
+
+# Overwrite php-fpm configuration
+old_overwrite_phpfpm="$(ynh_app_setting_get --app=$app --key=overwrite_phpfpm)"
+overwrite_phpfpm="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_PHPFPM:-$old_overwrite_phpfpm}"
+
+
+# Type of admin mail configuration
+old_admin_mail_html="$(ynh_app_setting_get --app=$app --key=admin_mail_html)"
+admin_mail_html="${YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE:-$old_admin_mail_html}"
+
+
+# Footprint for php-fpm
+old_fpm_footprint="$(ynh_app_setting_get --app=$app --key=fpm_footprint)"
+fpm_footprint="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FOOTPRINT:-$old_fpm_footprint}"
+
+# Free footprint value for php-fpm
+# Check if fpm_footprint is an integer
+if [ "$fpm_footprint" -eq "$fpm_footprint" ] 2> /dev/null
+then
+ # If fpm_footprint is an integer, that's a numeric value for the footprint
+ old_free_footprint=$fpm_footprint
+ fpm_footprint=specific
+else
+ old_free_footprint=0
+fi
+free_footprint="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FREE_FOOTPRINT:-$old_free_footprint}"
+
+# Usage for php-fpm
+old_fpm_usage="$(ynh_app_setting_get --app=$app --key=fpm_usage)"
+fpm_usage="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_USAGE:-$old_fpm_usage}"
+
+# php_forced_max_children for php-fpm
+old_php_forced_max_children="$(ynh_app_setting_get --app=$app --key=php_forced_max_children)"
+# If php_forced_max_children isn't into settings.yml, get the current value from the fpm config
+if [ -z "$old_php_forced_max_children" ]; then
+ old_php_forced_max_children="$(grep "^pm.max_children" "$fpm_config_dir/pool.d/$app.conf" | awk '{print $3}')"
+fi
+php_forced_max_children="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FORCE_MAX_CHILDREN:-$old_php_forced_max_children}"
+
+#=================================================
+# SHOW_CONFIG FUNCTION FOR 'SHOW' COMMAND
+#=================================================
+
+show_config() {
+ # here you are supposed to read some config file/database/other then print the values
+ # ynh_return "YNH_CONFIG_${PANEL_ID}_${SECTION_ID}_${OPTION_ID}=value"
+
+ ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETUPVARS=$overwrite_setupvars"
+ ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_FTL=$overwrite_ftl"
+ ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX=$overwrite_nginx"
+ ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_PHPFPM=$overwrite_phpfpm"
+
+ ynh_return "YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE=$admin_mail_html"
+
+ ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FOOTPRINT=$fpm_footprint"
+ ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FREE_FOOTPRINT=$free_footprint"
+ ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_USAGE=$fpm_usage"
+ ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FORCE_MAX_CHILDREN=$php_forced_max_children"
+}
+
+#=================================================
+# MODIFY THE CONFIGURATION
+#=================================================
+
+apply_config() {
+
+ #=================================================
+ # MODIFY OVERWRITTING SETTINGS
+ #=================================================
+
+ # Set overwrite_setupvars
+ ynh_app_setting_set --app=$app --key=overwrite_setupvars --value="$overwrite_setupvars"
+ # Set overwrite_ftl
+ ynh_app_setting_set --app=$app --key=overwrite_ftl --value="$overwrite_ftl"
+ # Set overwrite_nginx
+ ynh_app_setting_set --app=$app --key=overwrite_nginx --value="$overwrite_nginx"
+ # Set overwrite_phpfpm
+ ynh_app_setting_set --app=$app --key=overwrite_phpfpm --value="$overwrite_phpfpm"
+
+ #=================================================
+ # MODIFY EMAIL SETTING
+ #=================================================
+
+ # Set admin_mail_html
+ ynh_app_setting_set --app=$app --key=admin_mail_html --value="$admin_mail_html"
+
+ #=================================================
+ # RECONFIGURE PHP-FPM
+ #=================================================
+
+ if [ "$fpm_usage" != "$old_fpm_usage" ] || \
+ [ "$fpm_footprint" != "$old_fpm_footprint" ] || \
+ [ "$free_footprint" != "$old_free_footprint" ] || \
+ [ "$php_forced_max_children" != "$old_php_forced_max_children" ]
+ then
+ # If fpm_footprint is set to 'specific', use $free_footprint value.
+ if [ "$fpm_footprint" = "specific" ]
+ then
+ fpm_footprint=$free_footprint
+ fi
+
+ if [ "$php_forced_max_children" != "$old_php_forced_max_children" ]
+ then
+ # Set php_forced_max_children
+ if [ $php_forced_max_children -ne 0 ]
+ then
+ ynh_app_setting_set --app=$app --key=php_forced_max_children --value="$php_forced_max_children"
+ else
+ # If the value is set to 0, remove the setting
+ ynh_app_setting_delete --app=$app --key=php_forced_max_children
+ fi
+ fi
+
+ if [ "$fpm_footprint" != "0" ]
+ then
+ ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --dedicated_service
+ else
+ ynh_print_err --message="When selecting 'specific', you have to set a footprint value into the field below."
+ fi
+ fi
+}
+
+#=================================================
+# GENERIC FINALIZATION
+#=================================================
+# SELECT THE ACTION FOLLOWING THE GIVEN ARGUMENT
+#=================================================
+
+case $1 in
+ show) show_config;;
+ apply) apply_config;;
+esac
diff --git a/scripts/install b/scripts/install
index ed15ec4..d337f1d 100644
--- a/scripts/install
+++ b/scripts/install
@@ -7,7 +7,6 @@
#=================================================
# Load common variables for all scripts.
-source _variables
source _common.sh
source /usr/share/yunohost/helpers
@@ -27,7 +26,6 @@ path_url=$YNH_APP_ARG_PATH
admin=$YNH_APP_ARG_ADMIN
query_logging=$YNH_APP_ARG_QUERY_LOGGING
enable_dhcp=$YNH_APP_ARG_ENABLE_DHCP
-pihole_version="$YNH_APP_ARG_PIHOLE_VERSION"
app=$YNH_APP_INSTANCE_NAME
@@ -52,7 +50,6 @@ ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set --app=$app --key=query_logging --value=$query_logging
ynh_app_setting_set --app=$app --key=enable_dhcp --value=$enable_dhcp
-ynh_app_setting_set --app=$app --key=pihole_version --value="$pihole_version"
ynh_app_setting_set --app=$app --key=overwrite_setupvars --value=1
ynh_app_setting_set --app=$app --key=overwrite_ftl --value=1
@@ -102,18 +99,11 @@ ynh_script_progression --message="Setting up source files..." --weight=4
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Make a copy of local pihole repository (for Gravity)
pihole_local_repo="/etc/.pihole"
-if [ "$pihole_version" == "Last 3.X" ]
-then
- # Install the version 3.3.1
- ynh_setup_source --dest_dir="$pihole_local_repo" --source_id=app_3
- # Install admin dashboard
- ynh_setup_source --dest_dir="$final_path" --source_id=admin_dashboard_3
-else
- # Install the last version available
- ynh_setup_source --dest_dir="$pihole_local_repo" --source_id=app_last
- # Install admin dashboard
- ynh_setup_source --dest_dir="$final_path" --source_id=admin_dashboard_last
-fi
+
+# Install the last version available
+ynh_setup_source --dest_dir="$pihole_local_repo" --source_id=app
+# Install admin dashboard
+ynh_setup_source --dest_dir="$final_path" --source_id=admin_dashboard
chown $app:www-data "$final_path"
@@ -176,12 +166,8 @@ chown $dnsmasq_user:root /var/log/{pihole,pihole-FTL}.log
#=================================================
# This sudoers config allow pihole to execute /usr/local/bin/pihole as root without password. Nothing more.
-if [ "$pihole_version" == "Last 3.X" ]
-then
- cp "$pihole_local_repo/advanced/pihole.sudo" /etc/sudoers.d/pihole
-else
- cp "$pihole_local_repo/advanced/Templates/pihole.sudo" /etc/sudoers.d/pihole
-fi
+cp "$pihole_local_repo/advanced/Templates/pihole.sudo" /etc/sudoers.d/pihole
+
echo "$app ALL=NOPASSWD: /usr/local/bin/pihole" >> /etc/sudoers.d/pihole
# echo "Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin" >> /etc/sudoers.d/pihole
chmod 0440 /etc/sudoers.d/pihole
@@ -190,12 +176,8 @@ chmod 0440 /etc/sudoers.d/pihole
# INSTALL LOGROTATE SCRIPT FOR PI-HOLE
#=================================================
-if [ "$pihole_version" == "Last 3.X" ]
-then
- cp "$pihole_local_repo/advanced/logrotate" "$pihole_storage/logrotate"
-else
- cp "$pihole_local_repo/advanced/Templates/logrotate" "$pihole_storage/logrotate"
-fi
+cp "$pihole_local_repo/advanced/Templates/logrotate" "$pihole_storage/logrotate"
+
sed -i "/# su #/d;" "$pihole_storage/logrotate"
#=================================================
@@ -205,65 +187,52 @@ ynh_script_progression --message="Installing PiHole-FTL..." --weight=30
# Get the source of Pi-Hole-FTL
FTL_temp_path=$(mktemp -d)
-if [ "$pihole_version" == "Last 3.X" ]
-then
- # Install the version 3.3.1
- ynh_setup_source --dest_dir="$FTL_temp_path" --source_id=FTL_3
-else
- # Install the last version available
- ynh_setup_source --dest_dir="$FTL_temp_path" --source_id=FTL_last
-fi
+# Install the last version available
+ynh_setup_source --dest_dir="$FTL_temp_path" --source_id=FTL
# Instead of downloading a binary file, we're going to compile it
-( cd "$FTL_temp_path"
-if [ "$pihole_version" == "Last available" ]
-then
- ynh_exec_warn_less cmake .
-fi
-ynh_exec_warn_less make
-ynh_exec_warn_less make install )
+(
+ cd "$FTL_temp_path"
+ ynh_exec_warn_less cmake .
+ ynh_exec_warn_less make
+ ynh_exec_warn_less make install
+)
+
ynh_secure_remove --file="$FTL_temp_path"
cp "../conf/dns-servers.conf" "$pihole_storage"
ynh_add_config --template="../conf/pihole-FTL.conf" --destination="$pihole_storage/pihole-FTL.conf"
-if [ "$pihole_version" == "Last 3.X" ]
-then
- # Version 3.3.1
- cp -a $pihole_local_repo/advanced/pihole-FTL.service /etc/init.d/pihole-FTL
- chmod +x /etc/init.d/pihole-FTL
- ynh_exec_warn_less systemctl enable pihole-FTL --quiet
-else
- # Last version available
- # Stopped dnsmasq to replace it by pihole-FTL
- ynh_systemd_action --action=stop --service_name=dnsmasq
+# Last version available
+# Stopped dnsmasq to replace it by pihole-FTL
+ynh_systemd_action --action=stop --service_name=dnsmasq
- # Disable the real dnsmasq service
- ynh_exec_warn_less systemctl disable dnsmasq --quiet
+# Disable the real dnsmasq service
+#ynh_exec_warn_less systemctl disable dnsmasq --quiet
- # And move the files that make the service available in systemd to really disable it
- mv /lib/systemd/system/dnsmasq.service /lib/systemd/system/.dnsmasq.service.backup_by_pihole
- mv /etc/init.d/dnsmasq /etc/init.d/.dnsmasq.backup_by_pihole
+# And move the files that make the service available in systemd to really disable it
+#mv /lib/systemd/system/dnsmasq.service /lib/systemd/system/.dnsmasq.service.backup_by_pihole
+#mv /etc/init.d/dnsmasq /etc/init.d/.dnsmasq.backup_by_pihole
- # Move dnsmasq to preserve the current binary
- mv /usr/sbin/dnsmasq /usr/sbin/dnsmasq.backup_by_pihole
- # Replace dnsmasq by pihole-FTL
- # NOTE: pihole-FTL is actually a modified version of dnsmasq
- # https://github.com/pi-hole/FTL/tree/master/dnsmasq
- ln -s /usr/bin/pihole-FTL /usr/sbin/dnsmasq
+# Move dnsmasq to preserve the current binary
+#mv /usr/sbin/dnsmasq /usr/sbin/dnsmasq.backup_by_pihole
+# Replace dnsmasq by pihole-FTL
+# NOTE: pihole-FTL is actually a modified version of dnsmasq
+# https://github.com/pi-hole/FTL/tree/master/dnsmasq
+#ln -s /usr/bin/pihole-FTL /usr/sbin/dnsmasq
- cp -a $pihole_local_repo/advanced/Templates/pihole-FTL.service /etc/init.d/pihole-FTL
- chmod +x /etc/init.d/pihole-FTL
- ynh_exec_warn_less systemctl enable pihole-FTL --quiet
+cp -a $pihole_local_repo/advanced/Templates/pihole-FTL.service /etc/init.d/pihole-FTL
+chmod +x /etc/init.d/pihole-FTL
+ynh_exec_warn_less systemctl enable pihole-FTL --quiet
- # Replace the service dnsmasq by pihole-FTL
- # That way, YunoHost can continue to use dnsmasq by actually using pihole-FTL
- ln -s /run/systemd/generator.late/pihole-FTL.service /etc/systemd/system/dnsmasq.service
+# Replace the service dnsmasq by pihole-FTL
+# That way, YunoHost can continue to use dnsmasq by actually using pihole-FTL
+#ln -s /run/systemd/generator.late/pihole-FTL.service /etc/systemd/system/dnsmasq.service
+systemctl mask dnsmasq.service
- # Reload systemd config
- systemctl daemon-reload
-fi
+# Reload systemd config
+systemctl daemon-reload
#=================================================
# BUILD VARIABLES FILE
@@ -326,41 +295,17 @@ echo "$pihole_core_version $dashboard_version $FTL_version" | tee $pihole_storag
# INSTALL CRON JOB
#=================================================
-if [ "$pihole_version" == "Last 3.X" ]
-then
- cp $pihole_local_repo/advanced/pihole.cron /etc/cron.d/pihole
-else
- cp $pihole_local_repo/advanced/Templates/pihole.cron /etc/cron.d/pihole
-fi
+cp $pihole_local_repo/advanced/Templates/pihole.cron /etc/cron.d/pihole
# Remove git usage for version. Which fails because we use here a release instead of master.
ynh_replace_string --match_string=".*updatechecker.*" --replace_string="#&" --target_file=/etc/cron.d/pihole
-#=================================================
-# RESTART DNSMASQ
-#=================================================
-
-# Restart dnsmasq only for the version 3.X, otherwise we're going to restart it twice.
-if [ "$pihole_version" == "Last 3.X" ]
-then
- ynh_script_progression --message="Restarting Dnsmasq..." --weight=2
-
- ynh_systemd_action --action=restart --service_name=dnsmasq
-
- ynh_systemd_action --action=restart --service_name=pihole-FTL
-fi
-
#=================================================
# BUILD THE LISTS WITH GRAVITY
#=================================================
ynh_script_progression --message="Building the lists with Gravity..." --weight=7
-if [ "$pihole_version" == "Last 3.X" ]
-then
- cp "$pihole_local_repo/adlists.default" "$pihole_storage/adlists.default"
-else
- cp "../conf/adlists.default" "$pihole_storage/adlists.list"
-fi
+cp "../conf/adlists.default" "$pihole_storage/adlists.list"
ynh_exec_warn_less /opt/pihole/gravity.sh
#=================================================
diff --git a/scripts/remove b/scripts/remove
index 07c7805..1c73819 100755
--- a/scripts/remove
+++ b/scripts/remove
@@ -18,7 +18,6 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
-pihole_version="$(ynh_app_setting_get --app=$app --key=pihole_version)"
#=================================================
# STANDARD REMOVE
@@ -38,30 +37,25 @@ fi
#=================================================
ynh_script_progression --message="Stop and remove the service"
-if [ "$pihole_version" == "Last 3.X" ]
-then
- ynh_systemd_action --action=stop --service_name=pihole-FTL
- ynh_exec_warn_less systemctl disable pihole-FTL --quiet
-else
- ynh_systemd_action --action=stop --service_name=pihole-FTL
+ynh_systemd_action --action=stop --service_name=pihole-FTL
- # Restore dnsmasq as main DNS resolver
- # Move dnsmasq back to its original place
- if [ -e "/usr/sbin/dnsmasq.backup_by_pihole" ]
- then # Remove dnsmasq only if we have its backup
- ynh_secure_remove --file="/usr/sbin/dnsmasq"
- mv /usr/sbin/dnsmasq.backup_by_pihole /usr/sbin/dnsmasq
- fi
+# Restore dnsmasq as main DNS resolver
+# Move dnsmasq back to its original place
+#if [ -e "/usr/sbin/dnsmasq.backup_by_pihole" ]
+#then # Remove dnsmasq only if we have its backup
+# ynh_secure_remove --file="/usr/sbin/dnsmasq"
+# mv /usr/sbin/dnsmasq.backup_by_pihole /usr/sbin/dnsmasq
+#fi
- # Move back the service configuration for dnsmasq
- ynh_secure_remove --file="/etc/systemd/system/dnsmasq.service"
- mv /lib/systemd/system/.dnsmasq.service.backup_by_pihole /lib/systemd/system/dnsmasq.service
- mv /etc/init.d/.dnsmasq.backup_by_pihole /etc/init.d/dnsmasq
+# Move back the service configuration for dnsmasq
+#ynh_secure_remove --file="/etc/systemd/system/dnsmasq.service"
+#mv /lib/systemd/system/.dnsmasq.service.backup_by_pihole /lib/systemd/system/dnsmasq.service
+#mv /etc/init.d/.dnsmasq.backup_by_pihole /etc/init.d/dnsmasq
+systemctl unmask dnsmasq.service
- ynh_exec_warn_less systemctl enable dnsmasq --quiet
- # Reload systemd config
- systemctl daemon-reload
-fi
+#ynh_exec_warn_less systemctl enable dnsmasq --quiet
+# Reload systemd config
+systemctl daemon-reload
ynh_secure_remove --file="/etc/init.d/pihole-FTL"
ynh_secure_remove --file="/usr/bin/pihole-FTL"
@@ -185,11 +179,9 @@ ynh_systemd_action --action=restart --service_name=dnsmasq
#=================================================
ynh_script_progression --message="Removing the dedicated system user..." --weight=2
-if [ "$pihole_version" == "Last 3.X" ]
-then
- # Dirty hack to remove correctly the user
- killall -u $app
-fi
+# Dirty hack to remove correctly the user
+killall -u $app
+
ynh_system_user_delete --username=$app
#=================================================
diff --git a/scripts/restore b/scripts/restore
index 510c023..e35ce7f 100644
--- a/scripts/restore
+++ b/scripts/restore
@@ -6,8 +6,7 @@
# IMPORT GENERIC HELPERS
#=================================================
-# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
-source ../settings/scripts/_variables
+# Load common variables for all scripts.
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@@ -30,7 +29,6 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
enable_dhcp=$(ynh_app_setting_get --app=$app --key=enable_dhcp)
admin=$(ynh_app_setting_get --app=$app --key=admin)
-pihole_version="$(ynh_app_setting_get --app=$app --key=pihole_version)"
# Get variables from ynh_add_fpm_config
fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
@@ -43,8 +41,7 @@ fpm_service=$(ynh_app_setting_get --app=$app --key=fpm_service)
#=================================================
ynh_script_progression --message="Validating restoration parameters..."
-test ! -d $final_path \
- || ynh_die --message="There is already a directory: $final_path "
+test ! -d $final_path || ynh_die --message="There is already a directory: $final_path "
#=================================================
# ACTIVATE MAINTENANCE MODE
@@ -106,7 +103,6 @@ ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --dedicated_ser
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=12
-# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
#=================================================
@@ -149,38 +145,36 @@ ynh_restore_file --origin_path="/usr/share/yunohost/hooks/conf_regen/50-dnsmasq_
# REPLACE THE DEFAULT DNSMASQ BY PIHOLE-FTL
#=================================================
-if [ "$pihole_version" == "Last available" ]
-then
- # Last version available
- # Stopped dnsmasq to replace it by pihole-FTL
- ynh_systemd_action --action=stop --service_name=dnsmasq
+# Last version available
+# Stopped dnsmasq to replace it by pihole-FTL
+ynh_systemd_action --action=stop --service_name=dnsmasq
- # Disable the real dnsmasq service
- ynh_exec_warn_less systemctl disable dnsmasq --quiet
+# Disable the real dnsmasq service
+#ynh_exec_warn_less systemctl disable dnsmasq --quiet
- # And move the files that make the service available in systemd to really disable it
- mv /lib/systemd/system/dnsmasq.service /lib/systemd/system/.dnsmasq.service.backup_by_pihole
- mv /etc/init.d/dnsmasq /etc/init.d/.dnsmasq.backup_by_pihole
+# And move the files that make the service available in systemd to really disable it
+#mv /lib/systemd/system/dnsmasq.service /lib/systemd/system/.dnsmasq.service.backup_by_pihole
+#mv /etc/init.d/dnsmasq /etc/init.d/.dnsmasq.backup_by_pihole
- # Move dnsmasq to preserve the current binary
- mv /usr/sbin/dnsmasq /usr/sbin/dnsmasq.backup_by_pihole
- # Replace dnsmasq by pihole-FTL
- # NOTE: pihole-FTL is actually a modified version of dnsmasq
- # https://github.com/pi-hole/FTL/tree/master/dnsmasq
- ln -s /usr/bin/pihole-FTL /usr/sbin/dnsmasq
+# Move dnsmasq to preserve the current binary
+#mv /usr/sbin/dnsmasq /usr/sbin/dnsmasq.backup_by_pihole
+# Replace dnsmasq by pihole-FTL
+# NOTE: pihole-FTL is actually a modified version of dnsmasq
+# https://github.com/pi-hole/FTL/tree/master/dnsmasq
+#ln -s /usr/bin/pihole-FTL /usr/sbin/dnsmasq
- pihole_local_repo="/etc/.pihole"
- cp -a $pihole_local_repo/advanced/Templates/pihole-FTL.service /etc/init.d/pihole-FTL
- chmod +x /etc/init.d/pihole-FTL
- ynh_exec_warn_less systemctl enable pihole-FTL --quiet
+pihole_local_repo="/etc/.pihole"
+cp -a $pihole_local_repo/advanced/Templates/pihole-FTL.service /etc/init.d/pihole-FTL
+chmod +x /etc/init.d/pihole-FTL
+ynh_exec_warn_less systemctl enable pihole-FTL --quiet
- # Replace the service dnsmasq by pihole-FTL
- # That way, YunoHost can continue to use dnsmasq by actually using pihole-FTL
- ln -s /run/systemd/generator.late/pihole-FTL.service /etc/systemd/system/dnsmasq.service
+# Replace the service dnsmasq by pihole-FTL
+# That way, YunoHost can continue to use dnsmasq by actually using pihole-FTL
+#ln -s /run/systemd/generator.late/pihole-FTL.service /etc/systemd/system/dnsmasq.service
+systemctl mask dnsmasq.service
- # Reload systemd config
- systemctl daemon-reload
-fi
+# Reload systemd config
+systemctl daemon-reload
#=================================================
# RESTORE DNSMASQ CONFIG
@@ -214,18 +208,6 @@ do
echo "$localipv4 $perdomain #Added by pihole#" >> /etc/hosts
done <<< "$(yunohost domain list | grep "\." | sed 's/.*: \|.*- //')"
-#=================================================
-# RESTART DNSMASQ
-#=================================================
-
-# Restart dnsmasq only for the version 3.X, otherwise we're going to restart it twice.
-if [ "$pihole_version" == "Last 3.X" ]
-then
- ynh_script_progression --message="Restarting Dnsmasq..."
-
- ynh_systemd_action --action=restart --service_name=dnsmasq
-fi
-
#=================================================
# UPDATE VARIABLES FILE
#=================================================
diff --git a/scripts/upgrade b/scripts/upgrade
index c82a0ea..f0c4228 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -7,7 +7,6 @@
#=================================================
# Load common variables for all scripts.
-source _variables
source _common.sh
source /usr/share/yunohost/helpers
@@ -118,6 +117,36 @@ if [ -z "$pihole_version" ]; then
ynh_app_setting_set --app=$app --key=pihole_version --value="$pihole_version"
fi
+#=================================================
+# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
+#=================================================
+ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=7
+
+# Backup the current version of the app
+ynh_backup_before_upgrade
+ynh_clean_setup () {
+ # restore it if the upgrade fails
+ ynh_restore_upgradebackup
+}
+# Exit if an error occurs during the execution of the script
+ynh_abort_if_errors
+
+#=================================================
+# ACTIVATE MAINTENANCE MODE
+#=================================================
+ynh_script_progression --message="Activating maintenance mode..."
+
+ynh_maintenance_mode_ON
+
+#=================================================
+# STANDARD UPGRADE STEPS
+#=================================================
+# INSTALL DEPENDENCIES
+#=================================================
+ynh_script_progression --message="Upgrading dependencies..." --weight=6
+
+ynh_install_app_dependencies $pkg_dependencies
+
#=================================================
# CREATE DEDICATED USER
#=================================================
@@ -133,19 +162,11 @@ ynh_system_user_create --username=$app
pihole_local_repo="/etc/.pihole"
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
- ynh_script_progression --message="Upgrading source files..." --weight=4
- if [ "$pihole_version" == "Last 3.X" ]
- then
- # Update the version 3.X
- ynh_setup_source --dest_dir="$pihole_local_repo" --source_id=app_3
- # Update admin dashboard
- ynh_setup_source --dest_dir="$final_path" --source_id=admin_dashboard_3
- else
- # Update the last version available
- ynh_setup_source --dest_dir="$pihole_local_repo" --source_id=app_last
- # Update admin dashboard
- ynh_setup_source --dest_dir="$final_path" --source_id=admin_dashboard_last
- fi
+ ynh_script_progression --message="Upgrading source files..." --weight=4
+ # Update the last version available
+ ynh_setup_source --dest_dir="$pihole_local_repo" --source_id=app
+ # Update admin dashboard
+ ynh_setup_source --dest_dir="$final_path" --source_id=admin_dashboard
fi
chown $app:www-data "$final_path"
@@ -207,12 +228,7 @@ cp -a "$pihole_local_repo/advanced/bash-completion/pihole" /etc/bash_completion.
#=================================================
# This sudoers config allow pihole to execute /usr/local/bin/pihole as root without password. Nothing more.
-if [ "$pihole_version" == "Last 3.X" ]
-then
- cp "$pihole_local_repo/advanced/pihole.sudo" /etc/sudoers.d/pihole
-else
- cp "$pihole_local_repo/advanced/Templates/pihole.sudo" /etc/sudoers.d/pihole
-fi
+cp "$pihole_local_repo/advanced/Templates/pihole.sudo" /etc/sudoers.d/pihole
echo "$app ALL=NOPASSWD: /usr/local/bin/pihole" >> /etc/sudoers.d/pihole
chmod 0440 /etc/sudoers.d/pihole
@@ -221,14 +237,7 @@ chmod 0440 /etc/sudoers.d/pihole
#=================================================
pihole_storage="/etc/pihole"
-if [ "$pihole_version" == "Last 3.X" ]
-then
- cp "$pihole_local_repo/advanced/logrotate" "$pihole_storage/logrotate"
- dnsmasq_user=$(grep DNSMASQ_USER= /etc/init.d/dnsmasq | cut -d'"' -f2)
-else
- cp "$pihole_local_repo/advanced/Templates/logrotate" "$pihole_storage/logrotate"
- dnsmasq_user=$(grep FTLUSER= /etc/init.d/pihole-FTL | cut -d'=' -f2)
-fi
+cp "$pihole_local_repo/advanced/Templates/logrotate" "$pihole_storage/logrotate"
sed -i "/# su #/d;" "$pihole_storage/logrotate"
#=================================================
@@ -240,26 +249,19 @@ ynh_systemd_action --action=stop --service_name=pihole-FTL
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
- # Get the source of Pi-Hole-FTL
- FTL_temp_path=$(mktemp -d)
- if [ "$pihole_version" == "Last 3.X" ]
- then
- # Install the version 3.3.1
- ynh_setup_source --dest_dir="$FTL_temp_path" --source_id=FTL_3
- else
- # Install the last version available
- ynh_setup_source --dest_dir="$FTL_temp_path" --source_id=FTL_last
- fi
+ # Get the source of Pi-Hole-FTL
+ FTL_temp_path=$(mktemp -d)
+ # Install the last version available
+ ynh_setup_source --dest_dir="$FTL_temp_path" --source_id=FTL
- # Instead of downloading a binary file, we're going to compile it
- ( cd "$FTL_temp_path"
- if [ "$pihole_version" == "Last available" ]
- then
- ynh_exec_warn_less cmake .
- fi
- ynh_exec_warn_less make
- ynh_exec_warn_less make install )
- ynh_secure_remove --file="$FTL_temp_path"
+ # Instead of downloading a binary file, we're going to compile it
+ (
+ cd "$FTL_temp_path"
+ ynh_exec_warn_less cmake .
+ ynh_exec_warn_less make
+ ynh_exec_warn_less make install
+ )
+ ynh_secure_remove --file="$FTL_temp_path"
fi
# Overwrite pihole-FTL config file only if it's allowed
@@ -268,48 +270,41 @@ then
ynh_add_config --template="../conf/pihole-FTL.conf" --destination="$pihole_storage/pihole-FTL.conf"
fi
-if [ "$pihole_version" == "Last 3.X" ]
-then
- # Version 3.3.1
- cp -a $pihole_local_repo/advanced/pihole-FTL.service /etc/init.d/pihole-FTL
- chmod +x /etc/init.d/pihole-FTL
- ynh_exec_warn_less systemctl enable pihole-FTL --quiet
-else
- # Last version available
- # Stopped dnsmasq to replace it by pihole-FTL
- ynh_systemd_action --action=stop --service_name=dnsmasq
+# Last version available
+# Stopped dnsmasq to replace it by pihole-FTL
+ynh_systemd_action --action=stop --service_name=dnsmasq
- # Disable the real dnsmasq service
- ynh_exec_warn_less systemctl disable dnsmasq --quiet
+# Disable the real dnsmasq service
+#ynh_exec_warn_less systemctl disable dnsmasq --quiet
- # And move the files that make the service available in systemd to really disable it
- if [ ! -e "/lib/systemd/system/.dnsmasq.service.backup_by_pihole" ]; then
- mv /lib/systemd/system/dnsmasq.service /lib/systemd/system/.dnsmasq.service.backup_by_pihole
- fi
- if [ ! -e "/etc/init.d/.dnsmasq.backup_by_pihole" ]; then
- mv /etc/init.d/dnsmasq /etc/init.d/.dnsmasq.backup_by_pihole
- fi
+# And move the files that make the service available in systemd to really disable it
+#if [ ! -e "/lib/systemd/system/.dnsmasq.service.backup_by_pihole" ]; then
+# mv /lib/systemd/system/dnsmasq.service /lib/systemd/system/.dnsmasq.service.backup_by_pihole
+#fi
+#if [ ! -e "/etc/init.d/.dnsmasq.backup_by_pihole" ]; then
+# mv /etc/init.d/dnsmasq /etc/init.d/.dnsmasq.backup_by_pihole
+#fi
- # Move dnsmasq to preserve the current binary
- if [ ! -e "/usr/sbin/dnsmasq.backup_by_pihole" ]; then
- mv /usr/sbin/dnsmasq /usr/sbin/dnsmasq.backup_by_pihole
- fi
- # Replace dnsmasq by pihole-FTL
- # NOTE: pihole-FTL is actually a modified version of dnsmasq
- # https://github.com/pi-hole/FTL/tree/master/dnsmasq
- ln -sf /usr/bin/pihole-FTL /usr/sbin/dnsmasq
+# Move dnsmasq to preserve the current binary
+#if [ ! -e "/usr/sbin/dnsmasq.backup_by_pihole" ]; then
+# mv /usr/sbin/dnsmasq /usr/sbin/dnsmasq.backup_by_pihole
+#fi
+# Replace dnsmasq by pihole-FTL
+# NOTE: pihole-FTL is actually a modified version of dnsmasq
+# https://github.com/pi-hole/FTL/tree/master/dnsmasq
+#ln -sf /usr/bin/pihole-FTL /usr/sbin/dnsmasq
- cp -a $pihole_local_repo/advanced/Templates/pihole-FTL.service /etc/init.d/pihole-FTL
- chmod +x /etc/init.d/pihole-FTL
- ynh_exec_warn_less systemctl enable pihole-FTL --quiet
+cp -a $pihole_local_repo/advanced/Templates/pihole-FTL.service /etc/init.d/pihole-FTL
+chmod +x /etc/init.d/pihole-FTL
+ynh_exec_warn_less systemctl enable pihole-FTL --quiet
- # Replace the service dnsmasq by pihole-FTL
- # That way, YunoHost can continue to use dnsmasq by actually using pihole-FTL
- ln -sf /run/systemd/generator.late/pihole-FTL.service /etc/systemd/system/dnsmasq.service
+# Replace the service dnsmasq by pihole-FTL
+# That way, YunoHost can continue to use dnsmasq by actually using pihole-FTL
+#ln -sf /run/systemd/generator.late/pihole-FTL.service /etc/systemd/system/dnsmasq.service
+systemctl mask dnsmasq.service
- # Reload systemd config
- systemctl daemon-reload
-fi
+# Reload systemd config
+systemctl daemon-reload
#=================================================
# BUILD VARIABLES FILE
@@ -353,12 +348,8 @@ echo "$pihole_core_version $dashboard_version $FTL_version" | tee $pihole_storag
# UPDATE CRON JOB
#=================================================
-if [ "$pihole_version" == "Last 3.X" ]
-then
- cp $pihole_local_repo/advanced/pihole.cron /etc/cron.d/pihole
-else
- cp $pihole_local_repo/advanced/Templates/pihole.cron /etc/cron.d/pihole
-fi
+cp $pihole_local_repo/advanced/Templates/pihole.cron /etc/cron.d/pihole
+
# Remove git usage for version. Which fails because we use here a release instead of master.
ynh_replace_string --match_string=".*updatechecker.*" --replace_string="#&" --target_file=/etc/cron.d/pihole