Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Set address based on interface in provision.sh #540

Merged
merged 3 commits into from
Sep 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions hack/scripts/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -268,16 +268,16 @@ do_all_flintlock() {

install_flintlockd "$version"

if [[ -z "$address" ]]; then
address=$(lookup_address)
fi
if [[ -z "$parent_iface" ]]; then
parent_iface=$(lookup_interface)
fi
if [[ -z "$address" ]]; then
address=$(lookup_address "$parent_iface")
fi
write_flintlockd_config "$address" "$parent_iface" "$insecure"

start_flintlockd_service
say "Flintlockd running at $address:9090"
say "Flintlockd running at $address:9090 via interface $parent_iface"
}

# Fetch and install the flintlockd binary at the specified version
Expand Down Expand Up @@ -329,14 +329,16 @@ start_flintlockd_service() {
start_service "$FLINTLOCK_BIN"
}

# Returns the internal address of the host
lookup_address() {
ip route show | awk '/scope link/ {print $9}' | grep -E '^(192\.168|10\.|172\.1[6789]\.|172\.2[0-9]\.|172\.3[01]\.)'
}

# Returns the interface of the default route
lookup_interface() {
ip route show | awk '/default/ {print $5}'
ip route show | awk '/default/ {print $5}' | head -n 1
}

# Returns the internal address of the host associated with the given interface
lookup_address() {
local interface="$1"

ip route show | awk -v i="$interface" '$0 ~ i {print $9}' | grep -E '^(192\.168|10\.|172\.1[6789]\.|172\.2[0-9]\.|172\.3[01]\.)'
}

## CONTAINERD
Expand Down