Ensure $SERVER_ADDR is free on the server.
This commit is contained in:
parent
fb98bb2c0b
commit
727aa097bf
10
vpnerator.sh
10
vpnerator.sh
@ -59,6 +59,11 @@ cleanup() {
|
|||||||
EXIST_INTERFACE=\$(ip addr show to ${SERVER_ADDR} | head -1 | awk '{ print \$2 }' | cut -d':' -f1)
|
EXIST_INTERFACE=\$(ip addr show to ${SERVER_ADDR} | head -1 | awk '{ print \$2 }' | cut -d':' -f1)
|
||||||
|
|
||||||
if [ ! -z "\${EXIST_INTERFACE}" ] ; then
|
if [ ! -z "\${EXIST_INTERFACE}" ] ; then
|
||||||
|
if [ -z "\$(ip link show "\${EXIST_INTERFACE}" type wireguard)" ] ; then
|
||||||
|
# bail if the existing interface isn't of type wireguard
|
||||||
|
return 2
|
||||||
|
fi
|
||||||
|
|
||||||
remove_interface \${EXIST_INTERFACE}
|
remove_interface \${EXIST_INTERFACE}
|
||||||
return 0
|
return 0
|
||||||
elif ip link show ${INTERFACE_NAME} type wireguard > /dev/null 2>&1 ; then
|
elif ip link show ${INTERFACE_NAME} type wireguard > /dev/null 2>&1 ; then
|
||||||
@ -81,6 +86,11 @@ deps || exit 1
|
|||||||
|
|
||||||
# Cleanup previous tunnel
|
# Cleanup previous tunnel
|
||||||
cleanup
|
cleanup
|
||||||
|
if [ "\$?" -eq 2 ] ; then
|
||||||
|
echo "$SERVER_ADDR is already being used on the server."
|
||||||
|
echo "Please choose another address."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
umask 0177
|
umask 0177
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user