Proposal for avoiding the use of vbash and simplifying how the chat app
starts.

This also means that we fetch credentials specific for the chat app,
which IMHO is a good thing (can be revoked separately, and fits in
better with our model of one principal per application)

Change-Id: I84743ab55d2d1eb0bd37828c72a9f8ce1dad0c3d
diff --git a/.gitignore b/.gitignore
index 8db837f..6ffb93f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,8 @@
 /build
+/clients/shell/credentials
 /clients/shell/go/bin
 /clients/shell/go/pkg
 /node_modules
 /tmp
 /.v23
+
diff --git a/Makefile b/Makefile
index 045cb3a..9d257fc 100644
--- a/Makefile
+++ b/Makefile
@@ -101,7 +101,8 @@
 	$(GO) install \
 	v.io/x/ref/services/mounttable/mounttabled \
 	v.io/x/ref/services/proxy/proxyd \
-	v.io/x/ref/cmd/{principal,vdl}
+	v.io/x/ref/cmd/{principal,vdl} \
+	v.io/x/ref/services/agent/agentd
 
 gen-vdl: vanadium-binaries
 	vdl generate --lang=go v.io/x/chat/vdl
@@ -113,6 +114,9 @@
 
 build-shell: vanadium-binaries clients/shell/go/bin/chat
 
+run-shell: build-shell
+	clients/shell/run.sh
+
 mkdir-build:
 	@mkdir -p build
 
@@ -184,6 +188,7 @@
 clean:
 	rm -rf node_modules
 	rm -rf clients/shell/go/{bin,pkg}
+	rm -rf clients/shell/credentials
 	rm -rf build
 
 lint: node_modules
diff --git a/README.md b/README.md
index 90f8734..fb07a54 100644
--- a/README.md
+++ b/README.md
@@ -23,24 +23,21 @@
 These instructions assume you have an up-to-date [Vanadium development
 environment][vanadium-installation] inside `$V23_ROOT`.
 
-In order to install the shell client, please do the following:
+In order to run the shell client:
 
-1. Build the chat binary.
+    cd $V23_ROOT/release/projects/chat
+    make run-shell
 
-        cd $V23_ROOT/release/projects/chat
-        make build-shell
+This will generate Vanadium credentials (a new principal and a blessing) the
+first time it is run, which may prompt you for your Google Account password and
+caveats on the blessing in your web browser. You will also be prompted to
+select a password for encrypting the credentials on local disk. This is
+optional.
 
-2. Start the Vanadium Security Agent
+If you'd only like to build the binary, not run it:
 
-        $V23_ROOT/release/go/src/v.io/x/ref/cmd/vbash
-
-  You may be prompted for a password, and may have to select blessing caveats
-  in your web browser.
-
-3. Run the chat binary.
-
-        ./clients/shell/go/bin/chat
-
+    cd $V23_ROOT/release/projects/chat
+    make build-shell
 
 <a name="architecture"></a>
 ## Chat architecture
diff --git a/clients/shell/run.sh b/clients/shell/run.sh
new file mode 100755
index 0000000..9691c5a
--- /dev/null
+++ b/clients/shell/run.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+# Copyright 2015 The Vanadium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
+readonly DIR=$(dirname $0)
+export V23_CREDENTIALS="${DIR}/credentials"
+if [[ -d "${DIR}/credentials" ]]
+then
+	agentd "${DIR}/go/bin/chat"
+else
+	agentd bash -c "principal seekblessings && ${DIR}/go/bin/chat"
+fi