CONN_DEVICE_NAME is configurable by env var
This commit is contained in:
+5
-5
@@ -14,15 +14,15 @@ fi
|
||||
|
||||
set -eu
|
||||
CONN_NAME=${CONN_NAME:-nevis}
|
||||
conn_device_name="$(nmcli --fields NAME,DEVICE con show | grep ^$CONN_NAME | sed 's/\s\+/ /g' | cut -d' ' -f 2)"
|
||||
if [ -z "${conn_device_name:-}" ]; then
|
||||
CONN_DEVICE_NAME="${CONN_DEVICE_NAME:-$(nmcli --fields NAME,DEVICE con show | grep ^$CONN_NAME | sed 's/\s\+/ /g' | cut -d' ' -f 2)}"
|
||||
if [ -z "${CONN_DEVICE_NAME:-}" ]; then
|
||||
echo "Could not find the connection device name for connection: \"$CONN_NAME\"" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
device_line_no="$(ip addr | grep -En ^[0-9]+:\ $conn_device_name | cut -d':' -f 1)"
|
||||
device_line_no="$(ip addr | grep -En ^[0-9]+:\ $CONN_DEVICE_NAME | cut -d':' -f 1)"
|
||||
if [ -z "${device_line_no:-}" ]; then
|
||||
echo "Could not find device: \"$conn_device_name\" in output of ip addr" >&2
|
||||
echo "Could not find device: \"$CONN_DEVICE_NAME\" in output of ip addr" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -45,7 +45,7 @@ else
|
||||
fi
|
||||
ip="$(echo "$ip_addr_output_for_device" | grep "scope global" | grep -oE $ip_regex | head -n 1)"
|
||||
if [ -z "${ip:-}" ]; then
|
||||
echo "Could not find global IP in output of ip addr under device: $conn_device_name ($CONN_NAME)"
|
||||
echo "Could not find global IP in output of ip addr under device: $CONN_DEVICE_NAME ($CONN_NAME)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user