1
0
mirror of synced 2024-11-28 23:56:04 +03:00

Minor clean up

This commit is contained in:
hwdsl2 2017-04-12 10:30:26 -05:00
parent f58afbc84b
commit cebf9f4361
2 changed files with 8 additions and 12 deletions

View File

@ -71,17 +71,15 @@ NET_IF0=${VPN_IFACE:-'eth0'}
NET_IFS=${VPN_IFACE:-'eth+'}
if_state=$(cat "/sys/class/net/$NET_IF0/operstate" 2>/dev/null)
if [ -z "$if_state" ] || [ "$if_state" = "down" ] || [ "$NET_IF0" = "lo" ]; then
echo "Error: Network interface '$NET_IF0' is not available." >&2
printf "Error: Network interface '%s' is not available.\n" "$NET_IF0" >&2
printf '\n%s\n' "DO NOT RUN THIS SCRIPT ON YOUR PC OR MAC!" >&2
printf '\n%s\n\n' "If running on a server, try this workaround:" >&2
cat 1>&2 <<'EOF'
DO NOT RUN THIS SCRIPT ON YOUR PC OR MAC!
If running on a server, try this workaround:
VPN_IFACE="$(route | grep '^default' | grep -o '[^ ]*$')"
EOF
cat 1>&2 <<EOF
sudo VPN_IFACE="\$VPN_IFACE" sh "$0"
EOF
exit 1
fi

View File

@ -64,17 +64,15 @@ NET_IF0=${VPN_IFACE:-'eth0'}
NET_IFS=${VPN_IFACE:-'eth+'}
if_state=$(cat "/sys/class/net/$NET_IF0/operstate" 2>/dev/null)
if [ -z "$if_state" ] || [ "$if_state" = "down" ] || [ "$NET_IF0" = "lo" ]; then
echo "Error: Network interface '$NET_IF0' is not available." >&2
printf "Error: Network interface '%s' is not available.\n" "$NET_IF0" >&2
printf '\n%s\n' "DO NOT RUN THIS SCRIPT ON YOUR PC OR MAC!" >&2
printf '\n%s\n\n' "If running on a server, try this workaround:" >&2
cat 1>&2 <<'EOF'
DO NOT RUN THIS SCRIPT ON YOUR PC OR MAC!
If running on a server, try this workaround:
VPN_IFACE="$(route | grep '^default' | grep -o '[^ ]*$')"
EOF
cat 1>&2 <<EOF
sudo VPN_IFACE="\$VPN_IFACE" sh "$0"
EOF
exit 1
fi