configs/install-stuff/install-qemu-libvirt.bash

37 lines
1.2 KiB
Bash
Raw Normal View History

2023-09-06 15:21:33 -05:00
#!/usr/bin/env bash
set -e
if [ $(whoami) == "root" ]; then
echo "Run as a normal user, not root"
exit 1
fi
command_exists() { type "$1" &>/dev/null; }
if command_exists "apt-get"; then
sudo apt-get install qemu-system libvirt-daemon-system virt-manager -y
elif command_exists "yum"; then
sudo yum install @Virtualization virt-manager -y
2024-03-17 19:02:47 -05:00
sudo systemctl enable --now libvirtd.service
2024-03-17 18:56:48 -05:00
sudo usermod -aG libvirt $(whoami)
2023-09-06 15:21:33 -05:00
elif command_exists "pacman"; then
sudo pacman -S qemu-full dnsmasq --noconfirm --needed
2023-09-07 09:13:31 -05:00
sudo pacman -S virt-manager --noconfirm --needed
sudo systemctl enable --now libvirtd.service
2023-09-06 15:21:33 -05:00
elif command_exists "zypp"; then
# Untested
sudo zypper install qemu -y
elif command_exists "emerge"; then
sudo echo Not yet supported, exiting...
elif command_exists "apk"; then
sudo apk add qemu-img qemu-system-x86_64 libvirt-daemon py-libvirt py-libxml2
sudo apk add git
sudo rc-update add libvirtd
sudo rc-service libvirtd start
elif command_exists "xbps-install"; then
sudo xbps-install qemu libvirt virt-manager
sudo usermod -aG libvirt $(whoami)
2024-04-20 20:35:22 -05:00
sudo ln -s /etc/sv/libvirtd/ /var/service/
2023-09-06 15:21:33 -05:00
else
echo "Unsupported: unknown package manager and distro"
2023-09-06 15:21:33 -05:00
fi