media-sharing: Make the server run from the pi.

The pi server is now at: users/mattr@google.com/media2

Change-Id: Iada863304eb46d6dd457ff32f0af359e485549eb
diff --git a/go/src/v.io/x/media_sharing/mediaserver/mediaserver.go b/go/src/v.io/x/media_sharing/mediaserver/mediaserver.go
index 3b4e17d..5488070 100644
--- a/go/src/v.io/x/media_sharing/mediaserver/mediaserver.go
+++ b/go/src/v.io/x/media_sharing/mediaserver/mediaserver.go
@@ -28,6 +28,13 @@
 )
 
 func main() {
+	// When we run under the device manager, no environment is set up.
+	// We want to have some kind of path.
+	if os.Getenv("PATH") == "" {
+		os.Setenv("PATH", "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin")
+		os.Setenv("HOME", "/home/testuser1")
+	}
+
 	cmdline.Main(root)
 }
 
@@ -93,7 +100,7 @@
 		return nil, err
 	}
 
-	cmd := exec.Command("eog", "-f", tmp.Name())
+	cmd := exec.Command("eog", "--display", ":0", "-f", tmp.Name())
 	stop := func() {
 		if cmd.Process != nil {
 			if err := cmd.Process.Kill(); err != nil {
@@ -118,6 +125,7 @@
 	args := []string{
 		"--no-video-title-show",
 		"--fullscreen",
+		"--x11-display", ":0",
 		"-",
 		"vlc://quit",
 	}
diff --git a/scripts/install.sh b/scripts/install.sh
new file mode 100755
index 0000000..6abc69e
--- /dev/null
+++ b/scripts/install.sh
@@ -0,0 +1,21 @@
+#!/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.
+
+
+hostname="rpi2media"
+
+set -x
+set -e
+
+vbecome -role=identity/role/vlab/admin device associate add vlab/devices/${hostname}/devmgr/device testuser1 dev.v.io/u/mattr@google.com
+
+installation=$(vbecome -role=identity/role/vlab/admin device install vlab/devices/${hostname}/devmgr/apps applications/mediaserver/0)
+
+vbecome --role=identity/role/vlab/admin device acl set -f ${installation} \
+  dev.v.io/role/vlab/admin Admin,Debug,Read,Resolve,Write \
+  dev.v.io/u/mattr@google.com Read
+
+instance=$(device instantiate ${installation} ${hostname})
+device run ${instance}
diff --git a/scripts/setmediaacls.sh b/scripts/setmediaacls.sh
new file mode 100755
index 0000000..8e2f09b
--- /dev/null
+++ b/scripts/setmediaacls.sh
@@ -0,0 +1,35 @@
+#!/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.
+
+set -x
+set -e
+
+namespace permissions set users/mattr@google.com - << EOF
+{
+ "Admin":{
+   "In":["dev.v.io/u/mattr@google.com"]
+ },
+ "Resolve":{
+   "In":["..."]
+ },
+ "Read":{
+   "In":["..."]
+ }
+}
+EOF
+
+namespace permissions set users/mattr@google.com/media2 - << EOF
+{
+ "Admin":{
+   "In":["dev.v.io/u/mattr@google.com"]
+ },
+ "Resolve":{
+   "In":["..."]
+ },
+ "Read":{
+   "In":["..."]
+ }
+}
+EOF
diff --git a/scripts/setvlabacls.sh b/scripts/setvlabacls.sh
new file mode 100755
index 0000000..62c79d8
--- /dev/null
+++ b/scripts/setvlabacls.sh
@@ -0,0 +1,68 @@
+#!/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.
+
+set -x
+set -e
+
+vbecome --role=identity/role/vlab/admin namespace permissions set vlab - << EOF
+{
+ "Admin":{
+   "In":["dev.v.io/role/vlab"]
+ },
+ "Resolve":{
+   "In":["..."]
+ }
+}
+EOF
+
+vbecome --role=identity/role/vlab/admin namespace permissions set vlab/devices - << EOF
+{
+ "Admin":{
+   "In":["dev.v.io/role/vlab"]
+ },
+ "Resolve":{
+   "In":["..."]
+ }
+}
+EOF
+
+vbecome --role=identity/role/vlab/admin namespace permissions set vlab/tunnel - << EOF
+{
+ "Admin":{
+   "In":["dev.v.io/role/vlab"]
+ },
+ "Resolve":{
+   "In":["..."]
+ }
+}
+EOF
+
+vbecome --role=identity/role/vlab/admin namespace permissions set vlab/devices/rpi2media - << EOF
+{
+ "Admin":{
+   "In":["dev.v.io/role/vlab"]
+ },
+ "Resolve":{
+   "In":["..."]
+ },
+ "Read":{
+   "In":["..."]
+ }
+}
+EOF
+
+vbecome --role=identity/role/vlab/admin namespace permissions set vlab/tunnel/rpi2media - << EOF
+{
+ "Admin":{
+   "In":["dev.v.io/role/vlab"]
+ },
+ "Resolve":{
+   "In":["..."]
+ },
+ "Read":{
+   "In":["..."]
+ }
+}
+EOF
diff --git a/scripts/update.sh b/scripts/update.sh
new file mode 100755
index 0000000..8ca52c5
--- /dev/null
+++ b/scripts/update.sh
@@ -0,0 +1,16 @@
+#!/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.
+
+set -x
+set -e
+
+V23_PROFILE=arm v23 go install v.io/x/media_sharing/...
+mkdir -p $V23_ROOT/release/go/bin/linux_arm
+cp $V23_ROOT/release/projects/media-sharing/go/bin/linux_arm/* $V23_ROOT/release/go/bin/linux_arm
+vbecome --role=identity/role/vprod/publisher device publish --goos=linux --goarch=arm mediaserver
+
+installation=$(device ls --installation-state=Active vlab/devices/rpi2media/devmgr/apps/mediaserver/* | tail -n 1)
+
+device updateall $installation