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:
parent
d4a231c203
commit
9e24b61637
4 changed files with 8 additions and 17 deletions
|
@ -34,12 +34,10 @@ set__open_port_53() {
|
|||
|
||||
# regenerate config, needed to add or delete public IPs following the user's choice
|
||||
# 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 "$ipv4_route_output")
|
||||
ipv4_addr=$(process_ips "$(ip -4 route get 1.2.3.4 2> /dev/null | head -n1 | head -n1)")
|
||||
|
||||
# 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 "$ipv6_route_output")
|
||||
ipv6_addr=$(process_ips "$(ip -6 route get ::1.2.3.4 2> /dev/null | head -n1)")
|
||||
|
||||
# update the IP adresses in the AGH config file
|
||||
update_config
|
||||
|
|
|
@ -39,7 +39,6 @@ fi
|
|||
|
||||
ynh_app_setting_set --app="$app" --key=open_port_53 --value="$open_port_53"
|
||||
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
@ -97,12 +96,10 @@ systemctl restart dnsmasq
|
|||
ynh_store_file_checksum --file="/etc/dnsmasq.d/$app"
|
||||
|
||||
# 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 "$ipv4_route_output")
|
||||
ipv4_addr=$(process_ips "$(ip -4 route get 1.2.3.4 2> /dev/null | head -n1 | head -n1)")
|
||||
|
||||
# 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 "$ipv6_route_output")
|
||||
ipv6_addr=$(process_ips "$(ip -6 route get ::1.2.3.4 2> /dev/null | head -n1)")
|
||||
|
||||
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"
|
||||
|
|
|
@ -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
|
||||
|
||||
# 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 "$ipv4_route_output")
|
||||
ipv4_addr=$(process_ips "$(ip -4 route get 1.2.3.4 2> /dev/null | head -n1 | head -n1)")
|
||||
|
||||
# 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 "$ipv6_route_output")
|
||||
ipv6_addr=$(process_ips "$(ip -6 route get ::1.2.3.4 2> /dev/null | head -n1)")
|
||||
|
||||
# update the IP adresses in the AGH config file
|
||||
update_config
|
||||
|
|
|
@ -148,12 +148,10 @@ systemctl restart dnsmasq
|
|||
ynh_store_file_checksum --file="/etc/dnsmasq.d/$app"
|
||||
|
||||
# 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 "$ipv4_route_output")
|
||||
ipv4_addr=$(process_ips "$(ip -4 route get 1.2.3.4 2> /dev/null | head -n1 | head -n1)")
|
||||
|
||||
# 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 "$ipv6_route_output")
|
||||
ipv6_addr=$(process_ips "$(ip -6 route get ::1.2.3.4 2> /dev/null | head -n1)")
|
||||
|
||||
# update the IP adresses in the AGH config file
|
||||
update_config
|
||||
|
|
Loading…
Add table
Reference in a new issue