Fix conditional test in 02_configure.sh script
[icn.git] / env / metal3 / 02_configure.sh
index 3117027..d2842d2 100755 (executable)
@@ -1,5 +1,6 @@
 #!/usr/bin/env bash
-set -xe
+set -eux -o pipefail
+
 LIBDIR="$(dirname "$PWD")"
 
 source $LIBDIR/lib/logging.sh
@@ -10,11 +11,12 @@ if [[ $EUID -ne 0 ]]; then
     exit 1
 fi
 
-function check_inteface_ip {
+function check_interface_ip {
     local interface=$1
     local ipaddr=$2
 
-    if [ ! $(ip addr show dev $interface) ]; then
+    ip addr show dev $interface
+    if [ $? -ne 0 ]; then
         exit 1
     fi
 
@@ -62,13 +64,13 @@ function configure_ironic_interfaces {
     #Todo later to change the CNI networking for podman networking
     # Add firewall rules to ensure the IPA ramdisk can reach httpd, Ironic and the Inspector API on the host
     if [ "$IRONIC_PROVISIONING_INTERFACE" ]; then
-        check_inteface_ip $IRONIC_PROVISIONING_INTERFACE $IRONIC_PROVISIONING_INTERFACE_IP
+        check_interface_ip $IRONIC_PROVISIONING_INTERFACE $IRONIC_PROVISIONING_INTERFACE_IP
     else
         exit 1
     fi
 
     if [ "$IRONIC_IPMI_INTERFACE" ]; then
-        check_inteface_ip $IRONIC_IPMI_INTERFACE $IRONIC_IPMI_INTERFACE_IP
+        check_interface_ip $IRONIC_IPMI_INTERFACE $IRONIC_IPMI_INTERFACE_IP
     else
         exit 1
     fi
@@ -163,9 +165,10 @@ function configure {
     configure_ironic_interfaces
 }
 
-if [ "$1" == "-o" ]; then
+if [ "$#" -eq 0 ]; then
+    configure online
+elif [ "$1" == "-o" ]; then
     configure offline
-    exit 0
+else
+    exit 1
 fi
-
-configure