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 @@
1#!/bin/bash
2
3# Default values
4vcpu=2
5ram_gb=4
6disk_gb=20
7
8# Parse named arguments
9while [[ $# -gt 0 ]]; do
10 case $1 in
11 --vcpu)
12 vcpu="$2"
13 shift 2
14 ;;
15 --ram)
16 ram_gb="$2"
17 shift 2
18 ;;
19 --disk-size)
20 disk_gb="$2"
21 shift 2
22 ;;
23 *)
24 # Handle positional arguments (vmname and os)
25 if [ -z "$vmname" ]; then
26 vmname="$1"
27 elif [ -z "$os" ]; then
28 os="$1"
29 else
30 echo "Unknown argument: $1"
31 exit 1
32 fi
33 shift
34 ;;
35 esac
36done
37
38# Check mandatory arguments
39if [ -z "$vmname" ] || [ -z "$os" ]; then
40 echo "Usage: $0 <vm-name> <os> [--vcpu N] [--ram N] [--disk-size N]"
41 exit 1
42fi
43
44# Now you can use the variables
45echo "VM Name: $vmname"
46echo "OS: $os"
47echo "VCPU: $vcpu"
48echo "RAM: $ram_gb GB"
49echo "Disk: $disk_gb GB"