Skip to content

Instantly share code, notes, and snippets.

@cmhobbs
Created March 18, 2011 01:17
Show Gist options
  • Save cmhobbs/875468 to your computer and use it in GitHub Desktop.
Save cmhobbs/875468 to your computer and use it in GitHub Desktop.
hack script to install/setup kvm
#!/usr/bin/env bash
# Quick and dirty KVM setup script.
cat << EOT
THIS SCRIPT SHOULD GET YOU UP AND RUNNING WITH KVM.
HERE'S THE PROCESS:
- UPDATE YOUR SYSTEM
- INSTALL KVM'S REQUIRED PACKAGES
- ADD YOUR USER TO THE NECESSARY GROUPS
- REBOOT YOUR SERVER
THIS SCRIPT HAS NO ERROR CATCHING. WHAT'S THE WORST
THAT COULD HAPPEN?
EOT
read -p "== PRESS [ENTER] TO CONTINUE..."
# update the box
echo "== UPDATING YOUR SYSTEM..."
sudo apt-get update
sudo apt-get dist-upgrade
# install necessary packages
echo "== INSTALLING KVM AND ITS REQUIRED/EXTRA PACKAGES"
sudo apt-get install vim htop screen qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils qemu libcap2-bin bridge-utilsvirt-manager
# edit /etc/network/interfaces, make a backup first
echo "== BACKING UP /etc/network/interfaces to /tmp/interfaces.bak"
sudo mv /etc/network/interfaces /tmp/interfaces.bak
echo "== DUMPING CONFIG AND EDITING /etc/network/interfaces"
echo "== YOU WILL BE REDIRECTED TO VI, WHEN YOU FINISH YOUR"
echo "== EDITING AND SAVE THE FILE, YOU WILL BE RETURNED TO"
echo "== THIS SCRIPT."
echo ""
read -p "== PRESS [ENTER] TO CONTINUE..."
sudo cat > /etc/network/interfaces <<EOT
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet manual
auto br0
iface br0 inet static
address 192.168.0.10
network 192.168.0.0
netmask 255.255.255.0
broadcast 192.168.0.255
gateway 192.168.0.1
bridge_ports eth0
bridge_stp off
bridge_fd 0
bridge_maxwait 0
EOT
sudo vi /etc/network/interfaces
# reboot this mother
sudo reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment