55 lines
2.1 KiB
Bash
55 lines
2.1 KiB
Bash
#!/bin/sh
|
|
|
|
USER="$(test -d /vagrant && echo "vagrant")"
|
|
if test -z "$USER" && grep "^debian" /etc/passwd ; then USER="debian" ; fi
|
|
if test -z "$USER" && grep "^user" /etc/passwd ; then USER="user" ; fi
|
|
if [ -z "$USER" ] ; then
|
|
exit 1
|
|
fi
|
|
|
|
echo "root:root" | chpasswd
|
|
echo "$USER:$USER" | chpasswd
|
|
|
|
# FIXME: make sure that user is root or fail fast
|
|
|
|
# Install base unix tools
|
|
apt-get update
|
|
apt-get install -y git vim wget curl
|
|
|
|
# Install vagrant
|
|
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.asc
|
|
echo "deb [ signed-by=/usr/share/keyrings/hashicorp-archive-keyring.asc ] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
|
|
sudo apt-get update && sudo apt-get install vagrant
|
|
|
|
|
|
# Install libvirt + qemu + kvm
|
|
# Ref. https://vagrant-libvirt.github.io/vagrant-libvirt/installation.html#ubuntu--debian
|
|
apt-get install -y qemu-utils libvirt-daemon-system libvirt-dev ebtables libguestfs-tools bridge-utils ruby-fog-libvirt
|
|
|
|
adduser "$USER" libvirt || true
|
|
|
|
# Install NFS
|
|
apt-get install -y nfs-kernel-server
|
|
|
|
# Give permission to libvirt group for NFS
|
|
cat > /etc/sudoers.d/vagrant-nfs <<-MARK
|
|
Cmnd_Alias VAGRANT_EXPORTS_CHOWN = /bin/chown 0\:0 /tmp/vagrant-exports
|
|
Cmnd_Alias VAGRANT_EXPORTS_MV = /bin/mv -f /tmp/vagrant-exports /etc/exports
|
|
Cmnd_Alias VAGRANT_NFSD_CHECK = /etc/init.d/nfs-kernel-server status
|
|
Cmnd_Alias VAGRANT_NFSD_START = /etc/init.d/nfs-kernel-server start
|
|
Cmnd_Alias VAGRANT_NFSD_APPLY = /usr/sbin/exportfs -ar
|
|
%libvirt ALL=(root) NOPASSWD: VAGRANT_EXPORTS_CHOWN, VAGRANT_EXPORTS_MV, VAGRANT_NFSD_CHECK, VAGRANT_NFSD_START, VAGRANT_NFSD_APPLY
|
|
MARK
|
|
|
|
# Install base requirements for vagrant plugins
|
|
apt-get install -y libxslt-dev libxml2-dev zlib1g-dev ruby-dev gcc make
|
|
|
|
|
|
# Make sure the embedded libraries match system libraries
|
|
if ! su "$USER" -c "vagrant plugin list" |grep '^vagrant-libvirt' ; then
|
|
echo "Installing vagrant-libvirt..."
|
|
su "$USER" -c "vagrant plugin install vagrant-libvirt" # --debug
|
|
else
|
|
echo "Skipping vagrant-libvirt (already installed)"
|
|
fi
|
|
|