Fix warning reported by ShellCheck regarding PR #213 #230
@@ -53,7 +53,7 @@ wait_for_interface_or_ip
|
||||
|
||||
if [[ "$(echo "$LISTEN_ALL_INTERFACES" | tr '[:upper:]' '[:lower:]')" == "true" ]]; then
|
||||
export IRONIC_HOST_IP="::"
|
||||
elif [[ -n env.ENABLE_IPV6 ]]; then
|
||||
elif [[ -n "${ENABLE_IPV6}" ]]; then
|
||||
export IRONIC_HOST_IP="$IRONIC_IPV6"
|
||||
else
|
||||
export IRONIC_HOST_IP="$IRONIC_IP"
|
||||
|
@@ -55,7 +55,7 @@ get_ip_of_hostname()
|
||||
|
||||
local HOSTNAME=$1
|
||||
|
||||
echo "$(nslookup -type=${QUERY} $HOSTNAME | tail -n2 | grep -w "Address:" | cut -d " " -f2)"
|
||||
echo $(nslookup -type=${QUERY} "${HOSTNAME}" | tail -n2 | grep -w "Address:" | cut -d " " -f2)
|
||||
}
|
||||
|
||||
get_interface_of_ip()
|
||||
@@ -85,7 +85,7 @@ get_interface_of_ip()
|
||||
# For IPv6 addresses, this will give the short-form address
|
||||
IP_ADDR="$(ipcalc "${IP_ADDR}" | grep "^Address:" | awk '{print $2}')"
|
||||
|
||||
echo "$(ip $IP_VERS -br addr show scope global | grep -i " ${IP_ADDR}/" | cut -f 1 -d ' ' | cut -f 1 -d '@')"
|
||||
echo $(ip ${IP_VERS} -br addr show scope global | grep -i " ${IP_ADDR}/" | cut -f 1 -d ' ' | cut -f 1 -d '@')
|
||||
}
|
||||
|
||||
get_ip_of_interface()
|
||||
@@ -111,7 +111,7 @@ get_ip_of_interface()
|
||||
|
||||
local IFACE=$1
|
||||
|
||||
echo "$(ip $IP_VERS -br addr show scope global up dev $IFACE | awk '{print $3}' | sed -e 's%/.*%%' | head -n 1)"
|
||||
echo $(ip ${IP_VERS} -br addr show scope global up dev ${IFACE} | awk '{print $3}' | sed -e 's%/.*%%' | head -n 1)
|
||||
}
|
||||
|
||||
get_provisioning_interface()
|
||||
@@ -150,7 +150,7 @@ wait_for_interface_or_ip()
|
||||
|
||||
until [[ -n "$IFACE_OF_IP" ]]; do
|
||||
echo "Waiting for ${PROVISIONING_IP} to be configured on an interface..."
|
||||
IFACE_OF_IP="$(get_interface_of_ip $PROVISIONING_IP)"
|
||||
IFACE_OF_IP="$(get_interface_of_ip "${PROVISIONING_IP}")"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
@@ -167,18 +167,20 @@ wait_for_interface_or_ip()
|
||||
until [[ -n "$IRONIC_IPV6" ]] || [[ -n "$IRONIC_IP" ]]; do
|
||||
echo "Waiting for ${PROVISIONING_INTERFACE} interface to be configured..."
|
||||
|
||||
export IRONIC_IPV6="$(get_ip_of_interface $PROVISIONING_INTERFACE 6)"
|
||||
IRONIC_IPV6="$(get_ip_of_interface "${PROVISIONING_INTERFACE}" 6)"
|
||||
sleep 1
|
||||
|
||||
export IRONIC_IP="$(get_ip_of_interface $PROVISIONING_INTERFACE 4)"
|
||||
IRONIC_IP="$(get_ip_of_interface "${PROVISIONING_INTERFACE}" 4)"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
if [[ -n "$IRONIC_IPV6" ]]; then
|
||||
echo "Found $IRONIC_IPV6 on interface \"${PROVISIONING_INTERFACE}\"!"
|
||||
export IRONIC_IPV6
|
||||
fi
|
||||
if [[ -n "$IRONIC_IP" ]]; then
|
||||
echo "Found $IRONIC_IP on interface \"${PROVISIONING_INTERFACE}\"!"
|
||||
export IRONIC_IP
|
||||
fi
|
||||
elif [[ -n "$IRONIC_URL_HOSTNAME" ]]; then
|
||||
local IPV6_IFACE=""
|
||||
@@ -189,21 +191,21 @@ wait_for_interface_or_ip()
|
||||
local IPV6_RECORD=""
|
||||
local IPV4_RECORD=""
|
||||
|
||||
IPV6_RECORD="$(get_ip_of_hostname $IRONIC_URL_HOSTNAME 6)"
|
||||
IPV4_RECORD="$(get_ip_of_hostname $IRONIC_URL_HOSTNAME 4)"
|
||||
IPV6_RECORD="$(get_ip_of_hostname "${IRONIC_URL_HOSTNAME}" 6)"
|
||||
IPV4_RECORD="$(get_ip_of_hostname "${IRONIC_URL_HOSTNAME}" 4)"
|
||||
|
||||
# We couldn't get any IP
|
||||
if [[ -z "$IPV4_RECORD" ]] && [[ -z "$IPV6_RECORD" ]]; then
|
||||
echo "${FUNCNAME}: no valid IP found for hostname $IRONIC_URL_HOSTNAME" >&2
|
||||
echo "${FUNCNAME}: no valid IP found for hostname ${IRONIC_URL_HOSTNAME}" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "Waiting for ${IPV6_RECORD} to be configured on an interface"
|
||||
IPV6_IFACE="$(get_interface_of_ip $IPV6_RECORD 6)"
|
||||
IPV6_IFACE="$(get_interface_of_ip "${IPV6_RECORD}" 6)"
|
||||
sleep 1
|
||||
|
||||
echo "Waiting for ${IPV4_RECORD} to be configured on an interface"
|
||||
IPV4_IFACE="$(get_interface_of_ip $IPV4_RECORD 4)"
|
||||
IPV4_IFACE="$(get_interface_of_ip "${IPV4_RECORD}" 4)"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
@@ -236,7 +238,7 @@ wait_for_interface_or_ip()
|
||||
fi
|
||||
if [[ -n "$IRONIC_IPV6" ]]; then
|
||||
export ENABLE_IPV6=yes
|
||||
export IRONIC_URL_HOST="[$IRONIC_IPV6]" # The HTTP host needs surrounding with brackets
|
||||
export IRONIC_URL_HOST="[${IRONIC_IPV6}]" # The HTTP host needs surrounding with brackets
|
||||
fi
|
||||
|
||||
# Once determined if we have IPv4 and/or IPv6, override the hostname if provided
|
||||
|
Reference in New Issue
Block a user