forked from opsxcq/dev-kickstart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.sh
executable file
·34 lines (26 loc) · 897 Bytes
/
main.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
#!/bin/bash
if [ -z "$1" ]
then
echo '[+] No iso image specified, using install.iso image by default'
IMAGE='install.iso'
else
echo '[+] Using the iso file '$1
IMAGE='/iso/'$1
fi
echo '[+] Checking image file'
ls -lh $IMAGE
echo '[+] Starting libvirtd service & default network'
service libvirtd start
sleep 7
virsh net-start default
echo '[+] Installing the operating system'
virt-install --name linux-build-test --ram 1024 --noreboot \
--disk path=./disk.qcow2,size=10 \
--vcpus 1 --os-type linux --os-variant generic --network bridge=virbr0,mac=52:54:00:7c:a1:64 \
--nographics --console pty,target_type=serial \
--initrd-inject=vm.ks --extra-args "ks=file:/vm.ks console=ttyS0,115200n8 serial" \
--location=$IMAGE
echo '[+] Optimizing the disk image'
time qemu-img convert -c -O qcow2 disk.qcow2 disk-final.qcow2
mv disk-final.qcow2 disk.qcow2
bash