mirror of
https://github.com/YunoHost-Apps/adguardhome_ynh.git
synced 2024-09-03 18:06:23 +02:00
commit
c57900238f
15 changed files with 187 additions and 14 deletions
|
@ -20,7 +20,7 @@ AdGuard Home is a network-wide software for blocking ads & tracking. After you s
|
|||
It operates as a DNS server that re-routes tracking domains to a "black hole", thus preventing your devices from connecting to those servers. It's based on software we use for our public AdGuard DNS servers -- both share a lot of common code.
|
||||
|
||||
|
||||
**Shipped version:** 0.107.0~ynh1
|
||||
**Shipped version:** 0.107.2~ynh1
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ AdGuard Home est un logiciel à l'échelle du réseau pour bloquer les publicit
|
|||
Il fonctionne comme un serveur DNS qui redirige les domaines de pistage vers un "trou noir", empêchant ainsi vos appareils de se connecter à ces serveurs. Il est basé sur un logiciel que nous utilisons pour nos serveurs DNS publics AdGuard - les deux partagent beaucoup de code commun.
|
||||
|
||||
|
||||
**Version incluse :** 0.107.0~ynh1
|
||||
**Version incluse :** 0.107.2~ynh1
|
||||
|
||||
|
||||
|
||||
|
|
8
actions.toml
Normal file
8
actions.toml
Normal file
|
@ -0,0 +1,8 @@
|
|||
[reset_default_config]
|
||||
name = "Reset the AdguardHome config"
|
||||
command = "/bin/bash scripts/actions/reset_default_config"
|
||||
# user = "root" # optional
|
||||
# cwd = "/" # optional
|
||||
# accepted_return_codes = [0, 1, 2, 3] # optional
|
||||
accepted_return_codes = [0]
|
||||
description = "Reset the AdguardHome config for this app."
|
0
check_process
Executable file → Normal file
0
check_process
Executable file → Normal file
|
@ -13,7 +13,8 @@ debug_pprof: false
|
|||
web_session_ttl: 720
|
||||
dns:
|
||||
bind_hosts:
|
||||
- 0.0.0.0
|
||||
__IPV4_ADDR__
|
||||
__IPV6_ADDR__
|
||||
port: __ADGUARD_PORT__
|
||||
statistics_interval: 1
|
||||
querylog_enabled: true
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
SOURCE_URL=https://github.com/AdguardTeam/AdGuardHome/releases/download/v0.107.0/AdGuardHome_linux_amd64.tar.gz
|
||||
SOURCE_SUM=8360c8797c1aa934dfb21632c833476ce539ed851bbb15c32891c5a8a16bab3c
|
||||
SOURCE_URL=https://github.com/AdguardTeam/AdGuardHome/releases/download/v0.107.2/AdGuardHome_linux_amd64.tar.gz
|
||||
SOURCE_SUM=396f610231143e88929c2e3500582e4913ff1d5e45f99564dbe1bce5db598752
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=tar.gz
|
||||
SOURCE_IN_SUBDIR=2
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
SOURCE_URL=https://github.com/AdguardTeam/AdGuardHome/releases/download/v0.107.0/AdGuardHome_linux_arm64.tar.gz
|
||||
SOURCE_SUM=3e8bddb8645c7d251b86a5f57314603249cdf265897a48e3a41d1bd53135fff8
|
||||
SOURCE_URL=https://github.com/AdguardTeam/AdGuardHome/releases/download/v0.107.2/AdGuardHome_linux_arm64.tar.gz
|
||||
SOURCE_SUM=633591149e4f93e8850d2beaae8c12a848f4059f2581ce2757afa4c4f0ac6fa3
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=tar.gz
|
||||
SOURCE_IN_SUBDIR=2
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
SOURCE_URL=https://github.com/AdguardTeam/AdGuardHome/releases/download/v0.107.0/AdGuardHome_linux_armv7.tar.gz
|
||||
SOURCE_SUM=bf1662c2f6b83f9280f8624df107f4f82d887b40f48e448f227428e0b386f455
|
||||
SOURCE_URL=https://github.com/AdguardTeam/AdGuardHome/releases/download/v0.107.2/AdGuardHome_linux_armv7.tar.gz
|
||||
SOURCE_SUM=ef02ea830465203c68fb20d3cb16b6889246e8a90f492e5f4455990c489efa4b
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=tar.gz
|
||||
SOURCE_IN_SUBDIR=2
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"en": "Network-wide ads & trackers blocking DNS server",
|
||||
"fr": "Serveur DNS, bloqueur de publicités et trackers"
|
||||
},
|
||||
"version": "0.107.0~ynh1",
|
||||
"version": "0.107.2~ynh1",
|
||||
"url": "https://adguard.com/adguard-home.html",
|
||||
"upstream": {
|
||||
"license": "GPL-3.0",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#=================================================
|
||||
|
||||
# dependencies used by the app
|
||||
pkg_dependencies="python3-bcrypt"
|
||||
pkg_dependencies="python3-bcrypt python3-yaml"
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
|
|
64
scripts/actions/reset_default_config
Normal file
64
scripts/actions/reset_default_config
Normal file
|
@ -0,0 +1,64 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
||||
password=$(ynh_app_setting_get --app=$app --key=password)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
adguard_port=$(ynh_app_setting_get --app=$app --key=adguard_port)
|
||||
|
||||
ipv4_route_output=$(ip -4 route get 1.2.3.4 | head -n1)
|
||||
ipv6_route_output=$(ip -6 route get ::1.2.3.4 | head -n1)
|
||||
|
||||
ipv4_addr=""
|
||||
for i in $(seq "$(echo $ipv4_route_output | wc -w)" -1 1); do
|
||||
ip=$(echo $ipv4_route_output | awk "{print \$$i}")
|
||||
if ynh_validate_ip4 --ip_address=$ip; then
|
||||
ipv4_addr="- $ip"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
ipv6_addr=""
|
||||
for i in $(seq "$(echo $ipv6_route_output | wc -w)" -1 1); do
|
||||
ip=$(echo $ipv6_route_output | awk "{print \$$i}")
|
||||
if ynh_validate_ip6 --ip_address=$ip; then
|
||||
ipv6_addr="- $ip"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
#=================================================
|
||||
# RESET THE CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
||||
|
||||
ynh_add_config --template="../conf/AdGuardHome.yaml" --destination="$final_path/AdGuardHome.yaml"
|
||||
|
||||
#=================================================
|
||||
# RESTART SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restarting a systemd service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="restart"
|
|
@ -41,6 +41,7 @@ ynh_print_info --message="Declaring files to be backed up..."
|
|||
#=================================================
|
||||
|
||||
ynh_backup --src_path="$final_path"
|
||||
ynh_backup --src_path="/etc/dnsmasq.d/$app"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
|
|
|
@ -60,7 +60,7 @@ port=$(ynh_find_port --port=3000)
|
|||
ynh_app_setting_set --app=$app --key=port --value=$port
|
||||
|
||||
# Find an available port
|
||||
adguard_port=$(ynh_find_port --port=53)
|
||||
adguard_port=53
|
||||
ynh_app_setting_set --app=$app --key=adguard_port --value=$adguard_port
|
||||
|
||||
# Disable the port 53 for upnp
|
||||
|
@ -116,6 +116,42 @@ ynh_add_nginx_config
|
|||
#=================================================
|
||||
ynh_script_progression --message="Modifying a config file..." --weight=1
|
||||
|
||||
ipv4_interface=$(ip route get 1.2.3.4 | grep -oP '(?<=dev )\w+')
|
||||
ipv6_interface=$(ip -6 route get ::1.2.3.4 | grep -oP '(?<=dev )\w+')
|
||||
|
||||
if [ "$ipv4_interface" != "$ipv6_interface" ]; then
|
||||
echo "bind-interfaces
|
||||
except-interface=$ipv4_interface, $ipv6_interface" > "/etc/dnsmasq.d/$app"
|
||||
else
|
||||
echo "bind-interfaces
|
||||
except-interface=$ipv4_interface" > "/etc/dnsmasq.d/$app"
|
||||
fi
|
||||
|
||||
systemctl restart dnsmasq
|
||||
|
||||
ynh_store_file_checksum --file="/etc/dnsmasq.d/$app"
|
||||
|
||||
ipv4_route_output=$(ip -4 route get 1.2.3.4 | head -n1)
|
||||
ipv6_route_output=$(ip -6 route get ::1.2.3.4 | head -n1)
|
||||
|
||||
ipv4_addr=""
|
||||
for i in $(seq "$(echo $ipv4_route_output | wc -w)" -1 1); do
|
||||
ip=$(echo $ipv4_route_output | awk "{print \$$i}")
|
||||
if ynh_validate_ip4 --ip_address=$ip; then
|
||||
ipv4_addr="- $ip"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
ipv6_addr=""
|
||||
for i in $(seq "$(echo $ipv6_route_output | wc -w)" -1 1); do
|
||||
ip=$(echo $ipv6_route_output | awk "{print \$$i}")
|
||||
if ynh_validate_ip6 --ip_address=$ip; then
|
||||
ipv6_addr="- $ip"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Main config File
|
||||
ynh_add_config --template="../conf/AdGuardHome.yaml" --destination="$final_path/AdGuardHome.yaml"
|
||||
|
||||
|
|
|
@ -66,6 +66,10 @@ chown -R $app: "$final_path"
|
|||
|
||||
setcap 'CAP_NET_BIND_SERVICE=+eip CAP_NET_RAW=+eip' $final_path/AdGuardHome
|
||||
|
||||
ynh_restore_file --origin_path="/etc/dnsmasq.d/$app"
|
||||
|
||||
systemctl restart dnsmasq
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
#=================================================
|
||||
|
|
|
@ -31,6 +31,12 @@ architecture=$YNH_ARCH
|
|||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
# The dns port should be 53
|
||||
if [ "$adguard_port" -ne "53" ]; then
|
||||
adguard_port=53
|
||||
ynh_app_setting_set --app=$app --key=adguard_port --value=$adguard_port
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
|
@ -115,8 +121,61 @@ ynh_install_app_dependencies $pkg_dependencies
|
|||
#=================================================
|
||||
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
||||
|
||||
# Main config File
|
||||
ynh_add_config --template="../conf/AdGuardHome.yaml" --destination="$final_path/AdGuardHome.yaml"
|
||||
ipv4_interface=$(ip route get 1.2.3.4 | grep -oP '(?<=dev )\w+')
|
||||
ipv6_interface=$(ip -6 route get ::1.2.3.4 | grep -oP '(?<=dev )\w+')
|
||||
|
||||
if [ "$ipv4_interface" != "$ipv6_interface" ]; then
|
||||
echo "bind-interfaces
|
||||
except-interface=$ipv4_interface, $ipv6_interface" > "/etc/dnsmasq.d/$app"
|
||||
else
|
||||
echo "bind-interfaces
|
||||
except-interface=$ipv4_interface" > "/etc/dnsmasq.d/$app"
|
||||
fi
|
||||
|
||||
systemctl restart dnsmasq
|
||||
|
||||
ynh_store_file_checksum --file="/etc/dnsmasq.d/$app"
|
||||
|
||||
ipv4_route_output=$(ip -4 route get 1.2.3.4 | head -n1)
|
||||
ipv6_route_output=$(ip -6 route get ::1.2.3.4 | head -n1)
|
||||
|
||||
ipv4_addr=""
|
||||
for i in $(seq "$(echo $ipv4_route_output | wc -w)" -1 1); do
|
||||
ip=$(echo $ipv4_route_output | awk "{print \$$i}")
|
||||
if ynh_validate_ip4 --ip_address=$ip; then
|
||||
ipv4_addr="$ip"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
ipv6_addr=""
|
||||
for i in $(seq "$(echo $ipv6_route_output | wc -w)" -1 1); do
|
||||
ip=$(echo $ipv6_route_output | awk "{print \$$i}")
|
||||
if ynh_validate_ip6 --ip_address=$ip; then
|
||||
ipv6_addr="$ip"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Reset the bind_hosts if the current ip is 0.0.0.0
|
||||
python3 -c "import yaml
|
||||
with open(\"$final_path/AdGuardHome.yaml\", 'r') as file:
|
||||
conf_file = yaml.safe_load(file)
|
||||
|
||||
need_file_update = False
|
||||
|
||||
if \"0.0.0.0\" in conf_file[\"dns\"][\"bind_hosts\"]:
|
||||
conf_file[\"dns\"][\"bind_hosts\"] = [\"$ipv4_addr\", \"$ipv6_addr\"]
|
||||
need_file_update = True
|
||||
|
||||
if conf_file[\"dns\"][\"port\"] != $adguard_port:
|
||||
conf_file[\"dns\"][\"port\"] = $adguard_port
|
||||
need_file_update = True
|
||||
|
||||
if need_file_update:
|
||||
with open(\"$final_path/AdGuardHome.yaml\", 'w') as file:
|
||||
yaml.dump(conf_file, file)
|
||||
"
|
||||
|
||||
chmod 600 "$final_path/AdGuardHome.yaml"
|
||||
chown -R $app: "$final_path/AdGuardHome.yaml"
|
||||
|
|
Loading…
Reference in a new issue