From 9c98414c8580d557eb3e03439e50ee5a3be71ad3 Mon Sep 17 00:00:00 2001 From: Shaun Duncan Date: Thu, 20 Feb 2014 11:34:04 -0500 Subject: [PATCH 1/4] Initial Vagrantfile --- .gitignore | 2 ++ Vagrantfile | 28 +++++++++++++++ scripts/provision.sh | 82 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 112 insertions(+) create mode 100644 Vagrantfile create mode 100644 scripts/provision.sh diff --git a/.gitignore b/.gitignore index f5ba54803..956ba27ba 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,5 @@ cmd/drone/drone cmd/droned/droned deb/drone/usr/local/bin/drone deb/drone/usr/local/bin/droned + +.vagrant diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 000000000..72d10963e --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,28 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! +VAGRANTFILE_API_VERSION = "2" + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + # Drone supports 12.04 64bit and 13.04 64bit + config.vm.box = "precise64" + config.vm.box_url = "http://files.vagrantup.com/precise64.box" + + # Forward keys from SSH agent rather than copypasta + config.ssh.forward_agent = true + + # FIXME: Maybe this is enough + config.vm.provider "virtualbox" do |v| + v.customize ["modifyvm", :id, "--memory", "1024"] + end + + # Drone by default runs on port 80. Forward from host to guest + config.vm.network :forwarded_port, guest: 80, host: 8080 + config.vm.network :private_network, ip: "192.168.56.101" + + # system-level initial setup + config.vm.provision "shell" do |s| + s.path = "scripts/provision.sh" + end +end diff --git a/scripts/provision.sh b/scripts/provision.sh new file mode 100644 index 000000000..186d616f4 --- /dev/null +++ b/scripts/provision.sh @@ -0,0 +1,82 @@ +#!/bin/sh +set -e + +# Ensure that agent forwarding is set up properly. +if [ "$SSH_AUTH_SOCK" ]; then + echo "SSH_AUTH_SOCK is set; you are successfully agent-forwarding. These keys are loaded:" + if [ -z "$1" ]; then + ssh-add -l + else + echo "Not attempting to list keys because windows ssh-agent communication is broken..." + fi +else + echo "No SSH_AUTH_SOCK was found in the environment!" + exit 3 +fi + +# apt-get update. +if [ -e /root/package-list-updated ]; then + echo "Skipping package cache update. To force, remove /root/package-list-updated and re-provision." +else + echo "Updating package cache." + sudo apt-get update -qq + touch /root/package-list-updated +fi + +echo "Installing Packages..." +export DEBIAN_FRONTEND=noninteractive +( sed -e 's/#.*$//' | xargs sudo apt-get install -qqy --force-yes ) <<-EOF + git + + # Stuff required by medley + python-software-properties # TODO why do we need this? + build-essential # needed to compile parts of packages + curl # many scripts expect this to fetch urls. + python-dev # for compiling python modules + python-imaging # Useful if you do not want to compile PIL + python-pip # for installing things + python-psycopg2 # python postgresql library + python-setuptools # for installing/making packages + python-unittest2 # standard unit testing library + python-virtualenv # for partioning python projects + pv # "pipe viewer", for nice progressbars in med + exuberant-ctags # required by 'med tags' + + # geospatial libraries + libgdal1-dev + libgdal1-1.7.0 + libgeos-3.2.2 + libgeos-c1 + libgeos-dev + + python-lxml # TODO why do we need this? + libxml2 # TODO why do we need this? + libxml2-dev # TODO why do we need this? + libxslt1-dev # TODO why do we need this? + + postgresql-9.0 # our database. + postgresql-contrib-9.0 # django wants this + postgresql-server-dev-9.0 # TODO why do we need this? + + # postgresql-9.0-postgis is not available in standard repos, so we install + # my custom package later. + #postgresql-9.0-postgis # utilize geo stuff in postgres + + + # Development helpers that I'm asserting don't need to be installed by + # default for everyone using this thing, they can just install them when + # they need them. + # ack-grep # adreyer thinks you should have it + # ipython # adreyer thinks you should have it + # bpython # nksmith thinks you should have it + # memcached # django can work around not having this + # proj # TODO apt says it is transitional. wtf is it for? + # pyflakes # adreyer thinks you should have it + # pylint # adreyer thinks you should have it + # python-pycryptopp # adreyer thinks you should have it + # virtualenvwrapper # convenience tool + # rabbitmq-server # adreyer thinks you should have it + # vim # adreyer thinks you should have it + + openjdk-7-jre-headless # needed to run solr +EOF From dea3f597ad9574d33e86707439cc1d9ef55f2ac2 Mon Sep 17 00:00:00 2001 From: Shaun Duncan Date: Thu, 20 Feb 2014 17:34:25 -0500 Subject: [PATCH 2/4] Updates to vagrantfile and adding in extra provisioning --- Vagrantfile | 8 +-- scripts/provision.sh | 115 ++++++++++++++++++++++--------------------- 2 files changed, 62 insertions(+), 61 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 72d10963e..8b9f489ed 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -19,10 +19,10 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # Drone by default runs on port 80. Forward from host to guest config.vm.network :forwarded_port, guest: 80, host: 8080 - config.vm.network :private_network, ip: "192.168.56.101" + + # Sync this repo + config.vm.synced_folder ".", "/opt/drone" # system-level initial setup - config.vm.provision "shell" do |s| - s.path = "scripts/provision.sh" - end + config.vm.provision "shell", path: "scripts/provision.sh" end diff --git a/scripts/provision.sh b/scripts/provision.sh index 186d616f4..b5aa2161d 100644 --- a/scripts/provision.sh +++ b/scripts/provision.sh @@ -15,68 +15,69 @@ else fi # apt-get update. -if [ -e /root/package-list-updated ]; then - echo "Skipping package cache update. To force, remove /root/package-list-updated and re-provision." -else - echo "Updating package cache." - sudo apt-get update -qq - touch /root/package-list-updated -fi +#if [ -e /root/package-list-updated ]; then +# echo "Skipping package cache update. To force, remove /root/package-list-updated and re-provision." +#else +# echo "Updating package cache." +# sudo apt-get update -qq +# touch /root/package-list-updated +#fi -echo "Installing Packages..." +# FIXME: Don't run this every time? +sudo apt-get update -qq + +echo "Installing Base Packages" export DEBIAN_FRONTEND=noninteractive ( sed -e 's/#.*$//' | xargs sudo apt-get install -qqy --force-yes ) <<-EOF + build-essential + + # These are needed for go get + bzr git + mercurial + + # Other + vim # Stuff required by medley - python-software-properties # TODO why do we need this? - build-essential # needed to compile parts of packages - curl # many scripts expect this to fetch urls. - python-dev # for compiling python modules - python-imaging # Useful if you do not want to compile PIL - python-pip # for installing things - python-psycopg2 # python postgresql library - python-setuptools # for installing/making packages - python-unittest2 # standard unit testing library - python-virtualenv # for partioning python projects - pv # "pipe viewer", for nice progressbars in med - exuberant-ctags # required by 'med tags' + #python-software-properties # TODO why do we need this? + #curl # many scripts expect this to fetch urls. + #python-dev # for compiling python modules + #python-setuptools # for installing/making packages + #python-unittest2 # standard unit testing library + #python-virtualenv # for partioning python projects - # geospatial libraries - libgdal1-dev - libgdal1-1.7.0 - libgeos-3.2.2 - libgeos-c1 - libgeos-dev - - python-lxml # TODO why do we need this? - libxml2 # TODO why do we need this? - libxml2-dev # TODO why do we need this? - libxslt1-dev # TODO why do we need this? - - postgresql-9.0 # our database. - postgresql-contrib-9.0 # django wants this - postgresql-server-dev-9.0 # TODO why do we need this? - - # postgresql-9.0-postgis is not available in standard repos, so we install - # my custom package later. - #postgresql-9.0-postgis # utilize geo stuff in postgres - - - # Development helpers that I'm asserting don't need to be installed by - # default for everyone using this thing, they can just install them when - # they need them. - # ack-grep # adreyer thinks you should have it - # ipython # adreyer thinks you should have it - # bpython # nksmith thinks you should have it - # memcached # django can work around not having this - # proj # TODO apt says it is transitional. wtf is it for? - # pyflakes # adreyer thinks you should have it - # pylint # adreyer thinks you should have it - # python-pycryptopp # adreyer thinks you should have it - # virtualenvwrapper # convenience tool - # rabbitmq-server # adreyer thinks you should have it - # vim # adreyer thinks you should have it - - openjdk-7-jre-headless # needed to run solr + #python-lxml # TODO why do we need this? + #libxml2 # TODO why do we need this? + #libxml2-dev # TODO why do we need this? + #libxslt1-dev # TODO why do we need this? EOF + + +# Install Go +go_version="1.2" +go_tarball="go${go_version}.linux-amd64.tar.gz" +go_root=/usr/local/go +go_path=/opt/go + +echo "Installing Go $go_version" +if [ ! $(which go) ]; then + echo " Downloading $go_tarball" + wget --quiet --directory-prefix=/tmp https://go.googlecode.com/files/$go_tarball + + echo " Extracting $go_tarball to $go_root" + sudo tar -C /usr/local -xzf /tmp/$go_tarball + + echo " Configuring GOPATH" + sudo mkdir -p $go_path/src $go_path/bin $go_path/pkg + sudo chown -R vagrant $go_path + + echo " Configuring env vars" + echo "export PATH=\$PATH:$go_root/bin" | sudo tee /etc/profile.d/golang.sh > /dev/null + echo "export GOROOT=$go_root" | sudo tee --append /etc/profile.d/golang.sh > /dev/null + echo "export GOPATH=$go_path" | sudo tee --append /etc/profile.d/golang.sh > /dev/null +fi + + +# Cleanup +sudo apt-get autoremove From f1b3c2a1a31f8c7ceff13610d04762e4b78db8b9 Mon Sep 17 00:00:00 2001 From: Shaun Duncan Date: Thu, 20 Feb 2014 19:22:03 -0500 Subject: [PATCH 3/4] Working vagrant setup --- Vagrantfile | 5 +-- scripts/provision.sh | 79 +++++++++++++++++--------------------------- 2 files changed, 33 insertions(+), 51 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 8b9f489ed..e598a4247 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -19,9 +19,10 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # Drone by default runs on port 80. Forward from host to guest config.vm.network :forwarded_port, guest: 80, host: 8080 + config.vm.network :private_network, ip: "192.168.10.101" - # Sync this repo - config.vm.synced_folder ".", "/opt/drone" + # Sync this repo into what will be $GOPATH + config.vm.synced_folder ".", "/opt/go/src/github.com/drone/drone" # system-level initial setup config.vm.provision "shell", path: "scripts/provision.sh" diff --git a/scripts/provision.sh b/scripts/provision.sh index b5aa2161d..13ab0188a 100644 --- a/scripts/provision.sh +++ b/scripts/provision.sh @@ -14,70 +14,51 @@ else exit 3 fi -# apt-get update. -#if [ -e /root/package-list-updated ]; then -# echo "Skipping package cache update. To force, remove /root/package-list-updated and re-provision." -#else -# echo "Updating package cache." -# sudo apt-get update -qq -# touch /root/package-list-updated -#fi - -# FIXME: Don't run this every time? -sudo apt-get update -qq +# System packages echo "Installing Base Packages" export DEBIAN_FRONTEND=noninteractive -( sed -e 's/#.*$//' | xargs sudo apt-get install -qqy --force-yes ) <<-EOF - build-essential - - # These are needed for go get - bzr - git - mercurial - - # Other - vim - - # Stuff required by medley - #python-software-properties # TODO why do we need this? - #curl # many scripts expect this to fetch urls. - #python-dev # for compiling python modules - #python-setuptools # for installing/making packages - #python-unittest2 # standard unit testing library - #python-virtualenv # for partioning python projects - - #python-lxml # TODO why do we need this? - #libxml2 # TODO why do we need this? - #libxml2-dev # TODO why do we need this? - #libxslt1-dev # TODO why do we need this? -EOF +sudo apt-get update -qq +sudo apt-get install -qqy --force-yes build-essential bzr git mercurial vim # Install Go -go_version="1.2" -go_tarball="go${go_version}.linux-amd64.tar.gz" -go_root=/usr/local/go -go_path=/opt/go +GOVERSION="1.2" +GOTARBALL="go${GOVERSION}.linux-amd64.tar.gz" +export GOROOT=/usr/local/go +export GOPATH=/opt/go +export PATH=$PATH:$GOROOT/bin:$GOPATH/bin -echo "Installing Go $go_version" +echo "Installing Go $GOVERSION" if [ ! $(which go) ]; then - echo " Downloading $go_tarball" - wget --quiet --directory-prefix=/tmp https://go.googlecode.com/files/$go_tarball + echo " Downloading $GOTARBALL" + wget --quiet --directory-prefix=/tmp https://go.googlecode.com/files/$GOTARBALL - echo " Extracting $go_tarball to $go_root" - sudo tar -C /usr/local -xzf /tmp/$go_tarball + echo " Extracting $GOTARBALL to $GOROOT" + sudo tar -C /usr/local -xzf /tmp/$GOTARBALL echo " Configuring GOPATH" - sudo mkdir -p $go_path/src $go_path/bin $go_path/pkg - sudo chown -R vagrant $go_path + sudo mkdir -p $GOPATH/src $GOPATH/bin $GOPATH/pkg + sudo chown -R vagrant $GOPATH echo " Configuring env vars" - echo "export PATH=\$PATH:$go_root/bin" | sudo tee /etc/profile.d/golang.sh > /dev/null - echo "export GOROOT=$go_root" | sudo tee --append /etc/profile.d/golang.sh > /dev/null - echo "export GOPATH=$go_path" | sudo tee --append /etc/profile.d/golang.sh > /dev/null + echo "export PATH=\$PATH:$GOROOT/bin:$GOPATH/bin" | sudo tee /etc/profile.d/golang.sh > /dev/null + echo "export GOROOT=$GOROOT" | sudo tee --append /etc/profile.d/golang.sh > /dev/null + echo "export GOPATH=$GOPATH" | sudo tee --append /etc/profile.d/golang.sh > /dev/null fi +# Install drone +echo "Building Drone" +cd $GOPATH/src/github.com/drone/drone +make deps +make embed +make build +make dpkg + +echo "Installing Drone" +sudo dpkg -i deb/drone.deb + + # Cleanup sudo apt-get autoremove From f9f2e0205e21fe402957151ffa2ab655095944d2 Mon Sep 17 00:00:00 2001 From: Shaun Duncan Date: Mon, 24 Feb 2014 08:41:24 -0500 Subject: [PATCH 4/4] Inlined provisioning script and removed deb gen+install --- Vagrantfile | 62 ++++++++++++++++++++++++++++++++++++++++-- scripts/provision.sh | 64 -------------------------------------------- 2 files changed, 60 insertions(+), 66 deletions(-) delete mode 100644 scripts/provision.sh diff --git a/Vagrantfile b/Vagrantfile index e598a4247..e6ff401e1 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -18,12 +18,70 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| end # Drone by default runs on port 80. Forward from host to guest - config.vm.network :forwarded_port, guest: 80, host: 8080 + config.vm.network :forwarded_port, guest: 8080, host: 8080 config.vm.network :private_network, ip: "192.168.10.101" # Sync this repo into what will be $GOPATH config.vm.synced_folder ".", "/opt/go/src/github.com/drone/drone" # system-level initial setup - config.vm.provision "shell", path: "scripts/provision.sh" + config.vm.provision "shell", inline: <<-EOF + set -e + + # System packages + echo "Installing Base Packages" + export DEBIAN_FRONTEND=noninteractive + sudo apt-get update -qq + sudo apt-get install -qqy --force-yes build-essential bzr git mercurial vim + + + # Install Go + GOVERSION="1.2" + GOTARBALL="go${GOVERSION}.linux-amd64.tar.gz" + export GOROOT=/usr/local/go + export GOPATH=/opt/go + export PATH=$PATH:$GOROOT/bin:$GOPATH/bin + + echo "Installing Go $GOVERSION" + if [ ! $(which go) ]; then + echo " Downloading $GOTARBALL" + wget --quiet --directory-prefix=/tmp https://go.googlecode.com/files/$GOTARBALL + + echo " Extracting $GOTARBALL to $GOROOT" + sudo tar -C /usr/local -xzf /tmp/$GOTARBALL + + echo " Configuring GOPATH" + sudo mkdir -p $GOPATH/src $GOPATH/bin $GOPATH/pkg + sudo chown -R vagrant $GOPATH + + echo " Configuring env vars" + echo "export PATH=\$PATH:$GOROOT/bin:$GOPATH/bin" | sudo tee /etc/profile.d/golang.sh > /dev/null + echo "export GOROOT=$GOROOT" | sudo tee --append /etc/profile.d/golang.sh > /dev/null + echo "export GOPATH=$GOPATH" | sudo tee --append /etc/profile.d/golang.sh > /dev/null + fi + + + # Install drone + echo "Building Drone" + cd $GOPATH/src/github.com/drone/drone + make deps + make embed + make build + + + # Auto cd to drone install dir + echo "cd $GOPATH/src/github.com/drone/drone" >> /home/vagrant/.bashrc + + + # Cleanup + sudo apt-get autoremove + + + echo < /dev/null - echo "export GOROOT=$GOROOT" | sudo tee --append /etc/profile.d/golang.sh > /dev/null - echo "export GOPATH=$GOPATH" | sudo tee --append /etc/profile.d/golang.sh > /dev/null -fi - - -# Install drone -echo "Building Drone" -cd $GOPATH/src/github.com/drone/drone -make deps -make embed -make build -make dpkg - -echo "Installing Drone" -sudo dpkg -i deb/drone.deb - - -# Cleanup -sudo apt-get autoremove