Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # Installation: KVM
- # WebGUI: Kimchi for KVM
- # Tested on Ubuntu 16.04 and Debian 8
- # Inspiration: https://raymii.org/s/articles/virt-install_introduction_and_copy_paste_distro_install_commands.html
- # version 1.00
- # written by Henry den Hengst
- #
- if [[ $EUID -ne 0 ]]; then
- echo "This script must be run as root"
- exit 1
- fi
- #
- # update server
- apt-get update && apt-get upgrade -y
- #
- # for Debian 8
- # apt install qemu-kvm libvirt-bin virtinst uuid bridge-utils libosinfo-bin ntp -y
- # for ubuntu 16.04:
- # apt install qemu-kvm libvirt-bin virtinst uuid bridge-utils libosinfo-bin ntp -y
- #
- if [[ -r /etc/os-release ]]; then
- . /etc/os-release
- if [[ $ID = ubuntu ]]; then
- apt install qemu-kvm libvirt-bin virtinst uuid bridge-utils libosinfo-bin ntp yum git python-setuptools -y
- # apt install kimchi -y
- # I followed this link and was able to fix the issue: https://github.com/kimchi-project/kimchi/issues/821
- # Basically you need to edit /lib/systemd/system/kimchi.service and change
- # Requires=libvirtd.service
- # After=libvirtd.service
- # To:
- # Requires=libvirt-bin.service
- # After=libvirt-bin.service
- # and edit /etc/pam.d/kichmi and change:
- # auth sufficient pam_succeed_if.so user ingroup libvirt
- # To:
- # auth sufficient pam_succeed_if.so user ingroup libvirtd
- #
- # ufw allow 8000
- # ufw allow 8001
- # ufw allow 64667
- else
- apt install qemu-kvm libvirt-bin virtinst uuid bridge-utils libosinfo-bin ntp git -y
- fi
- else
- echo "Not running a distribution with /etc/os-release available"
- fi
- #
- adduser $USER libvirtd
- mkdir /iso
- mkdir /vm
- mkdir /scripts
- virsh pool-define-as VMpool01 dir - - - - "/vm/"
- virsh pool-build VMpool01
- virsh pool-start VMpool01
- virsh pool-autostart VMpool01
- qemu-img create -f raw /vm/VM-Vol1.img 100G
- #
- # automated KVM installation scripts of CentOS 7, OpenSUSE 13, Ubuntu 16.04 LTS and Debian 8
- cd /scripts
- #
- # Download Popular Linux Distro ISOs. Put a # before line to skip
- cd /iso
- wget -c http://releases.ubuntu.com/16.04/ubuntu-16.04.2-server-amd64.iso
- wget -c http://ftp.tudelft.nl/centos.org/7/isos/x86_64/CentOS-7-x86_64-NetInstall-1611.iso
- wget -c http://frafiles.pfsense.org/mirror/downloads/pfSense-CE-2.3.4-RELEASE-amd64.iso.gz
- gunzip pfSense-CE-2.3.4-RELEASE-amd64.iso.gz
- wget -c https://cdimage.debian.org/debian-cd/8.8.0/amd64/iso-cd/debian-8.8.0-amd64-netinst.iso
- #
- # End of Downloading ISOs.
- #
- # virsh destroy centos7
- # virsh undefine centos7
- cd /root
- osinfo-query os > status.txt
- brctl show >> status.txt
- virsh pool-info VMpool01 >> status.txt
- virsh list >> status.txt
- virsh pool-list --all >> status.txt
- if [[ -r /etc/os-release ]]; then
- . /etc/os-release
- if [[ $ID = ubuntu ]]; then
- ufw allow 22
- ufw enable
- else
- echo "ufw"
- fi
- else
- echo "Not running a distribution with /etc/os-release available"
- fi
- cat status.txt
Advertisement
Add Comment
Please, Sign In to add comment