File 0019-check-platform-service-after-getopts-parsing.patch of Package powerpc-utils
From ae0c6f88f780fafaa6772bc1dbd18ec18959cc54 Mon Sep 17 00:00:00 2001
From: Marius Tomaschewski <mt@suse.de>
Date: Mon, 7 Feb 2022 13:57:01 +0100
Subject: [PATCH 19/27] check platform/service after getopts parsing
---
scripts/hcnmgr | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/scripts/hcnmgr b/scripts/hcnmgr
index cd5c9a4..4fa6308 100644
--- a/scripts/hcnmgr
+++ b/scripts/hcnmgr
@@ -840,25 +840,6 @@ echo "=======================$NOW============================"
HCNCMD=$(basename "$0")
hcnlog DEBUG "$HCNCMD enter"
-#Validate this tool is running on powerpc platform
-. "$PSERIES_PLATFORM"
-if [ "$platform" != "$PLATFORM_PSERIES_LPAR" ]; then
- hcnlog INFO "HNV is only supported on PowerVM LPAR"
- hcnlog INFO "$HCNCMD exit"
- exit 0
-fi
-
-#Init the distribution and the network service
-check_network_service
-
-#Validate bonding module is loaded
-if ! lsmod | grep -q bonding; then
- hcnlog DEBUG "HCNMGR: Bonding module not loaded, load module ..."
- if ! modprobe bonding $BOND_MODPROBE_OPTS; then
- err $E_NOMODULE
- fi
-fi
-
#getops for help and version
while getopts "sxVhd:" arg; do
case "$arg" in
@@ -895,6 +876,25 @@ if [ "X$HCNTRACE" != "X" ] ; then
set "$HCNTRACE"
fi
+#Validate this tool is running on powerpc platform
+. "$PSERIES_PLATFORM"
+if [ "$platform" != "$PLATFORM_PSERIES_LPAR" ]; then
+ hcnlog INFO "HNV is only supported on PowerVM LPAR"
+ hcnlog INFO "$HCNCMD exit"
+ exit 0
+fi
+
+#Init the distribution and the network service
+check_network_service
+
+#Validate bonding module is loaded
+if ! lsmod | grep -q bonding; then
+ hcnlog DEBUG "HCNMGR: Bonding module not loaded, load module ..."
+ if ! modprobe bonding $BOND_MODPROBE_OPTS; then
+ err $E_NOMODULE
+ fi
+fi
+
#Parse the DRC_INDEX and HCN_ID from the arguments
for param in "$@"; do
if [[ $param =~ ^DRC_INDEX=(.+)$ ]]; then
--
2.34.1