1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/adguardhome_ynh.git synced 2024-09-03 18:06:23 +02:00

refactor commands to get IPs

This commit is contained in:
OniriCorpe 2023-12-27 19:40:24 +01:00
parent d4a231c203
commit 9e24b61637
4 changed files with 8 additions and 17 deletions

View file

@ -34,12 +34,10 @@ set__open_port_53() {
# regenerate config, needed to add or delete public IPs following the user's choice # regenerate config, needed to add or delete public IPs following the user's choice
# get IPv4 for the AGH config file # get IPv4 for the AGH config file
ipv4_route_output=$(echo "$(ip -4 route get 1.2.3.4 2> /dev/null)" | head -n1 | head -n1) ipv4_addr=$(process_ips "$(ip -4 route get 1.2.3.4 2> /dev/null | head -n1 | head -n1)")
ipv4_addr=$(process_ips "$ipv4_route_output")
# get IPv6 for the AGH config file # get IPv6 for the AGH config file
ipv6_route_output=$(echo "$(ip -6 route get ::1.2.3.4 2> /dev/null)" | head -n1) ipv6_addr=$(process_ips "$(ip -6 route get ::1.2.3.4 2> /dev/null | head -n1)")
ipv6_addr=$(process_ips "$ipv6_route_output")
# update the IP adresses in the AGH config file # update the IP adresses in the AGH config file
update_config update_config

View file

@ -39,7 +39,6 @@ fi
ynh_app_setting_set --app="$app" --key=open_port_53 --value="$open_port_53" ynh_app_setting_set --app="$app" --key=open_port_53 --value="$open_port_53"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
@ -97,12 +96,10 @@ systemctl restart dnsmasq
ynh_store_file_checksum --file="/etc/dnsmasq.d/$app" ynh_store_file_checksum --file="/etc/dnsmasq.d/$app"
# get IPv4 for the AGH config file # get IPv4 for the AGH config file
ipv4_route_output=$(echo "$(ip -4 route get 1.2.3.4 2> /dev/null)" | head -n1 | head -n1) ipv4_addr=$(process_ips "$(ip -4 route get 1.2.3.4 2> /dev/null | head -n1 | head -n1)")
ipv4_addr=$(process_ips "$ipv4_route_output")
# get IPv6 for the AGH config file # get IPv6 for the AGH config file
ipv6_route_output=$(echo "$(ip -6 route get ::1.2.3.4 2> /dev/null)" | head -n1) ipv6_addr=$(process_ips "$(ip -6 route get ::1.2.3.4 2> /dev/null | head -n1)")
ipv6_addr=$(process_ips "$ipv6_route_output")
password=$(python3 -c "import bcrypt; print(bcrypt.hashpw(b\"$password\", bcrypt.gensalt(rounds=10)).decode())") password=$(python3 -c "import bcrypt; print(bcrypt.hashpw(b\"$password\", bcrypt.gensalt(rounds=10)).decode())")
ynh_app_setting_set --app="$app" --key=password --value="$password" ynh_app_setting_set --app="$app" --key=password --value="$password"

View file

@ -45,12 +45,10 @@ ynh_restore_file --origin_path="$install_dir"
# environment, else AGH will try to bind port 53 on non-existent IPs and crash # environment, else AGH will try to bind port 53 on non-existent IPs and crash
# get IPv4 for the AGH config file # get IPv4 for the AGH config file
ipv4_route_output=$(echo "$(ip -4 route get 1.2.3.4 2> /dev/null)" | head -n1 | head -n1) ipv4_addr=$(process_ips "$(ip -4 route get 1.2.3.4 2> /dev/null | head -n1 | head -n1)")
ipv4_addr=$(process_ips "$ipv4_route_output")
# get IPv6 for the AGH config file # get IPv6 for the AGH config file
ipv6_route_output=$(echo "$(ip -6 route get ::1.2.3.4 2> /dev/null)" | head -n1) ipv6_addr=$(process_ips "$(ip -6 route get ::1.2.3.4 2> /dev/null | head -n1)")
ipv6_addr=$(process_ips "$ipv6_route_output")
# update the IP adresses in the AGH config file # update the IP adresses in the AGH config file
update_config update_config

View file

@ -148,12 +148,10 @@ systemctl restart dnsmasq
ynh_store_file_checksum --file="/etc/dnsmasq.d/$app" ynh_store_file_checksum --file="/etc/dnsmasq.d/$app"
# get IPv4 for the AGH config file # get IPv4 for the AGH config file
ipv4_route_output=$(echo "$(ip -4 route get 1.2.3.4 2> /dev/null)" | head -n1 | head -n1) ipv4_addr=$(process_ips "$(ip -4 route get 1.2.3.4 2> /dev/null | head -n1 | head -n1)")
ipv4_addr=$(process_ips "$ipv4_route_output")
# get IPv6 for the AGH config file # get IPv6 for the AGH config file
ipv6_route_output=$(echo "$(ip -6 route get ::1.2.3.4 2> /dev/null)" | head -n1) ipv6_addr=$(process_ips "$(ip -6 route get ::1.2.3.4 2> /dev/null | head -n1)")
ipv6_addr=$(process_ips "$ipv6_route_output")
# update the IP adresses in the AGH config file # update the IP adresses in the AGH config file
update_config update_config