1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/pihole_ynh.git synced 2024-09-03 20:05:58 +02:00

Merge pull request #72 from YunoHost-Apps/testing

Testing
This commit is contained in:
yalh76 2022-03-11 23:21:50 +01:00 committed by GitHub
commit 0cde7b6ae3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 403 additions and 841 deletions

3
.gitignore vendored
View file

@ -1,3 +0,0 @@
*.swp
*~
Notes

View file

@ -17,7 +17,8 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
Network-wide ad blocking via your own DNS server
**Shipped version:** 5.4~ynh1
**Shipped version:** 5.6~ynh1
@ -37,8 +38,7 @@ Use the admin panel of your Pi-hole to configure this app. You may also need to
* 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
==================
## Using Pi-hole as your DHCP server
> **Be careful, you should considering that playing with your DHCP may break your network.
In case your server is down, you will lose your dns resolution and ip address.

View file

@ -11,9 +11,10 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour
## Vue d'ensemble
Filtrage publicitaire via votre propre serveur DNS
Network-wide ad blocking via your own DNS server
**Version incluse :** 5.4~ynh1
**Version incluse :** 5.6~ynh1
@ -25,7 +26,7 @@ Filtrage publicitaire via votre propre serveur DNS
## Configuration
Utiliser le panneau d'administration de votre Pi-hole pour configurer cette application. Vous devrez peut-être aussi suivre le [guide de post-installation] (https://docs.pi-hole.net/main/post-install/) pour configurer Pi-hole en tant que *serveur DNS* ou *serveur DHCP*.
Utiliser le panneau d'administration de votre Pi-hole pour configurer cette application. Vous devrez peut-être aussi suivre le [guide de post-installation](https://docs.pi-hole.net/main/post-install/) pour configurer Pi-hole en tant que *serveur DNS* ou *serveur DHCP*.
## Limitations
@ -33,8 +34,7 @@ Utiliser le panneau d'administration de votre Pi-hole pour configurer cette appl
* 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
==================
## Faire de Pi-hole votre serveur DHCP
> **Attention, vous devez savoir que toucher à votre DHCP pourrait casser votre réseau.
Dans le cas où votre serveur serait inaccessible, vous perdriez votre résolution dns et votre adresse IP.

117
YEP.md
View file

@ -1,117 +0,0 @@
#### [Level 0](https://github.com/YunoHost/doc/blob/master/packaging_apps_levels_fr.md#niveau-0)
[YEP 1.1 - Nommer son app et son dépot](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-11)
`Validated`
[YEP 1.2 - Inscrire l'app sur un "répertoire" connu](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-12)
`Validated`
#### [Level 1](https://github.com/YunoHost/doc/blob/master/packaging_apps_levels_fr.md#niveau-1)
[YEP 2.2 - Utiliser bash pour les scripts principaux](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-22)
`Validated`
[YEP 2.5 - Copier correctement des fichiers](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-25)
`Don't know`
[YEP 2.7 - Donner des permissions suffisantes aux instructions bash](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-27)
`Validated`
[YEP 2.15 - Suivre les instructions d'installation de l'application](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-215)
`Validated`
#### [Level 2](https://github.com/YunoHost/doc/blob/master/packaging_apps_levels_fr.md#niveau-2)
[YEP 1.5 - Mettre à jour régulièrement le statut de l'app](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-11)
`Validated`
[YEP 2.18.2 - Gérer l'installation à la racine dun nom de domaine](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-2182)
`Validated` - *Automatically verified.*
[YEP 2.18.3 - Gérer l'installation sur un sous-domaine](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-2183)
`Validated` - *Automatically verified.*
[YEP 2.18.4 - Gérer l'installation sur un chemin /path](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-2184)
`Validated` - *Automatically verified.*
[YEP 4.6 - Gère le multi-instance](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-11)
`Not applicable` - *Automatically verified.*
#### [Level 3](https://github.com/YunoHost/doc/blob/master/packaging_apps_levels_fr.md#niveau-3)
[YEP 2.3 - Sauvegarder les réponses lors de l'installation](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-23)
`Validated`
#### [Level 4](https://github.com/YunoHost/doc/blob/master/packaging_apps_levels_fr.md#niveau-4)
[YEP 4.1 - Lier au ldap](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-41)
`Not applicable`
[YEP 4.2 - Lier l'authentification au sso](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-42)
`Not applicable`
#### [Level 5](https://github.com/YunoHost/doc/blob/master/packaging_apps_levels_fr.md#niveau-5)
[YEP 1.3 - Indiquer la licence associée au paquet](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-13)
`Validated`
[YEP 2.1 - Respecter le format du manifeste](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-21)
`Validated` - *Automatically verified.*
[YEP 2.12 - Utiliser les commandes pratiques (helpers)](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-212)
`Validated`
[YEP 2.18.1 - Lancer le script d'installation d'une webapp correctement](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-2181)
`Not applicable`
#### [Level 6](https://github.com/YunoHost/doc/blob/master/packaging_apps_levels_fr.md#niveau-6)
[YEP 1.4 - Informer sur l'intention de maintenir un paquet](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-14)
`Validated`
[YEP 1.6 - Se tenir informé sur l'évolution du packaging d'apps](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-16)
`Validated`
[YEP 1.7 - Ajouter l'app à l'organisation YunoHost-Apps](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-17)
`Validated` - *Automatically verified.*
[YEP 1.8 - Publier des demandes de test](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-18)
`Validated`
[YEP 1.9 - Documenter l'app](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-19)
`Validated`
[YEP 1.10 - Garder un historique de version propre](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-110)
`Don't know`
[YEP 2.9 - Enlever toutes traces de l'app lors de la suppression](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-29)
`Validated`
[YEP 3.3 - Faciliter le contrôle de l'intégrité des sources](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-33)
`Validated`
[YEP 3.5 - Suivre les recommendations de la documentation de l'app](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-35)
`Validated`
[YEP 3.6 - Mettre à jour les versions contenant des CVE](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-36)
`Validated`
[YEP 4.3 - Fournir un script de sauvegarde YunoHost fonctionnel](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-43)
`Validated` - *Automatically verified.*
[YEP 4.4 - Fournir un script de restauration YunoHost fonctionnel](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-44)
`Validated` - *Automatically verified.*
#### [Level 7](https://github.com/YunoHost/doc/blob/master/packaging_apps_levels_fr.md#niveau-7)
[YEP 2.6 - Annuler l'action si les valeurs d'entrées sont incorrectes](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-26)
`Validated`
[YEP 3.2 - Ouvrir un port correctement](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-32)
`Validated`
#### [Level 8](https://github.com/YunoHost/doc/blob/master/packaging_apps_levels_fr.md#niveau-8)
[YEP 2.4 - Détecter et gérer les erreurs](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-24)
`Validated`
[YEP 2.8 - Modifier correctement une configuration système](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-28)
`Validated`
[YEP 2.16 - Vérifier la disponibilité des dépendances sur ARM, x86 et x64](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-216)
`Not yet validated` - *Automatically verified.*
[YEP 2.18.5 - Gérer la tuile YunoHost pour faciliter la navigation entre les applications](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-2185)
`Validated`
[YEP 3.4 - Isoler l'app](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-34)
`Partially validated`
[YEP 4.5 - Utiliser les hooks](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-45)
`Validated`
#### [Level 9](https://github.com/YunoHost/doc/blob/master/packaging_apps_levels_fr.md#niveau-9)
[YEP 2.10 - Configurer les logs de l'application](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-210)
`Validated`
[YEP 2.11 - Utiliser une variable plutôt que l'app id directement](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-211)
`Validated`
[YEP 2.13 - Traduire le paquet en anglais](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-213)
`Partially validated`
[YEP 2.14 - Remplir correctement un fichier de conf](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-214)
`Not yet validated`
[YEP 2.17 - Prendre en compte la version d'origine lors des mises à jour](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-217)
`Validated`
[YEP 4.2.1 - Déconnexion](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-421)
`Not applicable`
#### Other YEP
[YEP 3.1 - Ne pas demander ou stocker de mot de passe LDAP](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-31)
`Validated`
[YEP 4.7 - Ajouter un module à la CLI](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-47)
`Not applicable`
[YEP 4.8 - Ajouter un module à l'admin web](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-48)
`Not applicable`
State of each YEP can be one of these: `Validated`, `Partially validated`, `Not yet validated`, `Not applicable`, `Don't know`.

View file

@ -1,45 +0,0 @@
[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.<br>This action won't remove any data added to the app.<br>However, if you have modified any configuration, it will be overwritten."

View file

@ -6,16 +6,6 @@
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
@ -28,8 +18,8 @@
multi_instance=0
port_already_use=1
change_url=1
actions=1
config_panel=1
actions=0
config_panel=0
;; Test version 3
; Manifest
domain="domain.tld"
@ -42,7 +32,10 @@
setup_sub_dir=1
setup_root=1
upgrade=1
upgrade=1 from_commit=d79ec131b3038ff4695c3317b5d3ee4eda9c8932
# 3.3.1~ynh1
upgrade=1 from_commit=d79ec131b3038ff4695c3317b5d3ee4eda9c8932
# 5.4~ynh1
upgrade=1 from_commit=cfa9c5a3dbcfb765dcca3b2e7d179756afe26def
backup_restore=1
actions=1
;;; Options

View file

@ -3,4 +3,3 @@ SOURCE_SUM=8c3d55eb3054698172e59ae81b8562ce235d73da461389840da62d90b32f0057
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=

View file

@ -1,5 +1,5 @@
SOURCE_URL=https://github.com/pi-hole/FTL/archive/v5.9.tar.gz
SOURCE_SUM=e10009f57a52434c70f6ca3abcac01b8a6a4365b8b257e9d1bdd2f6c3d509bc2
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

View file

@ -3,9 +3,6 @@
##StevenBlack's list
https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
##MalwareDomains
https://mirror1.malwaredomains.com/files/justdomains
##Cameleon
http://sysctl.org/cameleon/hosts
@ -14,6 +11,3 @@ https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt
##Disconnect.me Ads
https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt
##Hosts-file.net
https://hosts-file.net/ad_servers.txt

View file

@ -3,4 +3,3 @@ SOURCE_SUM=caba2129fe8753b0c7aaf611b7c7b2146ff1ac56d5ac58987053b1553d09c49f
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=

View file

@ -1,6 +1,5 @@
SOURCE_URL=https://github.com/pi-hole/AdminLTE/archive/v5.6.tar.gz
SOURCE_SUM=1b959de820fa9fb39999f5244a0201d26a1df9846ad3151dc6d66dd8fdda92dd
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
SOURCE_FILENAME=

View file

@ -1,6 +1,5 @@
SOURCE_URL=https://github.com/pi-hole/pi-hole/archive/v5.4.tar.gz
SOURCE_SUM=dc82465f3b257d170cd0089a249bdee5378a8f52166ae95d1d7dc00512ef505c
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
SOURCE_FILENAME=

View file

@ -1,27 +1,23 @@
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {
# Path to source
alias __FINALPATH__/;
# Path to source
alias __FINALPATH__/;
# Force usage of https
if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent;
}
index index.html index.php;
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;
try_files $uri $uri/ index.php;
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php/php7.3-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;
}
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;
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
}

View file

@ -1,70 +0,0 @@
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.<br>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.<br>medium: Low usage, few people or/and publicly accessible. Low RAM footprint, medium processor footprint when used.<br>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 !<br>pm.max_children is automatically defined by this formula: $max_ram / 2 / $footprint<br>You can force that value, and ignore the formula by changing the value here.<br>To reset to the default value, set to 0."

BIN
doc/.DS_Store vendored

Binary file not shown.

0
doc/.gitkeep Normal file
View file

1
doc/DESCRIPTION.md Normal file
View file

@ -0,0 +1 @@
Network-wide ad blocking via your own DNS server

View file

@ -8,8 +8,7 @@ Use the admin panel of your Pi-hole to configure this app. You may also need to
* 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
==================
## Using Pi-hole as your DHCP server
> **Be careful, you should considering that playing with your DHCP may break your network.
In case your server is down, you will lose your dns resolution and ip address.

View file

@ -1,6 +1,6 @@
## Configuration
Utiliser le panneau d'administration de votre Pi-hole pour configurer cette application. Vous devrez peut-être aussi suivre le [guide de post-installation] (https://docs.pi-hole.net/main/post-install/) pour configurer Pi-hole en tant que *serveur DNS* ou *serveur DHCP*.
Utiliser le panneau d'administration de votre Pi-hole pour configurer cette application. Vous devrez peut-être aussi suivre le [guide de post-installation](https://docs.pi-hole.net/main/post-install/) pour configurer Pi-hole en tant que *serveur DNS* ou *serveur DHCP*.
## Limitations
@ -8,8 +8,7 @@ Utiliser le panneau d'administration de votre Pi-hole pour configurer cette appl
* 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
==================
## Faire de Pi-hole votre serveur DHCP
> **Attention, vous devez savoir que toucher à votre DHCP pourrait casser votre réseau.
Dans le cas où votre serveur serait inaccessible, vous perdriez votre résolution dns et votre adresse IP.

0
doc/screenshots/.gitkeep Normal file
View file

View file

@ -6,7 +6,7 @@
"en": "Network-wide ad blocking via your own DNS server",
"fr": "Filtrage publicitaire via votre propre serveur DNS"
},
"version": "5.4~ynh1",
"version": "5.6~ynh1",
"url": "https://pi-hole.net/",
"upstream": {
"license": "EUPL-1.2",
@ -24,7 +24,7 @@
"email": "maniackc_dev@crudelis.fr"
}],
"requirements": {
"yunohost": ">= 4.2.7"
"yunohost": ">= 4.3.0"
},
"multi_instance": false,
"services": [
@ -32,11 +32,10 @@
"php7.3-fpm"
],
"arguments": {
"install" : [
"install": [
{
"name": "domain",
"type": "domain",
"example": "domain.org"
"type": "domain"
},
{
"name": "path",
@ -46,8 +45,7 @@
},
{
"name": "admin",
"type": "user",
"example": "john"
"type": "user"
},
{
"name": "query_logging",

View file

@ -1,7 +1,14 @@
#!/bin/bash
#=================================================
# FUTUR OFFICIAL HELPERS
# 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"
#=================================================
# PERSONAL HELPERS
#=================================================
#=================================================
@ -364,4 +371,8 @@ ynh_app_changelog () {
then
echo "No significative changes from the changelog..." > "${final_changelog}_lite"
fi
}
}
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -1,15 +1,12 @@
#!/bin/bash
# Dependencies
app_depencencies="sqlite3 idn2 php7.3-sqlite3 nettle-dev libcap2-bin build-essential libgmp-dev m4 cmake libidn11-dev libreadline-dev xxd"
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.4
dashboard_version=5.6
FTL_version=5.9
pihole_core_version=5.6
dashboard_version=5.8
FTL_version=5.11
fi

View file

@ -6,6 +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/_common.sh
source /usr/share/yunohost/helpers
@ -36,7 +37,7 @@ fpm_config_dir=$(ynh_app_setting_get --app=$app --key=fpm_config_dir)
ynh_print_info --message="Declaring files to be backed up..."
#=================================================
# BACKUP THE MAIN APP DIRECTORIES
# BACKUP THE APP MAIN DIRECTORIES
#=================================================
ynh_backup --src_path="$final_path"
@ -45,13 +46,13 @@ ynh_backup --src_path="/etc/pihole"
ynh_backup --src_path="/opt/pihole"
#=================================================
# BACKUP NGINX CONFIGURATION
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP PHP-FPM CONFIGURATION
# BACKUP THE PHP-FPM CONFIGURATION
#=================================================
ynh_backup --src_path="$fpm_config_dir/php-fpm-$app.conf"
@ -60,15 +61,11 @@ ynh_backup --src_path="$fpm_config_dir/pool.d/$app.conf"
#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP CRON FILE
# BACKUP VARIOUS FILES
#=================================================
ynh_backup --src_path="/etc/cron.d/pihole"
#=================================================
# BACKUP SPECIFIC FILES
#=================================================
ynh_backup --src_path="/usr/local/bin/pihole"
ynh_backup --src_path="/etc/bash_completion.d/pihole"
@ -78,7 +75,7 @@ ynh_backup --src_path="/etc/init.d/pihole-FTL"
ynh_backup --src_path="/usr/bin/pihole-FTL"
if test -e "/etc/dnsmasq.d/03-pihole-wildcard.conf"; then
ynh_backup --src_path="/etc/dnsmasq.d/03-pihole-wildcard.conf"
ynh_backup --src_path="/etc/dnsmasq.d/03-pihole-wildcard.conf"
fi
ynh_backup --src_path="/usr/share/yunohost/hooks/conf_regen/50-dnsmasq_$app"

View file

@ -26,21 +26,22 @@ app=$YNH_APP_INSTANCE_NAME
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=2
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=11
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# 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
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@ -61,13 +62,13 @@ ynh_maintenance_mode_ON
change_domain=0
if [ "$old_domain" != "$new_domain" ]
then
change_domain=1
change_domain=1
fi
change_path=0
if [ "$old_path" != "$new_path" ]
then
change_path=1
change_path=1
fi
#=================================================
@ -79,29 +80,26 @@ 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
# Change the path in the NGINX config file
if [ $change_path -eq 1 ]
then
# Make a backup of the original nginx config file if modified
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for nginx helper
domain="$old_domain"
path_url="$new_path"
# Create a dedicated nginx config
ynh_add_nginx_config
# Make a backup of the original NGINX config file if modified
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for NGINX helper
domain="$old_domain"
path_url="$new_path"
# Create a dedicated NGINX config
ynh_add_nginx_config
fi
# Change the domain for nginx
# 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"
# 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
#=================================================

View file

@ -1,174 +0,0 @@
#!/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

View file

@ -1,19 +1,18 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Load common variables for all scripts.
source _variables
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE FAILURE OF THE SCRIPT
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
@ -33,7 +32,7 @@ pihole_version="$YNH_APP_ARG_PIHOLE_VERSION"
app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=2
@ -68,11 +67,11 @@ ynh_app_setting_set --app=$app --key=admin_mail_html --value=1
#=================================================
ynh_script_progression --message="Finding an available port..." --weight=12
# Find a free port
# Find an available port
port=$(ynh_find_port --port=4711)
if [ $port -gt 4720 ]
then
ynh_die --message="The ports 4711 to 4720 are already in use. Pi-hole can't work on another port. Please try to free one of these ports."
ynh_die --message="The ports 4711 to 4720 are already in use. Pi-hole can't work on another port. Please try to free one of these ports."
fi
ynh_app_setting_set --app=$app --key=port --value=$port
@ -85,15 +84,15 @@ ynh_exec_fully_quiet yunohost firewall allow Both 53 --no-upnp
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=12
ynh_install_app_dependencies $app_depencencies
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=2
# Create a dedicated system user
ynh_system_user_create --username=$app
# Create a system user
ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@ -105,15 +104,15 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path
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
# 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
# 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
chown $app:www-data "$final_path"
@ -121,17 +120,17 @@ chown $app:www-data "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring nginx web server..." --weight=2
ynh_script_progression --message="Configuring NGINX web server..." --weight=2
# Create a dedicated nginx config
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring php-fpm..." --weight=2
ynh_script_progression --message="Configuring PHP-FPM..." --weight=2
# Create a dedicated php-fpm config
# Create a dedicated PHP-FPM config
ynh_add_fpm_config --usage=low --footprint=low --dedicated_service
#=================================================
@ -179,9 +178,9 @@ 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
cp "$pihole_local_repo/advanced/pihole.sudo" /etc/sudoers.d/pihole
else
cp "$pihole_local_repo/advanced/Templates/pihole.sudo" /etc/sudoers.d/pihole
cp "$pihole_local_repo/advanced/Templates/pihole.sudo" /etc/sudoers.d/pihole
fi
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
@ -193,9 +192,9 @@ chmod 0440 /etc/sudoers.d/pihole
if [ "$pihole_version" == "Last 3.X" ]
then
cp "$pihole_local_repo/advanced/logrotate" "$pihole_storage/logrotate"
cp "$pihole_local_repo/advanced/logrotate" "$pihole_storage/logrotate"
else
cp "$pihole_local_repo/advanced/Templates/logrotate" "$pihole_storage/logrotate"
cp "$pihole_local_repo/advanced/Templates/logrotate" "$pihole_storage/logrotate"
fi
sed -i "/# su #/d;" "$pihole_storage/logrotate"
@ -208,18 +207,18 @@ ynh_script_progression --message="Installing PiHole-FTL..." --weight=30
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
# 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
# Install the last version available
ynh_setup_source --dest_dir="$FTL_temp_path" --source_id=FTL_last
fi
# 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 .
ynh_exec_warn_less cmake .
fi
ynh_exec_warn_less make
ynh_exec_warn_less make install )
@ -231,39 +230,39 @@ ynh_add_config --template="../conf/pihole-FTL.conf" --destination="$pihole_stora
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
# 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
# Reload systemd config
systemctl daemon-reload
# Reload systemd config
systemctl daemon-reload
fi
#=================================================
@ -280,9 +279,9 @@ echo "IPV6_ADDRESS=::1" >> $setupVars
echo "PIHOLE_DNS_1=" >> $setupVars
echo "PIHOLE_DNS_2=" >> $setupVars
if [ $query_logging -eq 1 ]; then
query_logging=true
query_logging=true
else
query_logging=false
query_logging=false
fi
echo "QUERY_LOGGING=$query_logging" >> $setupVars
echo "INSTALL_WEB=true" >> $setupVars
@ -293,7 +292,7 @@ ynh_store_file_checksum --file="$setupVars"
#=================================================
# CONFIGURE DNS FOR THE LOCAL DOMAINS
#=================================================
ynh_script_progression --message="Configuring dns for the local domains..." --weight=7
ynh_script_progression --message="Configuring DNS for the local domains..." --weight=7
# Find the IP associated to the network interface
localipv4=$(ip address | grep "${main_iface}\$" | awk '{print $2;}' | cut -d/ -f1)
@ -301,12 +300,12 @@ localipv4=$(ip address | grep "${main_iface}\$" | awk '{print $2;}' | cut -d/ -f
# List all YunoHost domains
while read perdomain
do
# Comment domain resolution in /etc/hosts on 127.0.0.1, because they can interfere with the local network resolution.
ynh_replace_string --match_string="^127.0.0.1.*$perdomain" --replace_string="#Commented by pihole# &" --target_file=/etc/hosts
# Comment domain resolution in /etc/hosts on 127.0.0.1, because they can interfere with the local network resolution.
ynh_replace_string --match_string="^127.0.0.1.*$perdomain" --replace_string="#Commented by pihole# &" --target_file=/etc/hosts
# And add a resolution on the local IP instead
grep -q "^$localipv4.*$perdomain" /etc/hosts || \
echo "$localipv4 $perdomain #Added by pihole#" >> /etc/hosts
# And add a resolution on the local IP instead
grep -q "^$localipv4.*$perdomain" /etc/hosts || \
echo "$localipv4 $perdomain #Added by pihole#" >> /etc/hosts
done <<< "$(yunohost domain list | grep "\." | sed 's/.*: \|.*- //')"
#=================================================
@ -329,9 +328,9 @@ echo "$pihole_core_version $dashboard_version $FTL_version" | tee $pihole_storag
if [ "$pihole_version" == "Last 3.X" ]
then
cp $pihole_local_repo/advanced/pihole.cron /etc/cron.d/pihole
cp $pihole_local_repo/advanced/pihole.cron /etc/cron.d/pihole
else
cp $pihole_local_repo/advanced/Templates/pihole.cron /etc/cron.d/pihole
cp $pihole_local_repo/advanced/Templates/pihole.cron /etc/cron.d/pihole
fi
# Remove git usage for version. Which fails because we use here a release instead of master.
@ -344,11 +343,11 @@ ynh_replace_string --match_string=".*updatechecker.*" --replace_string="#&" --ta
# 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_script_progression --message="Restarting Dnsmasq..." --weight=2
ynh_systemd_action --action=restart --service_name=dnsmasq
ynh_systemd_action --action=restart --service_name=dnsmasq
ynh_systemd_action --action=restart --service_name=pihole-FTL
ynh_systemd_action --action=restart --service_name=pihole-FTL
fi
#=================================================
@ -358,9 +357,9 @@ 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"
cp "$pihole_local_repo/adlists.default" "$pihole_storage/adlists.default"
else
cp "../conf/adlists.default" "$pihole_storage/adlists.list"
cp "../conf/adlists.default" "$pihole_storage/adlists.list"
fi
ynh_exec_warn_less /opt/pihole/gravity.sh
@ -413,12 +412,12 @@ admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)
if [ $enable_dhcp -eq 1 ]
then
dhcp_alert="You asked to use the internal DHCP server of dnsmasq with PiHole.
dhcp_alert="You asked to use the internal DHCP server of dnsmasq with PiHole.
You should really read the __URL_TAG1__documentation about that__URL_TAG2__https://github.com/YunoHost-Apps/pihole_ynh/blob/master/dhcp.md__URL_TAG3__
"
else
dhcp_alert=""
dhcp_alert=""
fi
echo "${dhcp_alert}You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__.

View file

@ -1,7 +1,7 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -23,14 +23,14 @@ pihole_version="$(ynh_app_setting_get --app=$app --key=pihole_version)"
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE SERVICE FROM ADMIN PANEL
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#=================================================
# Check if the service is declared in YunoHost
if ynh_exec_fully_quiet yunohost service status pihole-FTL
then
ynh_script_progression --message="Removing pihole-FTL service..." --weight=2
yunohost service remove pihole-FTL
ynh_script_progression --message="Removing pihole-FTL service..." --weight=2
yunohost service remove pihole-FTL
fi
#=================================================
@ -40,27 +40,27 @@ 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
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
ynh_exec_warn_less systemctl enable dnsmasq --quiet
# Reload systemd config
systemctl daemon-reload
ynh_exec_warn_less systemctl enable dnsmasq --quiet
# Reload systemd config
systemctl daemon-reload
fi
ynh_secure_remove --file="/etc/init.d/pihole-FTL"
@ -95,7 +95,7 @@ ynh_secure_remove --file="/etc/.pihole"
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..."
# Remove the dedicated nginx config
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================
@ -103,7 +103,7 @@ ynh_remove_nginx_config
#=================================================
ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=2
# Remove the dedicated php-fpm config
# Remove the dedicated PHP-FPM config
ynh_remove_fpm_config
#=================================================
@ -113,28 +113,25 @@ ynh_script_progression --message="Closing ports $port and 67..." --weight=13
if yunohost firewall list | grep -q "\- $port$"
then
ynh_print_info "Close port $port"
ynh_exec_quiet yunohost firewall disallow TCP $port
ynh_print_info "Close port $port"
ynh_exec_quiet yunohost firewall disallow TCP $port
fi
if yunohost firewall list | grep -q "\- 67$"
then
ynh_print_info "Close port 67"
ynh_exec_quiet yunohost firewall disallow UDP 67
ynh_print_info "Close port 67"
ynh_exec_quiet yunohost firewall disallow UDP 67
fi
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE CRON FILE
# REMOVE VARIOUS FILES
#=================================================
ynh_script_progression --message="Removing various files..."
ynh_secure_remove --file="/etc/cron.d/pihole"
#=================================================
# REMOVE OTHER FILES
#=================================================
# Remove logs
ynh_secure_remove --file="/var/log/pihole.log"
ynh_secure_remove --file="/var/log/pihole-FTL.log"
@ -182,7 +179,7 @@ ynh_script_progression --message="Restarting Dnsmasq..."
ynh_systemd_action --action=restart --service_name=dnsmasq
#=================================================
# GENERIC FINALISATION
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
@ -190,8 +187,8 @@ ynh_script_progression --message="Removing the dedicated system user..." --weigh
if [ "$pihole_version" == "Last 3.X" ]
then
# Dirty hack to remove correctly the user
killall -u $app
# Dirty hack to remove correctly the user
killall -u $app
fi
ynh_system_user_delete --username=$app

View file

@ -6,9 +6,8 @@
# IMPORT GENERIC HELPERS
#=================================================
# Load common variables for all scripts.
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_variables
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@ -44,10 +43,8 @@ fpm_service=$(ynh_app_setting_get --app=$app --key=fpm_service)
#=================================================
ynh_script_progression --message="Validating restoration parameters..."
ynh_webpath_available --domain=$domain --path_url=$path_url \
|| ynh_die --message="Path not available: ${domain}${path_url}"
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
|| ynh_die --message="There is already a directory: $final_path "
#=================================================
# ACTIVATE MAINTENANCE MODE
@ -64,6 +61,14 @@ ynh_maintenance_mode_ON
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=2
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# RESTORE THE MAIN DIRECTORIES OF THE APP
#=================================================
@ -77,18 +82,6 @@ ynh_restore_file --origin_path="/etc/pihole"
ynh_restore_file --origin_path="/opt/pihole"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=2
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app
#=================================================
# RESTORE USER RIGHTS
#=================================================
# Restore permissions on app files
chown $app: -R "/etc/pihole"
# /etc/pihole/logrotate have to belong to root, otherwise logrotate will failed silently...
@ -113,7 +106,8 @@ ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --dedicated_ser
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=12
ynh_install_app_dependencies $app_depencencies
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
@ -157,35 +151,35 @@ ynh_restore_file --origin_path="/usr/share/yunohost/hooks/conf_regen/50-dnsmasq_
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
# Reload systemd config
systemctl daemon-reload
# Reload systemd config
systemctl daemon-reload
fi
#=================================================
@ -194,7 +188,7 @@ fi
ynh_script_progression --message="Restoring Dnsmasq config..."
test -e "${YNH_APP_BACKUP_DIR}/etc/dnsmasq.d/03-pihole-wildcard.conf" && \
ynh_restore_file --origin_path="/etc/dnsmasq.d/03-pihole-wildcard.conf"
ynh_restore_file --origin_path="/etc/dnsmasq.d/03-pihole-wildcard.conf"
systemctl daemon-reload
ynh_exec_warn_less yunohost tools regen-conf dnsmasq
@ -212,12 +206,12 @@ localipv4=$(ip address | grep "${main_iface}\$" | awk '{print $2;}' | cut -d/ -f
# List all YunoHost domains
while read perdomain
do
# Comment domain resolution in /etc/hosts on 127.0.0.1, because they can interfere with the local network resolution.
ynh_replace_string --match_string="^127.0.0.1.*$perdomain" --replace_string="#Commented by pihole# &" --target_file=/etc/hosts
# Comment domain resolution in /etc/hosts on 127.0.0.1, because they can interfere with the local network resolution.
ynh_replace_string --match_string="^127.0.0.1.*$perdomain" --replace_string="#Commented by pihole# &" --target_file=/etc/hosts
# And add a resolution on the local IP instead
grep -q "^$localipv4.*$perdomain" /etc/hosts || \
echo "$localipv4 $perdomain #Added by pihole#" >> /etc/hosts
# And add a resolution on the local IP instead
grep -q "^$localipv4.*$perdomain" /etc/hosts || \
echo "$localipv4 $perdomain #Added by pihole#" >> /etc/hosts
done <<< "$(yunohost domain list | grep "\." | sed 's/.*: \|.*- //')"
#=================================================
@ -227,9 +221,9 @@ done <<< "$(yunohost domain list | grep "\." | sed 's/.*: \|.*- //')"
# 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_script_progression --message="Restarting Dnsmasq..."
ynh_systemd_action --action=restart --service_name=dnsmasq
ynh_systemd_action --action=restart --service_name=dnsmasq
fi
#=================================================
@ -254,7 +248,7 @@ ynh_exec_warn_less systemctl enable pihole-FTL --quiet
ynh_systemd_action --action=restart --service_name=pihole-FTL
#=================================================
# GENERIC FINALISATION
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
@ -279,12 +273,12 @@ admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)
if [ $enable_dhcp -eq 1 ]
then
dhcp_alert="You asked to use the internal DHCP server of Dnsmasq with PiHole.
dhcp_alert="You asked to use the internal DHCP server of Dnsmasq with PiHole.
You should really read the __URL_TAG1__documentation about that__URL_TAG2__https://github.com/YunoHost-Apps/pihole_ynh/blob/master/dhcp.md__URL_TAG3__
"
else
dhcp_alert=""
dhcp_alert=""
fi
echo "${dhcp_alert}You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__.

View file

@ -1,14 +1,13 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Load common variables for all scripts.
source _variables
source _common.sh
source /usr/share/yunohost/helpers
@ -32,69 +31,17 @@ overwrite_setupvars=$(ynh_app_setting_get --app=$app --key=overwrite_setupvars)
overwrite_ftl=$(ynh_app_setting_get --app=$app --key=overwrite_ftl)
overwrite_nginx=$(ynh_app_setting_get --app=$app --key=overwrite_nginx)
overwrite_phpfpm=$(ynh_app_setting_get --app=$app --key=overwrite_phpfpm)
admin_mail_html=$(ynh_app_setting_get --app=$app --key=admin_mail_html)
fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
# If overwrite_setupvars doesn't exist, create it
if [ -z "$overwrite_setupvars" ]; then
overwrite_setupvars=1
ynh_app_setting_set --app=$app --key=overwrite_setupvars --value=$overwrite_setupvars
fi
# If overwrite_ftl doesn't exist, create it
if [ -z "$overwrite_ftl" ]; then
overwrite_ftl=1
ynh_app_setting_set --app=$app --key=overwrite_ftl --value=$overwrite_ftl
fi
# If overwrite_nginx doesn't exist, create it
if [ -z "$overwrite_nginx" ]; then
overwrite_nginx=1
ynh_app_setting_set --app=$app --key=overwrite_nginx --value=$overwrite_nginx
fi
# If overwrite_phpfpm doesn't exist, create it
if [ -z "$overwrite_phpfpm" ]; then
overwrite_phpfpm=1
ynh_app_setting_set --app=$app --key=overwrite_phpfpm --value=$overwrite_phpfpm
fi
# If admin_mail_html doesn't exist, create it
if [ -z "$admin_mail_html" ]; then
admin_mail_html=1
ynh_app_setting_set --app=$app --key=admin_mail_html --value=$admin_mail_html
fi
# If fpm_footprint doesn't exist, create it
if [ -z "$fpm_footprint" ]; then
fpm_footprint=low
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint
fi
# If fpm_usage doesn't exist, create it
if [ -z "$fpm_usage" ]; then
fpm_usage=low
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
fi
# If pihole_version doesn't exist, create it
if [ -z "$pihole_version" ]; then
pihole_version="Last 3.X"
ynh_app_setting_set --app=$app --key=pihole_version --value="$pihole_version"
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
@ -103,8 +50,8 @@ ynh_script_progression --message="Backing up the app before upgrading (may take
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# restore it if the upgrade fails
ynh_restore_upgradebackup
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@ -119,11 +66,57 @@ ynh_maintenance_mode_ON
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# INSTALL DEPENDENCIES
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=6
ynh_script_progression --message="Ensuring downward compatibility..."
ynh_install_app_dependencies $app_depencencies
# If overwrite_setupvars doesn't exist, create it
if [ -z "$overwrite_setupvars" ]; then
overwrite_setupvars=1
ynh_app_setting_set --app=$app --key=overwrite_setupvars --value=$overwrite_setupvars
fi
# If overwrite_ftl doesn't exist, create it
if [ -z "$overwrite_ftl" ]; then
overwrite_ftl=1
ynh_app_setting_set --app=$app --key=overwrite_ftl --value=$overwrite_ftl
fi
# If overwrite_nginx doesn't exist, create it
if [ -z "$overwrite_nginx" ]; then
overwrite_nginx=1
ynh_app_setting_set --app=$app --key=overwrite_nginx --value=$overwrite_nginx
fi
# If overwrite_phpfpm doesn't exist, create it
if [ -z "$overwrite_phpfpm" ]; then
overwrite_phpfpm=1
ynh_app_setting_set --app=$app --key=overwrite_phpfpm --value=$overwrite_phpfpm
fi
# If admin_mail_html doesn't exist, create it
if [ -z "$admin_mail_html" ]; then
admin_mail_html=1
ynh_app_setting_set --app=$app --key=admin_mail_html --value=$admin_mail_html
fi
# If fpm_footprint doesn't exist, create it
if [ -z "$fpm_footprint" ]; then
fpm_footprint=low
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint
fi
# If fpm_usage doesn't exist, create it
if [ -z "$fpm_usage" ]; then
fpm_usage=low
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
fi
# If pihole_version doesn't exist, create it
if [ -z "$pihole_version" ]; then
pihole_version="Last 3.X"
ynh_app_setting_set --app=$app --key=pihole_version --value="$pihole_version"
fi
#=================================================
# CREATE DEDICATED USER
@ -140,19 +133,19 @@ 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
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
fi
chown $app:www-data "$final_path"
@ -164,11 +157,18 @@ chown $app:www-data "$final_path"
# Overwrite the nginx configuration only if it's allowed
if [ $overwrite_nginx -eq 1 ]
then
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
# Create a dedicated nginx config
ynh_add_nginx_config
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
# Create a dedicated NGINX config
ynh_add_nginx_config
fi
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=6
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
@ -176,9 +176,9 @@ fi
# Overwrite the php-fpm configuration only if it's allowed
if [ $overwrite_phpfpm -eq 1 ]
then
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=3
# Create a dedicated php-fpm config
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --dedicated_service
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=3
# Create a dedicated php-fpm config
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --dedicated_service
fi
#=================================================
@ -209,9 +209,9 @@ 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
cp "$pihole_local_repo/advanced/pihole.sudo" /etc/sudoers.d/pihole
else
cp "$pihole_local_repo/advanced/Templates/pihole.sudo" /etc/sudoers.d/pihole
cp "$pihole_local_repo/advanced/Templates/pihole.sudo" /etc/sudoers.d/pihole
fi
echo "$app ALL=NOPASSWD: /usr/local/bin/pihole" >> /etc/sudoers.d/pihole
chmod 0440 /etc/sudoers.d/pihole
@ -223,11 +223,11 @@ 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)
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)
cp "$pihole_local_repo/advanced/Templates/logrotate" "$pihole_storage/logrotate"
dnsmasq_user=$(grep FTLUSER= /etc/init.d/pihole-FTL | cut -d'=' -f2)
fi
sed -i "/# su #/d;" "$pihole_storage/logrotate"
@ -240,75 +240,75 @@ 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)
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
# 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"
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"
fi
# Overwrite pihole-FTL config file only if it's allowed
if [ $overwrite_ftl -eq 1 ]
then
ynh_add_config --template="../conf/pihole-FTL.conf" --destination="$pihole_storage/pihole-FTL.conf"
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
# 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
# Reload systemd config
systemctl daemon-reload
# Reload systemd config
systemctl daemon-reload
fi
#=================================================
@ -320,26 +320,26 @@ setupVars="$pihole_storage/setupVars.conf"
# Overwrite the setupVars config file only if it's allowed
if [ $overwrite_setupvars -eq 1 ]
then
# Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
ynh_backup_if_checksum_is_different --file="$setupVars"
# Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
ynh_backup_if_checksum_is_different --file="$setupVars"
# Get the default network interface
main_iface=$(ip route | grep --max-count=1 default | awk '{print $5;}')
echo "PIHOLE_INTERFACE=$main_iface" > $setupVars
echo "IPV4_ADDRESS=127.0.0.1" >> $setupVars
echo "IPV6_ADDRESS=::1" >> $setupVars
echo "PIHOLE_DNS_1=" >> $setupVars
echo "PIHOLE_DNS_2=" >> $setupVars
if [ $query_logging -eq 1 ]; then
query_logging=true
else
query_logging=false
fi
echo "QUERY_LOGGING=$query_logging" >> $setupVars
echo "INSTALL_WEB=true" >> $setupVars
# Get the default network interface
main_iface=$(ip route | grep --max-count=1 default | awk '{print $5;}')
echo "PIHOLE_INTERFACE=$main_iface" > $setupVars
echo "IPV4_ADDRESS=127.0.0.1" >> $setupVars
echo "IPV6_ADDRESS=::1" >> $setupVars
echo "PIHOLE_DNS_1=" >> $setupVars
echo "PIHOLE_DNS_2=" >> $setupVars
if [ $query_logging -eq 1 ]; then
query_logging=true
else
query_logging=false
fi
echo "QUERY_LOGGING=$query_logging" >> $setupVars
echo "INSTALL_WEB=true" >> $setupVars
# Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum --file="$setupVars"
# Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum --file="$setupVars"
fi
#=================================================
@ -355,22 +355,24 @@ echo "$pihole_core_version $dashboard_version $FTL_version" | tee $pihole_storag
if [ "$pihole_version" == "Last 3.X" ]
then
cp $pihole_local_repo/advanced/pihole.cron /etc/cron.d/pihole
cp $pihole_local_repo/advanced/pihole.cron /etc/cron.d/pihole
else
cp $pihole_local_repo/advanced/Templates/pihole.cron /etc/cron.d/pihole
cp $pihole_local_repo/advanced/Templates/pihole.cron /etc/cron.d/pihole
fi
# 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
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add pihole-FTL --description="PiHole backend service" --log="/var/log/pihole-FTL.log"
#=================================================
# UPDATE CONF_REGEN HOOK
#=================================================
ynh_script_progression --message="Updating conf_regen hook..."
cp ../conf/dnsmasq_regenconf_hook /usr/share/yunohost/hooks/conf_regen/50-dnsmasq_$app
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="/usr/share/yunohost/hooks/conf_regen/50-dnsmasq_$app"
@ -408,20 +410,20 @@ admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)
# If a html email is required. Apply html to the changelog.
if [ "$admin_mail_html" -eq 1 ]; then
format=html
format=html
else
format=plain
format=plain
fi
ynh_app_changelog --format=$format
if [ $enable_dhcp -eq 1 ]
then
dhcp_alert="You asked to use the internal DHCP server of dnsmasq with PiHole.
dhcp_alert="You asked to use the internal DHCP server of dnsmasq with PiHole.
You should really read the documentation about that, https://github.com/YunoHost-Apps/pihole_ynh/blob/master/dhcp.md
"
else
dhcp_alert=""
dhcp_alert=""
fi
echo "${dhcp_alert}You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__.