diff --git a/vpnsetup.sh b/vpnsetup.sh index d5da22d..76f9cf2 100755 --- a/vpnsetup.sh +++ b/vpnsetup.sh @@ -53,7 +53,8 @@ if [ "$(id -u)" != 0 ]; then exit 1 fi -if [ ! -f /sys/class/net/eth0/operstate ]; then +eth0_state=$(cat /sys/class/net/eth0/operstate 2>/dev/null) +if [ -z "$eth0_state" ] || [ "$eth0_state" = "down" ]; then cat 1>&2 <<'EOF' Network interface 'eth0' is not available. Aborting. diff --git a/vpnsetup_centos.sh b/vpnsetup_centos.sh index 626ae03..3704164 100755 --- a/vpnsetup_centos.sh +++ b/vpnsetup_centos.sh @@ -57,7 +57,8 @@ if [ "$(id -u)" != 0 ]; then exit 1 fi -if [ ! -f /sys/class/net/eth0/operstate ]; then +eth0_state=$(cat /sys/class/net/eth0/operstate 2>/dev/null) +if [ -z "$eth0_state" ] || [ "$eth0_state" = "down" ]; then cat 1>&2 <<'EOF' Network interface 'eth0' is not available. Aborting.