From 23d5f19e39f099364a2ea69747e855b4f1ffed01 Mon Sep 17 00:00:00 2001 From: Paul Wagener Date: Mon, 9 Dec 2013 02:35:14 -0800 Subject: [PATCH] Use separate configuration files for vmbuilder --- build-vm/.gitignore | 4 ++++ build-vm/build.sh | 13 +++++-------- build-vm/firstboot.sh | 15 --------------- build-vm/vmbuilder.cfg.template | 13 +++++++++++++ build-vm/vmbuilder.copy.template | 1 + build-vm/vmbuilder.postinst | 4 ++++ 6 files changed, 27 insertions(+), 23 deletions(-) create mode 100644 build-vm/.gitignore delete mode 100755 build-vm/firstboot.sh create mode 100644 build-vm/vmbuilder.cfg.template create mode 100644 build-vm/vmbuilder.copy.template create mode 100755 build-vm/vmbuilder.postinst diff --git a/build-vm/.gitignore b/build-vm/.gitignore new file mode 100644 index 0000000..ea654af --- /dev/null +++ b/build-vm/.gitignore @@ -0,0 +1,4 @@ +vmbuilder.cfg +vmbuilder.copy +ubuntu-vmw6 +*~ diff --git a/build-vm/build.sh b/build-vm/build.sh index 813df9c..50143e5 100755 --- a/build-vm/build.sh +++ b/build-vm/build.sh @@ -1,14 +1,11 @@ #!/bin/bash -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +BUILDDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +sed "s|BUILDDIR|$BUILDDIR|g" < vmbuilder.cfg.template > vmbuilder.cfg +sed "s|BUILDDIR|$BUILDDIR|g" < vmbuilder.copy.template > vmbuilder.copy echo "Building Virtual Machine for Avans Security Workshop..." echo "(Requires vmbuilder, install with: 'sudo apt-get install python-vm-builder')" -sudo vmbuilder vmw6 ubuntu --flavour virtual --arch i386 -o \ - --firstboot $DIR/firstboot.sh \ - --user security --pass security --name "Security Workshop" \ - --addpkg apache2 --addpkg apache2-mpm-prefork \ - --addpkg git-core \ - --addpkg php5-cli --addpkg php5-mysql --addpkg libapache2-mod-php5 \ - --addpkg mysql-server --addpkg mysql-client +echo sudo vmbuilder vmw6 ubuntu --config vmbuilder.cfg -o diff --git a/build-vm/firstboot.sh b/build-vm/firstboot.sh deleted file mode 100755 index c0d242e..0000000 --- a/build-vm/firstboot.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -# This script is run the first time the VM boots up. -# It configures the VM for the security workshop -DIR=/home/security/workshop -echo "Initializing this VM for the Security Workshop..." - -# Get the workshop files -git clone https://github.com/Avans/Security-Workshop.git $DIR - -# Add boot.sh to the boot sequence -echo "$DIR/build-vm/boot.sh" >> /etc/rc.local - -# Resume normal boot sequence -$DIR/build-vm/boot.sh diff --git a/build-vm/vmbuilder.cfg.template b/build-vm/vmbuilder.cfg.template new file mode 100644 index 0000000..3cb983d --- /dev/null +++ b/build-vm/vmbuilder.cfg.template @@ -0,0 +1,13 @@ +[DEFAULT] +arch = i386 +user = security +name = Security Workshop +pass = security +copy = BUILDDIR/vmbuilder.copy +execscript = BUILDDIR/vmbuilder.postinst +verbose = true + +[ubuntu] +flavour = virtual +addpkg = apache2, git-core, php5-cli, php5-mysql, libapache2-mod-php5, mysql-server, mysql-client +hostname = security-workshop diff --git a/build-vm/vmbuilder.copy.template b/build-vm/vmbuilder.copy.template new file mode 100644 index 0000000..799398c --- /dev/null +++ b/build-vm/vmbuilder.copy.template @@ -0,0 +1 @@ +BUILDDIR/security-workshop.conf /etc/init/security-workshop.conf diff --git a/build-vm/vmbuilder.postinst b/build-vm/vmbuilder.postinst new file mode 100755 index 0000000..966da3e --- /dev/null +++ b/build-vm/vmbuilder.postinst @@ -0,0 +1,4 @@ +#!/bin/sh + +chroot $1 git clone https://github.com/Avans/Security-Workshop.git /home/security/workshop +