1
0
mirror of synced 2024-11-25 14:26:09 +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+'} NET_IFS=${VPN_IFACE:-'eth+'}
if_state=$(cat "/sys/class/net/$NET_IF0/operstate" 2>/dev/null) if_state=$(cat "/sys/class/net/$NET_IF0/operstate" 2>/dev/null)
if [ -z "$if_state" ] || [ "$if_state" = "down" ] || [ "$NET_IF0" = "lo" ]; then 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' 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 '[^ ]*$')" VPN_IFACE="$(route | grep '^default' | grep -o '[^ ]*$')"
EOF EOF
cat 1>&2 <<EOF cat 1>&2 <<EOF
sudo VPN_IFACE="\$VPN_IFACE" sh "$0" sudo VPN_IFACE="\$VPN_IFACE" sh "$0"
EOF EOF
exit 1 exit 1
fi fi

View File

@ -64,17 +64,15 @@ NET_IF0=${VPN_IFACE:-'eth0'}
NET_IFS=${VPN_IFACE:-'eth+'} NET_IFS=${VPN_IFACE:-'eth+'}
if_state=$(cat "/sys/class/net/$NET_IF0/operstate" 2>/dev/null) if_state=$(cat "/sys/class/net/$NET_IF0/operstate" 2>/dev/null)
if [ -z "$if_state" ] || [ "$if_state" = "down" ] || [ "$NET_IF0" = "lo" ]; then 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' 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 '[^ ]*$')" VPN_IFACE="$(route | grep '^default' | grep -o '[^ ]*$')"
EOF EOF
cat 1>&2 <<EOF cat 1>&2 <<EOF
sudo VPN_IFACE="\$VPN_IFACE" sh "$0" sudo VPN_IFACE="\$VPN_IFACE" sh "$0"
EOF EOF
exit 1 exit 1
fi fi