Skip to content

Commit

Permalink
Allow active network interface to be overriden
Browse files Browse the repository at this point in the history
  • Loading branch information
abhay-krishna committed Sep 13, 2023
1 parent 0499672 commit 872ca90
Showing 1 changed file with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,24 @@ env_and_envsubst '$EKSD_NAME' \
if [ "$IMAGE_FORMAT" = "ova" ] && \
( [ "$IMAGE_OS" = "redhat" ] || ( [ "$IMAGE_OS" = "ubuntu" ] && [ "$IMAGE_OS_VERSION" != "2004" ] ) ); then
echo "Finding correct interface for packer temporary http server"
ACTIVE_INTERFACE=""
if [ "$(uname -s)" = "Linux" ]; then
INTERFACES=($(ls /sys/class/net))
for interface in "${INTERFACES[@]}"; do
if [ "$interface" = "eth0" ] || [ "$interface" = "en0" ] || [ "$interface" = "eno1" ]; then
ACTIVE_INTERFACE=$interface
echo "Found interface: $interface"
break
fi
done
ACTIVE_INTERFACE="${EKSA_PACKER_ACTIVE_INTERFACE:-}"
if [ -z $ACTIVE_INTERFACE ]; then
if [ "$(uname -s)" = "Linux" ]; then
INTERFACES=($(ls /sys/class/net))
for interface in "${INTERFACES[@]}"; do
if [ "$interface" = "eth0" ] || [ "$interface" = "en0" ] || [ "$interface" = "eno1" ]; then
ACTIVE_INTERFACE=$interface
echo "Found interface: $interface"
break
fi
done
HTTP_SERVER_IP=$(ip a l $ACTIVE_INTERFACE | awk '/inet / {print $2}' | cut -d/ -f1)
elif [ "$(uname -s)" = "Darwin" ]; then
ACTIVE_INTERFACE="en0"
HTTP_SERVER_IP=$(ifconfig $ACTIVE_INTERFACE | awk '/inet / {print $2}' | cut -d/ -f1)
fi
else
HTTP_SERVER_IP=$(ip a l $ACTIVE_INTERFACE | awk '/inet / {print $2}' | cut -d/ -f1)
elif [ "$(uname -s)" = "Darwin" ]; then
ACTIVE_INTERFACE="en0"
HTTP_SERVER_IP=$(ifconfig $ACTIVE_INTERFACE | awk '/inet / {print $2}' | cut -d/ -f1)
fi

if [ -z $ACTIVE_INTERFACE ]; then
Expand Down

0 comments on commit 872ca90

Please sign in to comment.