From 3ed39d684b400ecc64f3d7987bb20bb2b2e40f90 Mon Sep 17 00:00:00 2001 From: Julien VAUBOURG Date: Sat, 25 Jul 2015 00:05:00 +0200 Subject: [PATCH] Fix error when there is no internet interface available (close #8) --- conf/ynh-hotspot | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/conf/ynh-hotspot b/conf/ynh-hotspot index 5d84641..300051e 100644 --- a/conf/ynh-hotspot +++ b/conf/ynh-hotspot @@ -92,7 +92,7 @@ is_running() { fi done - is_hostapd_running && is_forwarding_set && is_nat_set "${new_internet_device}" + is_hostapd_running && is_forwarding_set && ( [ -z "${new_internet_device}" ] || is_nat_set "${new_internet_device}" ) } ## Setters @@ -340,7 +340,7 @@ case "$1" in fi # Set ipv4 NAT - if ! is_nat_set "${new_internet_device}"; then + if [ ! -z "${new_internet_device}" ] && ! is_nat_set "${new_internet_device}"; then echo "Set NAT" set_nat "${new_internet_device}" fi @@ -415,7 +415,7 @@ case "$1" in echo "[hotspot] Stopping..." rm -f /tmp/.ynh-hotspot-started - if is_nat_set "${old_internet_device}"; then + if [ ! -z "${old_internet_device}" ] && is_nat_set "${old_internet_device}"; then echo "Unset NAT" unset_nat "${old_internet_device}" fi @@ -479,7 +479,11 @@ case "$1" in if is_nat_set "${new_internet_device}"; then echo "[OK] IPv4 NAT set" else - echo "[ERR] No IPv4 NAT set" + if [ -z "${new_internet_device}" ]; then + echo "[INFO] No IPv4 NAT set (no internet interface)" + else + echo "[ERR] No IPv4 NAT set" + fi exitcode=1 fi