#!/bin/bash # SPDX-FileCopyrightText: 2021 Ole Tange, http://ole.tange.dk and Free Software and Foundation, Inc. # # SPDX-License-Identifier: GPL-3.0-or-later setup_one() { # setup_one ubuntu/trusty64 172.27.27.2 if [ -z "$2" ] ; then echo Usage: setup_one ubuntu/trusty64 172.27.27.2 return 1 fi vfile="$1"/Vagrantfile mkdir -p "$1" cp Vagrantfile.tmpl "$vfile" ( cd "$1" perl -i -pe "s{%%VMBOX%%}{$1}g;s/%%IP%%/$2/" Vagrantfile vagrant up vagrant ssh -c 'ip addr || ifconfig' ) ssh-keygen -R $2 ssh vagrant@$2 hostname } export -f setup_one destroy_one() { ( cd "$1" vagrant destroy -f ) rm -r ./"$1" } export -f destroy_one server_list() { grep -v '#' <