summaryrefslogtreecommitdiff
path: root/others/vm3/test.sh
diff options
context:
space:
mode:
Diffstat (limited to 'others/vm3/test.sh')
-rwxr-xr-xothers/vm3/test.sh49
1 files changed, 49 insertions, 0 deletions
diff --git a/others/vm3/test.sh b/others/vm3/test.sh
new file mode 100755
index 0000000..0dafc23
--- /dev/null
+++ b/others/vm3/test.sh
@@ -0,0 +1,49 @@
+#!/bin/bash
+
+# Default values
+vcpu=2
+ram_gb=4
+disk_gb=20
+
+# Parse named arguments
+while [[ $# -gt 0 ]]; do
+ case $1 in
+ --vcpu)
+ vcpu="$2"
+ shift 2
+ ;;
+ --ram)
+ ram_gb="$2"
+ shift 2
+ ;;
+ --disk-size)
+ disk_gb="$2"
+ shift 2
+ ;;
+ *)
+ # Handle positional arguments (vmname and os)
+ if [ -z "$vmname" ]; then
+ vmname="$1"
+ elif [ -z "$os" ]; then
+ os="$1"
+ else
+ echo "Unknown argument: $1"
+ exit 1
+ fi
+ shift
+ ;;
+ esac
+done
+
+# Check mandatory arguments
+if [ -z "$vmname" ] || [ -z "$os" ]; then
+ echo "Usage: $0 <vm-name> <os> [--vcpu N] [--ram N] [--disk-size N]"
+ exit 1
+fi
+
+# Now you can use the variables
+echo "VM Name: $vmname"
+echo "OS: $os"
+echo "VCPU: $vcpu"
+echo "RAM: $ram_gb GB"
+echo "Disk: $disk_gb GB"