From a69405c0cd4a6697ebe63c1b2fa7aa6e0323f574 Mon Sep 17 00:00:00 2001 From: Yosafat Marselino Date: Sat, 17 May 2025 09:18:52 -0400 Subject: [PATCH] Update script to allow args --- curl_execute.yaml | 2 +- test-scripts/install_k8s.sh | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/curl_execute.yaml b/curl_execute.yaml index 0035a92..af90299 100644 --- a/curl_execute.yaml +++ b/curl_execute.yaml @@ -26,7 +26,7 @@ - { name: 'script1.sh' } - name: Execute downloaded scripts - shell: "/tmp/downloaded_scripts/{{ item.item.name }}" + shell: "/tmp/downloaded_scripts/{{ item.item.name }} --ip {{ 192.168.8.54 }}" loop: "{{ downloaded_scripts.results }}" register: script_output diff --git a/test-scripts/install_k8s.sh b/test-scripts/install_k8s.sh index 078f999..de85d6a 100644 --- a/test-scripts/install_k8s.sh +++ b/test-scripts/install_k8s.sh @@ -12,8 +12,43 @@ if [ "$EUID" -ne 0 ]; then fi host_name="smolite" + +usage() { + echo "Usage: $0 -i IP -a ACTION" + echo "Required arguments:" + echo " -i, --ip IP Specify the IP address" + echo " -a, --action ACTION Specify the action to perform" + echo "Optional arguments:" + echo " -h, --help Show this help message and exit" + exit 1 +} + # read -p "Enter option (1.SMO Only; 2. NearRT Only; 3. SMO+NearRT ): " OPTION -read -p "Enter IP address: " VM_IP +#read -p "Enter IP address: " VM_IP + +if [ $# -eq 0 ]; then + echo "Error: Arguments are required!" + usage +fi + +while [ $# -gt 0 ]; do + case "$1" in + -h | --help) + usage + ;; + -ip | --ip) + VM_IP="$2" + shift 2 + ;; + *) + echo "Error: Unknown option $1" + usage + ;; + esac +done + +echo "Provision Kubernetes With IP $VM_IP" +exit KUBEVERSION="1.32.3-1.1" HELMVERSION="3.14.2"