Skip to content

Commit

Permalink
Add Vagrantfile for easier testing (#396)
Browse files Browse the repository at this point in the history
  • Loading branch information
angristan committed Feb 25, 2019
1 parent 52d6728 commit 6e40228
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vagrant/
*.log
30 changes: 30 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Run the script in headless mode for each of the supported OS.

machines = [
{ hostname: 'openvpn-debian-9', box: 'debian/stretch64' },
{ hostname: 'openvpn-debian-8', box: 'debian/jessie64' },
{ hostname: 'openvpn-ubuntu-1604', box: 'ubuntu/bionic64' },
{ hostname: 'openvpn-ubuntu-1804', box: 'ubuntu/xenial64' },
{ hostname: 'openvpn-centos-7', box: 'centos/7' },
{ hostname: 'openvpn-fedora-29', box: 'fedora/29-cloud-base' },
{ hostname: 'openvpn-fedora-28', box: 'fedora/28-cloud-base' },
{ hostname: 'openvpn-archlinux', box: 'archlinux/archlinux' }
]

Vagrant.configure('2') do |config|
machines.each do |machine|
config.vm.provider 'virtualbox' do |v|
v.memory = 1024
v.cpus = 2
end
config.vm.define machine[:hostname] do |machineconfig|
machineconfig.vm.hostname = machine[:hostname]
machineconfig.vm.box = machine[:box]

machineconfig.vm.provision 'shell', inline: <<-SHELL
AUTO_INSTALL=y /vagrant/openvpn-install.sh
ps aux | grep openvpn | grep -v grep > /dev/null 2>&1 && echo "Success: OpenVPN is running" && exit 0 || echo "Failure: OpenVPN is not running" && exit 1
SHELL
end
end
end
16 changes: 1 addition & 15 deletions openvpn-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ function installOpenVPN () {
CUSTOMIZE_ENC=${CUSTOMIZE_ENC:-n}
CLIENT=${CLIENT:-client}
PASS=${PASS:-1}
CONTINUE=${CONTINUE:-y}

# Behind NAT, we'll default to the publicly reachable IPv4.
PUBLIC_IPV4=$(curl ifconfig.co)
Expand Down Expand Up @@ -602,21 +603,6 @@ function installOpenVPN () {
elif [[ "$OS" = 'fedora' ]]; then
dnf install -y openvpn iptables openssl wget ca-certificates curl
elif [[ "$OS" = 'arch' ]]; then
echo ""
echo "WARNING: As you're using ArchLinux, I need to update the packages on your system to install those I need."
echo "Not doing that could cause problems between dependencies, or missing files in repositories (Arch Linux does not support partial upgrades)."
echo ""
echo "Continuing will update your installed packages and install needed ones."
echo ""
unset CONTINUE
until [[ $CONTINUE =~ (y|n) ]]; do
read -rp "Continue? [y/n]: " -e -i y CONTINUE
done
if [[ "$CONTINUE" = "n" ]]; then
echo "Exiting because user did not permit updating the system."
exit 4
fi

# Install required dependencies and upgrade the system
pacman --needed --noconfirm -Syu openvpn iptables openssl wget ca-certificates curl
fi
Expand Down

0 comments on commit 6e40228

Please sign in to comment.