Fix warning reported by ShellCheck regarding PR #213 #230

Merged
mchiappero merged 1 commits from mchiappero/Factory:shellcheck_213 into main 2025-08-08 09:56:29 +02:00
2 changed files with 15 additions and 13 deletions

View File

@@ -53,7 +53,7 @@ wait_for_interface_or_ip
if [[ "$(echo "$LISTEN_ALL_INTERFACES" | tr '[:upper:]' '[:lower:]')" == "true" ]]; then if [[ "$(echo "$LISTEN_ALL_INTERFACES" | tr '[:upper:]' '[:lower:]')" == "true" ]]; then
export IRONIC_HOST_IP="::" export IRONIC_HOST_IP="::"
elif [[ -n env.ENABLE_IPV6 ]]; then elif [[ -n "${ENABLE_IPV6}" ]]; then

elif [[ -n "${ENABLE_IPV6}" ]]; then

`elif [[ -n "${ENABLE_IPV6}" ]]; then`
export IRONIC_HOST_IP="$IRONIC_IPV6" export IRONIC_HOST_IP="$IRONIC_IPV6"
else else
export IRONIC_HOST_IP="$IRONIC_IP" export IRONIC_HOST_IP="$IRONIC_IP"

View File

@@ -55,7 +55,7 @@ get_ip_of_hostname()
local HOSTNAME=$1 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)

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() get_interface_of_ip()
@@ -85,7 +85,7 @@ get_interface_of_ip()
# For IPv6 addresses, this will give the short-form address # For IPv6 addresses, this will give the short-form address
IP_ADDR="$(ipcalc "${IP_ADDR}" | grep "^Address:" | awk '{print $2}')" 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 '@')

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() get_ip_of_interface()
@@ -111,7 +111,7 @@ get_ip_of_interface()
local IFACE=$1 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)

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() get_provisioning_interface()
@@ -150,7 +150,7 @@ wait_for_interface_or_ip()
until [[ -n "$IFACE_OF_IP" ]]; do until [[ -n "$IFACE_OF_IP" ]]; do
echo "Waiting for ${PROVISIONING_IP} to be configured on an interface..." 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}")"

IFACE_OF_IP="$(get_interface_of_ip "${PROVISIONING_IP}")"

`IFACE_OF_IP="$(get_interface_of_ip "${PROVISIONING_IP}")"`
sleep 1 sleep 1
done done
@@ -167,18 +167,20 @@ wait_for_interface_or_ip()
until [[ -n "$IRONIC_IPV6" ]] || [[ -n "$IRONIC_IP" ]]; do until [[ -n "$IRONIC_IPV6" ]] || [[ -n "$IRONIC_IP" ]]; do
echo "Waiting for ${PROVISIONING_INTERFACE} interface to be configured..." 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)"

IRONIC_IPV6="$(get_ip_of_interface "${PROVISIONING_INTERFACE}" 6)"

` IRONIC_IPV6="$(get_ip_of_interface "${PROVISIONING_INTERFACE}" 6)"`
sleep 1 sleep 1
export IRONIC_IP="$(get_ip_of_interface $PROVISIONING_INTERFACE 4)" IRONIC_IP="$(get_ip_of_interface "${PROVISIONING_INTERFACE}" 4)"

IRONIC_IP="$(get_ip_of_interface "${PROVISIONING_INTERFACE}" 4)"

` IRONIC_IP="$(get_ip_of_interface "${PROVISIONING_INTERFACE}" 4)"`
sleep 1 sleep 1
done done
if [[ -n "$IRONIC_IPV6" ]]; then if [[ -n "$IRONIC_IPV6" ]]; then
echo "Found $IRONIC_IPV6 on interface \"${PROVISIONING_INTERFACE}\"!" echo "Found $IRONIC_IPV6 on interface \"${PROVISIONING_INTERFACE}\"!"
export IRONIC_IPV6
fi fi
if [[ -n "$IRONIC_IP" ]]; then if [[ -n "$IRONIC_IP" ]]; then
echo "Found $IRONIC_IP on interface \"${PROVISIONING_INTERFACE}\"!" echo "Found $IRONIC_IP on interface \"${PROVISIONING_INTERFACE}\"!"
export IRONIC_IP
fi fi
elif [[ -n "$IRONIC_URL_HOSTNAME" ]]; then elif [[ -n "$IRONIC_URL_HOSTNAME" ]]; then
local IPV6_IFACE="" local IPV6_IFACE=""
@@ -189,21 +191,21 @@ wait_for_interface_or_ip()
local IPV6_RECORD="" local IPV6_RECORD=""
local IPV4_RECORD="" local IPV4_RECORD=""
IPV6_RECORD="$(get_ip_of_hostname $IRONIC_URL_HOSTNAME 6)" IPV6_RECORD="$(get_ip_of_hostname "${IRONIC_URL_HOSTNAME}" 6)"

IPV6_RECORD="$(get_ip_of_hostname "${IRONIC_URL_HOSTNAME}" 6)"

` IPV6_RECORD="$(get_ip_of_hostname "${IRONIC_URL_HOSTNAME}" 6)"`
IPV4_RECORD="$(get_ip_of_hostname $IRONIC_URL_HOSTNAME 4)" IPV4_RECORD="$(get_ip_of_hostname "${IRONIC_URL_HOSTNAME}" 4)"

IPV4_RECORD="$(get_ip_of_hostname "${IRONIC_URL_HOSTNAME}" 4)"

`IPV4_RECORD="$(get_ip_of_hostname "${IRONIC_URL_HOSTNAME}" 4)"`
# We couldn't get any IP # We couldn't get any IP
if [[ -z "$IPV4_RECORD" ]] && [[ -z "$IPV6_RECORD" ]]; then 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 return 1
fi fi
echo "Waiting for ${IPV6_RECORD} to be configured on an interface" 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)"

IPV6_IFACE="$(get_interface_of_ip "${IPV6_RECORD}" 6)"

`IPV6_IFACE="$(get_interface_of_ip "${IPV6_RECORD}" 6)"`
sleep 1 sleep 1
echo "Waiting for ${IPV4_RECORD} to be configured on an interface" 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)"

IPV4_IFACE="$(get_interface_of_ip "${IPV4_RECORD}" 4)"

` IPV4_IFACE="$(get_interface_of_ip "${IPV4_RECORD}" 4)"`
sleep 1 sleep 1
done done
@@ -236,7 +238,7 @@ wait_for_interface_or_ip()
fi fi
if [[ -n "$IRONIC_IPV6" ]]; then if [[ -n "$IRONIC_IPV6" ]]; then
export ENABLE_IPV6=yes 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 fi
# Once determined if we have IPv4 and/or IPv6, override the hostname if provided # Once determined if we have IPv4 and/or IPv6, override the hostname if provided