mirror of
https://github.com/YunoHost-Apps/pihole_ynh.git
synced 2024-09-03 20:05:58 +02:00
Fix ipv6 and /etc/hosts
Thanks to rafi59 for having found out this bugs
This commit is contained in:
parent
32af3e208d
commit
50387429fe
6 changed files with 73 additions and 10 deletions
|
@ -19,8 +19,7 @@
|
||||||
"multi_instance": false,
|
"multi_instance": false,
|
||||||
"services": [
|
"services": [
|
||||||
"nginx",
|
"nginx",
|
||||||
"php5-fpm",
|
"php5-fpm"
|
||||||
"dnsmasq"
|
|
||||||
],
|
],
|
||||||
"arguments": {
|
"arguments": {
|
||||||
"install" : [
|
"install" : [
|
||||||
|
|
|
@ -90,3 +90,9 @@ ynh_backup "/var/run/pihole-FTL.pid" "${YNH_APP_BACKUP_DIR}/var/run/pihole-FTL.p
|
||||||
ynh_backup "/var/run/pihole-FTL.port" "${YNH_APP_BACKUP_DIR}/var/run/pihole-FTL.port"
|
ynh_backup "/var/run/pihole-FTL.port" "${YNH_APP_BACKUP_DIR}/var/run/pihole-FTL.port"
|
||||||
|
|
||||||
ynh_backup "/etc/dnsmasq.d/01-pihole.conf" "${YNH_APP_BACKUP_DIR}/etc/dnsmasq.d/01-pihole.conf"
|
ynh_backup "/etc/dnsmasq.d/01-pihole.conf" "${YNH_APP_BACKUP_DIR}/etc/dnsmasq.d/01-pihole.conf"
|
||||||
|
if test -e "/etc/dnsmasq.d/02-pihole-dhcp.conf"; then
|
||||||
|
ynh_backup "/etc/dnsmasq.d/02-pihole-dhcp.conf" "${YNH_APP_BACKUP_DIR}/etc/dnsmasq.d/02-pihole-dhcp.conf"
|
||||||
|
fi
|
||||||
|
if test -e "/etc/dnsmasq.d/03-pihole-wildcard.conf"; then
|
||||||
|
ynh_backup "/etc/dnsmasq.d/03-pihole-wildcard.conf" "${YNH_APP_BACKUP_DIR}/etc/dnsmasq.d/03-pihole-wildcard.conf"
|
||||||
|
fi
|
||||||
|
|
|
@ -178,7 +178,7 @@ echo "PIHOLE_INTERFACE=$main_iface" > $setupVars
|
||||||
# Trouve l'ipv4 associée à l'interface trouvée
|
# Trouve l'ipv4 associée à l'interface trouvée
|
||||||
localipv4=$(ifconfig | grep -A 1 "$main_iface" | tail -1 | awk '{print $2;}' | cut -d: -f2)
|
localipv4=$(ifconfig | grep -A 1 "$main_iface" | tail -1 | awk '{print $2;}' | cut -d: -f2)
|
||||||
echo "IPV4_ADDRESS=$localipv4" >> $setupVars
|
echo "IPV4_ADDRESS=$localipv4" >> $setupVars
|
||||||
echo "IPV6_ADDRESS=::/0" >> $setupVars
|
echo "IPV6_ADDRESS=" >> $setupVars
|
||||||
echo "PIHOLE_DNS_1=" >> $setupVars
|
echo "PIHOLE_DNS_1=" >> $setupVars
|
||||||
echo "PIHOLE_DNS_2=" >> $setupVars
|
echo "PIHOLE_DNS_2=" >> $setupVars
|
||||||
if [ $query_logging -eq 1 ]; then
|
if [ $query_logging -eq 1 ]; then
|
||||||
|
@ -216,6 +216,25 @@ ynh_store_file_checksum "$pihole_dnsmasq_config" # Enregistre la somme de contr
|
||||||
# Pour éviter un conflit entre les config de dnsmasq, il faut commenter cache-size dans la config par défaut.
|
# Pour éviter un conflit entre les config de dnsmasq, il faut commenter cache-size dans la config par défaut.
|
||||||
ynh_replace_string "^cache-size=" "#pihole# cache-size=" /etc/dnsmasq.conf
|
ynh_replace_string "^cache-size=" "#pihole# cache-size=" /etc/dnsmasq.conf
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CONFIGURE DNS FOR THE LOCAL DOMAINS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Liste les domaines de yunohost
|
||||||
|
while read perdomain
|
||||||
|
do
|
||||||
|
# Commente les résolutions du domaine sur 127.0.0.1, qui risquerait de bloquer la résolution sur le réseau local
|
||||||
|
sed -i "s/^127.0.0.1.*$perdomain/#Commented by pihole# &/g" /etc/hosts
|
||||||
|
|
||||||
|
# Et ajoute une résolution sur l'ip local à la place, si elle n'existe pas déjà
|
||||||
|
grep -q "^$localipv4.*$perdomain" /etc/hosts || \
|
||||||
|
echo "$localipv4 $perdomain #Added by pihole#" >> /etc/hosts
|
||||||
|
done <<< "$(sudo yunohost domain list | grep "\." | sed 's/.*: \|.*- //')"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTART DNSMASQ
|
||||||
|
#=================================================
|
||||||
|
|
||||||
systemctl start dnsmasq
|
systemctl start dnsmasq
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -109,10 +109,26 @@ ynh_secure_remove "/etc/sudoers.d/pihole"
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
systemctl stop dnsmasq
|
systemctl stop dnsmasq
|
||||||
ynh_secure_remove "/etc/dnsmasq.d/01-pihole.conf"
|
rm -f "/etc/dnsmasq.d/01-pihole.conf"
|
||||||
|
rm -f "/etc/dnsmasq.d/02-pihole-dhcp.conf"
|
||||||
|
rm -f "/etc/dnsmasq.d/03-pihole-wildcard.conf"
|
||||||
|
|
||||||
ynh_replace_string "#pihole# " "" /etc/dnsmasq.conf
|
ynh_replace_string "#pihole# " "" /etc/dnsmasq.conf
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CLEAN /etc/hosts
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Restaure les résolutions qui avaient été commentées par pihole
|
||||||
|
sed -i "s/#Commented by pihole# //g" /etc/hosts
|
||||||
|
|
||||||
|
# Et supprime les lignes ajoutées par pihole
|
||||||
|
sed -i "/#Added by pihole#/d" /etc/hosts
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTART DNSMASQ
|
||||||
|
#=================================================
|
||||||
|
|
||||||
systemctl start dnsmasq
|
systemctl start dnsmasq
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -136,10 +136,38 @@ ynh_restore_file "/var/run/pihole-FTL.port"
|
||||||
systemctl stop dnsmasq
|
systemctl stop dnsmasq
|
||||||
|
|
||||||
ynh_restore_file "/etc/dnsmasq.d/01-pihole.conf"
|
ynh_restore_file "/etc/dnsmasq.d/01-pihole.conf"
|
||||||
|
test -e "${YNH_APP_BACKUP_DIR}/etc/dnsmasq.d/02-pihole-dhcp.conf" && \
|
||||||
|
ynh_restore_file "/etc/dnsmasq.d/02-pihole-dhcp.conf"
|
||||||
|
test -e "${YNH_APP_BACKUP_DIR}/etc/dnsmasq.d/03-pihole-wildcard.conf" && \
|
||||||
|
ynh_restore_file "/etc/dnsmasq.d/03-pihole-wildcard.conf"
|
||||||
|
|
||||||
# Pour éviter un conflit entre les config de dnsmasq, il faut commenter cache-size dans la config par défaut.
|
# Pour éviter un conflit entre les config de dnsmasq, il faut commenter cache-size dans la config par défaut.
|
||||||
ynh_replace_string "^cache-size=" "#pihole# cache-size=" /etc/dnsmasq.conf
|
ynh_replace_string "^cache-size=" "#pihole# cache-size=" /etc/dnsmasq.conf
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CONFIGURE DNS FOR THE LOCAL DOMAINS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Trouve l'interface réseau par défaut
|
||||||
|
main_iface=$(route | grep default | awk '{print $8;}' | head -n1)
|
||||||
|
# Trouve l'ipv4 associée à l'interface trouvée
|
||||||
|
localipv4=$(ifconfig | grep -A 1 "$main_iface" | tail -1 | awk '{print $2;}' | cut -d: -f2)
|
||||||
|
|
||||||
|
# Liste les domaines de yunohost
|
||||||
|
while read perdomain
|
||||||
|
do
|
||||||
|
# Commente les résolutions du domaine sur 127.0.0.1, qui risquerait de bloquer la résolution sur le réseau local
|
||||||
|
sed -i "s/^127.0.0.1.*$perdomain/#Commented by pihole# &/g" /etc/hosts
|
||||||
|
|
||||||
|
# Et ajoute une résolution sur l'ip local à la place, si elle n'existe pas déjà
|
||||||
|
grep -q "^$localipv4.*$perdomain" /etc/hosts || \
|
||||||
|
echo "$localipv4 $perdomain #Added by pihole#" >> /etc/hosts
|
||||||
|
done <<< "$(sudo yunohost domain list | grep "\." | sed 's/.*: \|.*- //')"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTART DNSMASQ
|
||||||
|
#=================================================
|
||||||
|
|
||||||
systemctl start dnsmasq
|
systemctl start dnsmasq
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -148,13 +176,8 @@ systemctl start dnsmasq
|
||||||
|
|
||||||
setupVars="/etc/pihole/setupVars.conf"
|
setupVars="/etc/pihole/setupVars.conf"
|
||||||
|
|
||||||
# Trouve l'interface réseau par défaut
|
|
||||||
main_iface=$(route | grep default | awk '{print $8;}' | head -n1)
|
|
||||||
echo "PIHOLE_INTERFACE=$main_iface" > $setupVars
|
echo "PIHOLE_INTERFACE=$main_iface" > $setupVars
|
||||||
ynh_replace_string "^PIHOLE_INTERFACE=.*" "PIHOLE_INTERFACE=$main_iface" $setupVars
|
ynh_replace_string "^PIHOLE_INTERFACE=.*" "PIHOLE_INTERFACE=$main_iface" $setupVars
|
||||||
|
|
||||||
# Trouve l'ipv4 associée à l'interface trouvée
|
|
||||||
localipv4=$(ifconfig | grep -A 1 "$main_iface" | tail -1 | awk '{print $2;}' | cut -d: -f2)
|
|
||||||
ynh_replace_string "^IPV4_ADDRESS=.*" "IPV4_ADDRESS=$localipv4" $setupVars
|
ynh_replace_string "^IPV4_ADDRESS=.*" "IPV4_ADDRESS=$localipv4" $setupVars
|
||||||
|
|
||||||
ynh_store_file_checksum "$setupVars" # Enregistre la somme de contrôle du fichier de config
|
ynh_store_file_checksum "$setupVars" # Enregistre la somme de contrôle du fichier de config
|
||||||
|
|
|
@ -133,7 +133,7 @@ echo "PIHOLE_INTERFACE=$main_iface" > $setupVars
|
||||||
# Trouve l'ipv4 associée à l'interface trouvée
|
# Trouve l'ipv4 associée à l'interface trouvée
|
||||||
localipv4=$(ifconfig | grep -A 1 "$main_iface" | tail -1 | awk '{print $2;}' | cut -d: -f2)
|
localipv4=$(ifconfig | grep -A 1 "$main_iface" | tail -1 | awk '{print $2;}' | cut -d: -f2)
|
||||||
echo "IPV4_ADDRESS=$localipv4" >> $setupVars
|
echo "IPV4_ADDRESS=$localipv4" >> $setupVars
|
||||||
echo "IPV6_ADDRESS=::/0" >> $setupVars
|
echo "IPV6_ADDRESS=" >> $setupVars
|
||||||
echo "PIHOLE_DNS_1=" >> $setupVars
|
echo "PIHOLE_DNS_1=" >> $setupVars
|
||||||
echo "PIHOLE_DNS_2=" >> $setupVars
|
echo "PIHOLE_DNS_2=" >> $setupVars
|
||||||
if [ $query_logging -eq 1 ]; then
|
if [ $query_logging -eq 1 ]; then
|
||||||
|
|
Loading…
Add table
Reference in a new issue