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

Fix when the server doesn't have an ipv4/6

This commit is contained in:
Kay0u 2022-01-12 11:03:31 +01:00
parent 3836687675
commit ab93de8dbc
No known key found for this signature in database
GPG key ID: AAFEEB16CFA2AE2D
2 changed files with 4 additions and 4 deletions

View file

@ -125,8 +125,8 @@ ynh_add_nginx_config
ynh_script_progression --message="Modifying a config file..." --weight=1
# echo the ip route command to prevent a crash if the server doesn't have any ipv4/6
ipv4_interface=$(echo "$(ip -4 route get 1.2.3.4 2> /dev/null)" | head -n1 | grep -oP '(?<=dev )\w+')
ipv6_interface=$(echo "$(ip -6 route get ::1.2.3.4 2> /dev/null)" | head -n1 | grep -oP '(?<=dev )\w+')
ipv4_interface=$(echo "$(ip -4 route get 1.2.3.4 2> /dev/null)" | head -n1 | grep -oP '(?<=dev )\w+' || true)
ipv6_interface=$(echo "$(ip -6 route get ::1.2.3.4 2> /dev/null)" | head -n1 | grep -oP '(?<=dev )\w+' || true)
if [ -z "$ipv4_interface" ] && [ -z "$ipv6_interface" ]; then
ynh_die --message="Impossible to find the main network interface, please report this issue."

View file

@ -137,8 +137,8 @@ ynh_install_app_dependencies $pkg_dependencies
#=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=1
ipv4_interface=$(echo "$(ip -4 route get 1.2.3.4 2> /dev/null)" | head -n1 | grep -oP '(?<=dev )\w+')
ipv6_interface=$(echo "$(ip -6 route get ::1.2.3.4 2> /dev/null)" | head -n1 | grep -oP '(?<=dev )\w+')
ipv4_interface=$(echo "$(ip -4 route get 1.2.3.4 2> /dev/null)" | head -n1 | grep -oP '(?<=dev )\w+' || true)
ipv6_interface=$(echo "$(ip -6 route get ::1.2.3.4 2> /dev/null)" | head -n1 | grep -oP '(?<=dev )\w+' || true)
if [ -z "$ipv4_interface" ] && [ -z "$ipv6_interface" ]; then
ynh_die --message="Impossible to find the main network interface, please report this issue."