Merge "Remove service_account flag"
diff --git a/create.sh b/create.sh
index 069cbf6..dfb8d59 100755
--- a/create.sh
+++ b/create.sh
@@ -15,11 +15,20 @@
 #
 # Run this script to create the pluginbuilder instance
 
+if [ $# != 1 ]
+then
+    echo "Usage: $0 ZONE" 1>&2
+    echo "ZONE suggestion: us-central2-b" 1>&2
+    exit 1
+fi
+
 project=google.com:gerritcodereview-build
-zone=us-central2-b
+zone=$1
 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