Merge "Parameterize the zone"
diff --git a/create.sh b/create.sh
index d6079ec..98a3cfb 100755
--- a/create.sh
+++ b/create.sh
@@ -27,6 +27,8 @@
 name=pluginbuilder
 
 gcutil --project $project deleteinstance \
+    --force \
+    --delete_boot_pd \
     --zone=$zone \
     $name
 
diff --git a/setup.sh b/setup.sh
index 765a495..5975ff0 100755
--- a/setup.sh
+++ b/setup.sh
@@ -13,6 +13,38 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-# Run this script to set up depencencies
+#
+# This script:
+# * bootstraps the build scripts
+# * installs needed packages and sets up the environment
+# * kicks off a build if requested
 
-apt-get install git-core openjdk-7-jdk ant maven
+
+# Grab the latest files from git and install them
+# if the setup file has changed, rerun it
+apt-get install -y git-core
+oldsetup=/tmp/pb-oldsetup.sh
+path=/usr/pb
+cp $0 $oldsetup
+rm -rf $path
+git clone https://gerrit-review.googlesource.com/plugin-builder $path
+if [ "$(sha1sum $path/setup.sh)" != "$(sha1sum $oldsetup)" ]
+then
+    rm $oldsetup
+    $path/setup.sh $1
+    exit 0
+fi
+
+
+# Install the needed packages and setup the environment
+apt-get install -y gcc openjdk-7-jdk ant maven zip
+rm -rf $path
+echo "0 0 * * * /usr/pb/setup.sh build >> /var/log/pb.log" | crontab -u root
+adduser --uid 1337 --disabled-password --gecos ,,, worker
+
+
+# Kick off a build if requested
+if [ "$1" == build ]
+then
+    su - worker -c "$path/build.sh >> ~/build.log"
+fi