Skip to content

Instantly share code, notes, and snippets.

@RichMorin
Last active December 14, 2019 05:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RichMorin/dc9138962c19c205697bea23cce5134c to your computer and use it in GitHub Desktop.
Save RichMorin/dc9138962c19c205697bea23cce5134c to your computer and use it in GitHub Desktop.
Vagrantfile to set up Ubuntu disco with ALSA
# -*- mode: ruby -*-
# vi: set ft=ruby :
# This is `Vagrantfile.make`. It specifies the provisioning and
# configuration of the base Perkify VM (before add_ons is run).
#
# The ALSA-specific code is adapted from Christoph Neumann's vagrant-audio
# Vagrantfile (in https://github.com/christoph-neumann/vagrant-audio), with
# help from Clemens Ladisch and Eric Zuck.
Vagrant.configure("2") do |config|
config.ssh.forward_x11 = true
vm = config.vm
vm.box = "bento/ubuntu-19.04"
vm.box_version = "201906.18.0"
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine and only allow access
# via 127.0.0.1 to disable public access.
vm.network 'forwarded_port',
guest: 80,
host: 8080,
host_ip: '127.0.0.1'
vm.provision :shell, inline: <<-SHELL
set -ex
hostname perkify-make
apt-get update
# Provision ALSA.
extra=linux-modules-extra-$(uname -r)
echo "extra: $extra" #!T
apt-get install -y linux-image-generic $extra alsa-utils
sudo usermod -aG audio vagrant
text='pcm.!default {\n type plug\n slave.pcm "hw:0,1"\n}'
echo -e $text | tee >/dev/null /etc/asound.conf
sudo modprobe snd
sudo modprobe snd-hda-intel
sleep 2
sudo amixer -c 0 set Master playback 100% unmute
echo 'finis'
SHELL
# Customize ALSA.
config.vm.provider :virtualbox do |vb|
audio = case RUBY_PLATFORM
when /darwin|mac os/; 'coreaudio'
when /mswin|msys|mingw|cygwin|bccwin|wince|emc/; 'dsound'
when /linux/; 'alsa'
end
vb.customize [ 'modifyvm', :id,
'--audio', audio,
'--audiocontroller', 'hda',
'--audioout', 'on'
]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment