-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_kvm
executable file
·28 lines (22 loc) · 1.32 KB
/
setup_kvm
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
#!/usr/bin/env bash
# make SURE httpd is installed and running
BOOT_ISO="/srv/boot.iso"
sudo yum install -y qemu-kvm qemu-img virt-manager libvirt libvirt-python libvirt-client virt-install virt-viewer httpd ipcalc
echo -en "WHAT is the DEFAULT domain for VM FQDN e.g mynet.net.org?: "
read DOMAIN ; if [[ -z $DOMAIN ]] ; then DOMAIN="mynet.net.org" ; fi
echo -en "WHAT is the DEFAULT domain for DNS to use e.g 8.8.8: "
read CHANGE_NS ; if [[ -z $CHANGE_NS ]] ; then CHANGE_NS="8.8.8.8" ; fi
if ipcalc -c $CHANGE_NS 2> /dev/null ; then echo "DEFAULT NS $CHANGE_NS"; else echo "$CAHNGE_NS is not a valid IP" ; fi
sudo cp create_vm destroy_vm vm_ks.ks /usr/bin/
sudo cp vm_ks.ks /srv/vm_ks_template.ks
sudo chmod +x /bin/create_vm /usr/bin/destroy_vm
sudo sed -i 's/^DOMAIN=.*$/'DOMAIN=$DOMAIN'/g' /usr/bin/create_vm
sudo sed -i 's/^CHANGE_NS_DEFAULT=.*$/'CHANGE_NS_DEFAULT=$CHANGE_NS'/g' /usr/bin/create_vm
if [[ -f $BOOT_ISO ]]
then
echo "$BOOT_ISO already exists, skiping download"
else
sudo curl http://mirror.centos.org/centos/7/os/x86_64/images/boot.iso -o $BOOT_ISO
fi
echo -en "IN order to allow kickstart, we should allow HTTP traffic, should we configure Firewall?? Say Yes: "
read config_firewall ; if [[ "$config_firewall" =~ [yes|Yes] ]] ; then sudo firewall-cmd --permanent --add-service=http ; sudo firewall-cmd --reload ; fi