From 13ae767e7f394d8b90deca3c1543780744619ddc Mon Sep 17 00:00:00 2001
From: tteckster <tteckster@gmail.com>
Date: Sat, 6 May 2023 07:30:41 -0400
Subject: [PATCH] Update monitor-all.sh

code refactoring
---
 misc/monitor-all.sh | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/misc/monitor-all.sh b/misc/monitor-all.sh
index 3b616b315..a72300c62 100644
--- a/misc/monitor-all.sh
+++ b/misc/monitor-all.sh
@@ -118,11 +118,24 @@ remove() {
   echo "Removed Monitor All from Proxmox VE"
 }
 
-if [ "$1" == "add" ]; then
+# Define options for the whiptail menu
+OPTIONS=(Add "Add Monitor-All to Proxmox VE" \
+         Remove "Remove Monitor-All from Proxmox VE")
+
+# Show the whiptail menu and save the user's choice
+CHOICE=$(whiptail --title "Monitor-All for Proxmox VE" --menu "Select an option:" 10 58 2 \
+          "${OPTIONS[@]}" 3>&1 1>&2 2>&3)
+
+# Check the user's choice and perform the corresponding action
+case $CHOICE in
+  "Add")
     add
-elif [ "$1" == "remove" ]; then
+    ;;
+  "Remove")
     remove
-else
-    echo "Usage: $0 [ -s add | -s remove ]"
-    exit 1
-fi
+    ;;
+  *)
+    echo "Exiting..."
+    exit 0
+    ;;
+esac