-
Notifications
You must be signed in to change notification settings - Fork 0
/
virt-install.sh
executable file
·59 lines (54 loc) · 1.79 KB
/
virt-install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
cpus=2
memory=2048
disk_size=12
name="aps-vm2"
usage()
{
echo -e "Help for installing Debian 10 KVM Virtual machine via virt installer\nOptions:"
echo -e "\t--cpus NUM_OF_CPUS"
echo -e "\t\tNumber of cpus for vitual machine (default 2)"
echo -e "\t--memory MEMORY_SIZE"
echo -e "\t\tAmount of memory size in MB (default 2048)"
echo -e "\t--size DISK_SIZE"
echo -e "\t\tDisk size in GB (default 12)"
echo -e "\t--name NAME"
echo -e "\t\tVM name (default aps-vm)"
echo -e "\t-h, --help"
echo -e "\t\tShows this help"
}
while [ "$1" != "" ]; do
case $1 in
--cpus ) shift
cpus=$1
;;
-h | --help ) usage
exit
;;
--memory ) shift
memory=$1
;;
--size ) shift
disk_size=$1
;;
--name ) shift
name=$1
;;
* ) echo "$(echo $'\e[33;1m')Unrecognized option!"
tput sgr0
usage
exit 1
esac
shift
done
if [ "$disk_size" -lt "12" ]; then
echo "$(echo $'\e[33;1m')Disk size cannot be less than 12GB!"
disk_size=12
tput sgr0
fi
# wget https://cdimage.debian.org/debian-cd/current/i386/iso-cd/debian-10.2.0-i386-netinst.iso
virt-install \
--name $name \
--ram $memory \
--vcpus $cpus \
--disk size=$disk_size \
--cdrom /home/jany/Downloads/ubuntu-18.04.3-live-server-amd64.iso