[ARVADOS-DEV] updated: 9b59c468d0776e6a7c35b19ed5d0b8f877572c7c

git at public.curoverse.com git at public.curoverse.com
Tue Jan 5 12:04:12 EST 2016


Summary of changes:
 arvbox/arvbox                                      | 20 ++---
 arvbox/docker/Dockerfile                           |  6 +-
 arvbox/docker/common.sh                            |  4 +-
 arvbox/docker/createusers.sh                       | 18 ++++
 arvbox/docker/crunch-setup.sh                      |  2 +-
 arvbox/docker/keep-setup.sh                        |  2 +-
 arvbox/docker/service/api/run                      | 94 +--------------------
 arvbox/docker/service/api/{run => run-service}     |  9 +-
 arvbox/docker/service/crunch0/run                  |  3 +-
 arvbox/docker/service/crunch0/run-service          |  2 +
 arvbox/docker/service/crunch1/run                  |  4 +-
 arvbox/docker/service/crunch1/run-service          |  3 +
 arvbox/docker/service/doc/run                      | 12 +--
 arvbox/docker/service/doc/{run => run-service}     |  2 +-
 arvbox/docker/service/git/run                      | 79 +-----------------
 arvbox/docker/service/git/{run => run-service}     |  6 +-
 arvbox/docker/service/githttp/run                  | 24 +-----
 arvbox/docker/service/githttp/{run => run-service} |  4 +-
 arvbox/docker/service/keep0/run                    |  3 +-
 arvbox/docker/service/keep0/run-service            |  2 +
 arvbox/docker/service/keep1/run                    |  4 +-
 arvbox/docker/service/keep1/run-service            |  3 +
 arvbox/docker/service/keepproxy/run                | 50 +-----------
 .../docker/service/keepproxy/{run => run-service}  |  2 +-
 arvbox/docker/service/keepweb/run                  | 22 +----
 arvbox/docker/service/keepweb/{run => run-service} |  2 +-
 arvbox/docker/service/postgres/run                 | 16 ++--
 arvbox/docker/service/postgres/run-service         | 14 ++++
 arvbox/docker/service/ready/run                    | 95 +---------------------
 arvbox/docker/service/ready/{run => run-service}   | 24 +++---
 arvbox/docker/service/runsu.sh                     | 14 ++++
 arvbox/docker/service/sdk/run                      | 28 +------
 arvbox/docker/service/sdk/{run => run-service}     |  7 +-
 arvbox/docker/service/sso/run                      | 88 +-------------------
 arvbox/docker/service/sso/{run => run-service}     |  9 +-
 arvbox/docker/service/vm/run                       | 47 +----------
 arvbox/docker/service/vm/{run => run-service}      |  2 +-
 arvbox/docker/service/workbench/run                | 35 ++------
 .../docker/service/workbench/{run => run-service}  |  7 +-
 arvbox/docker/tests-service/docker                 |  1 +
 arvbox/docker/tests-service/docker/log/run         |  1 -
 arvbox/docker/tests-service/docker/run             | 95 ----------------------
 arvbox/docker/tests-service/logger                 |  3 +-
 arvbox/docker/tests-service/postgres               |  1 +
 .../tests-service/postgres/log/main/.gitstub       |  0
 arvbox/docker/tests-service/postgres/log/run       |  1 -
 arvbox/docker/tests-service/postgres/run           | 13 ---
 arvbox/docker/tests-service/runsu.sh               |  1 +
 48 files changed, 138 insertions(+), 746 deletions(-)
 create mode 100755 arvbox/docker/createusers.sh
 mode change 100755 => 120000 arvbox/docker/service/api/run
 copy arvbox/docker/service/api/{run => run-service} (87%)
 mode change 100755 => 120000 arvbox/docker/service/crunch0/run
 create mode 100755 arvbox/docker/service/crunch0/run-service
 mode change 100755 => 120000 arvbox/docker/service/crunch1/run
 create mode 100755 arvbox/docker/service/crunch1/run-service
 mode change 100755 => 120000 arvbox/docker/service/doc/run
 copy arvbox/docker/service/doc/{run => run-service} (87%)
 mode change 100755 => 120000 arvbox/docker/service/git/run
 copy arvbox/docker/service/git/{run => run-service} (89%)
 mode change 100755 => 120000 arvbox/docker/service/githttp/run
 copy arvbox/docker/service/githttp/{run => run-service} (73%)
 mode change 100755 => 120000 arvbox/docker/service/keep0/run
 create mode 100755 arvbox/docker/service/keep0/run-service
 mode change 100755 => 120000 arvbox/docker/service/keep1/run
 create mode 100755 arvbox/docker/service/keep1/run-service
 mode change 100755 => 120000 arvbox/docker/service/keepproxy/run
 copy arvbox/docker/service/keepproxy/{run => run-service} (97%)
 mode change 100755 => 120000 arvbox/docker/service/keepweb/run
 copy arvbox/docker/service/keepweb/{run => run-service} (93%)
 create mode 100755 arvbox/docker/service/postgres/run-service
 mode change 100755 => 120000 arvbox/docker/service/ready/run
 copy arvbox/docker/service/ready/{run => run-service} (82%)
 create mode 100755 arvbox/docker/service/runsu.sh
 copy arvbox/docker/service/sdk/{run => run-service} (82%)
 mode change 100755 => 120000 arvbox/docker/service/sso/run
 copy arvbox/docker/service/sso/{run => run-service} (85%)
 mode change 100755 => 120000 arvbox/docker/service/vm/run
 copy arvbox/docker/service/vm/{run => run-service} (97%)
 copy arvbox/docker/service/workbench/{run => run-service} (92%)
 create mode 120000 arvbox/docker/tests-service/docker
 delete mode 120000 arvbox/docker/tests-service/docker/log/run
 delete mode 100755 arvbox/docker/tests-service/docker/run
 mode change 100755 => 120000 arvbox/docker/tests-service/logger
 create mode 120000 arvbox/docker/tests-service/postgres
 delete mode 100644 arvbox/docker/tests-service/postgres/log/main/.gitstub
 delete mode 120000 arvbox/docker/tests-service/postgres/log/run
 delete mode 100755 arvbox/docker/tests-service/postgres/run
 create mode 120000 arvbox/docker/tests-service/runsu.sh

       via  9b59c468d0776e6a7c35b19ed5d0b8f877572c7c (commit)
      from  7dae80945a055453fea5ec85a3c4b1ca160b5c17 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 9b59c468d0776e6a7c35b19ed5d0b8f877572c7c
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Tue Jan 5 12:04:01 2016 -0500

    8080: Now runs most services as regular use instead of root.

diff --git a/arvbox/arvbox b/arvbox/arvbox
index f6e95cb..596d20b 100755
--- a/arvbox/arvbox
+++ b/arvbox/arvbox
@@ -24,12 +24,11 @@ if test -z "$SSO_ROOT" ; then
     SSO_ROOT=$ARVBOX_DATA/sso-devise-omniauth-provider
 fi
 
-PASSENGER=$ARVBOX_DATA/passenger
 PG_DATA=$ARVBOX_DATA/postgres
 VAR_DATA=$ARVBOX_DATA/var
 GEMS=$ARVBOX_DATA/gems
 
-mkdir -p $PASSENGER $PG_DATA $VAR_DATA $GEMS
+mkdir -p $PG_DATA $VAR_DATA $GEMS
 
 run() {
     if ! test -d $ARVADOS_ROOT ; then
@@ -49,7 +48,6 @@ run() {
                --volume=$SSO_ROOT:/usr/src/sso:rw \
                --volume=$PG_DATA:/var/lib/postgresql:rw \
                --volume=$VAR_DATA:/var/lib/arvados:rw \
-               --volume=$PASSENGER:/var/lib/passenger:rw \
                --volume=$GEMS:/var/lib/gems:rw \
                --volume=/var/lib/docker \
                arvados/arvbox \
@@ -63,7 +61,6 @@ run() {
                --volume=$SSO_ROOT:/usr/src/sso:rw \
                --volume=$PG_DATA:/var/lib/postgresql:rw \
                --volume=$VAR_DATA:/var/lib/arvados:rw \
-               --volume=$PASSENGER:/var/lib/passenger:rw \
                --volume=$GEMS:/var/lib/gems:rw \
                --volume=/var/lib/docker \
                arvados/arvbox
@@ -86,7 +83,7 @@ run() {
 stop() {
     if docker ps -a |grep -E "\b$ARVBOX_CONTAINER\b" -q ; then
         docker stop $ARVBOX_CONTAINER
-        docker rm $ARVBOX_CONTAINER
+        docker rm -v $ARVBOX_CONTAINER
     fi
 }
 
@@ -135,13 +132,13 @@ case $1 in
             exit 1
         fi
         stop
-        sudo rm -rf $ARVBOX_DATA
+        rm -rf $ARVBOX_DATA
         ;;
 
     log|svrestart)
         if test -n "$2" ; then
             if test "$1" = log ; then
-                docker exec -ti $ARVBOX_CONTAINER tail -n40 /etc/service/$2/log/main/current
+                docker exec -ti $ARVBOX_CONTAINER tail -n100 /etc/service/$2/log/main/current
             fi
             if test "$1" = svrestart ; then
                 docker exec -ti $ARVBOX_CONTAINER sv restart $2
@@ -164,14 +161,17 @@ case $1 in
         run testing
 
         shift
-        docker exec -ti $ARVBOX_CONTAINER /usr/src/arvados-dev/jenkins/run-tests.sh \
+        docker exec -ti \
+               $ARVBOX_CONTAINER \
+               /etc/tests-service/runsu.sh \
+               /usr/src/arvados-dev/jenkins/run-tests.sh \
                --leave-temp \
                WORKSPACE=/usr/src/arvados \
                VENVDIR=/var/lib/arvados/tests-venv \
                VENV3DIR=/var/lib/arvados/tests-venv3 \
                GOPATH=/var/lib/arvados/tests-gostuff \
-               GEMHOME=/var/lib/gems \
-               GEM_HOME=/var/lib/gems \
+               GEMHOME=/var/lib/gems/ruby/2.1.0 \
+               GEM_HOME=/var/lib/gems/ruby/2.1.0 \
                "$@"
         ;;
 
diff --git a/arvbox/docker/Dockerfile b/arvbox/docker/Dockerfile
index a9c3321..22ad5d2 100644
--- a/arvbox/docker/Dockerfile
+++ b/arvbox/docker/Dockerfile
@@ -29,12 +29,8 @@ RUN cd /root/runit-docker && \
 ENV LD_PRELOAD /lib/runit-docker.so
 
 ADD fuse.conf /etc/
-RUN useradd crunch && \
-    addgroup crunch docker && \
-    mkdir -p /var/lib/arvados/git && \
-    useradd --home-dir /var/lib/arvados/git git
 
-ADD crunch-setup.sh gitolite-setup.sh gitolite.rc gitssh-setup.sh keep-setup.sh common.sh /root/
+ADD crunch-setup.sh gitolite-setup.sh gitolite.rc gitssh-setup.sh keep-setup.sh common.sh createusers.sh /usr/local/lib/arvbox/
 ADD service /etc/service
 ADD tests-service /etc/tests-service
 
diff --git a/arvbox/docker/common.sh b/arvbox/docker/common.sh
index 3bf3293..bc328f7 100644
--- a/arvbox/docker/common.sh
+++ b/arvbox/docker/common.sh
@@ -8,8 +8,8 @@ run_bundler() {
     else
         frozen=""
     fi
-    if ! flock /var/lib/arvados/gems.lock bundle install --local --no-deployment $frozen "$@" ; then
-        flock /var/lib/arvados/gems.lock bundle install --no-deployment $frozen "$@"
+    if ! flock /var/lib/arvados/gems.lock bundle install --path $GEM_HOME --local --no-deployment $frozen "$@" ; then
+        flock /var/lib/arvados/gems.lock bundle install --path $GEM_HOME --no-deployment $frozen "$@"
     fi
 }
 
diff --git a/arvbox/docker/createusers.sh b/arvbox/docker/createusers.sh
new file mode 100755
index 0000000..eda4161
--- /dev/null
+++ b/arvbox/docker/createusers.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+set -e
+
+if ! grep "^arvbox:" /etc/passwd >/dev/null 2>/dev/null ; then
+    HOSTUID=$(ls -nd /usr/src/arvados | sed 's/ */ /' | cut -d' ' -f4)
+    HOSTGID=$(ls -nd /usr/src/arvados | sed 's/ */ /' | cut -d' ' -f5)
+
+    mkdir -p /var/lib/arvados/git
+    groupadd --gid $HOSTGID arvbox
+    groupadd --gid $HOSTGID --non-unique git
+    useradd --home-dir /var/lib/arvados \
+            --uid $HOSTUID --gid $HOSTGID \
+            --groups docker arvbox
+    useradd --home-dir /var/lib/arvados/git --uid $HOSTUID --gid $HOSTGID --non-unique git
+    useradd --groups docker crunch
+    chown arvbox:arvbox -R /usr/local
+fi
diff --git a/arvbox/docker/crunch-setup.sh b/arvbox/docker/crunch-setup.sh
index 4b70250..c52b034 100755
--- a/arvbox/docker/crunch-setup.sh
+++ b/arvbox/docker/crunch-setup.sh
@@ -3,7 +3,7 @@
 exec 2>&1
 set -eux
 
-. /root/common.sh
+. /usr/local/lib/arvbox/common.sh
 
 mkdir -p /var/lib/arvados/gostuff
 cd /var/lib/arvados/gostuff
diff --git a/arvbox/docker/keep-setup.sh b/arvbox/docker/keep-setup.sh
index a4f8832..529360e 100755
--- a/arvbox/docker/keep-setup.sh
+++ b/arvbox/docker/keep-setup.sh
@@ -4,7 +4,7 @@ exec 2>&1
 sleep 2
 set -eux
 
-. /root/common.sh
+. /usr/local/lib/arvbox/common.sh
 
 mkdir -p /var/lib/arvados/gostuff
 cd /var/lib/arvados/gostuff
diff --git a/arvbox/docker/service/api/run b/arvbox/docker/service/api/run
deleted file mode 100755
index 68019e7..0000000
--- a/arvbox/docker/service/api/run
+++ /dev/null
@@ -1,93 +0,0 @@
-#!/bin/sh
-
-exec 2>&1
-set -eux
-
-. /root/common.sh
-
-cd /usr/src/arvados/services/api
-export RAILS_ENV=development
-
-run_bundler --without=development
-
-if ! test -s /var/lib/arvados/api_uuid_prefix ; then
-  ruby -e 'puts "#{rand(2**64).to_s(36)[0,5]}"' > /var/lib/arvados/api_uuid_prefix
-fi
-uuid_prefix=$(cat /var/lib/arvados/api_uuid_prefix)
-
-if ! test -s /var/lib/arvados/api_secret_token ; then
-  ruby -e 'puts rand(2**400).to_s(36)' > /var/lib/arvados/api_secret_token
-fi
-secret_token=$(cat /var/lib/arvados/api_secret_token)
-
-if ! test -s /var/lib/arvados/blob_signing_key ; then
-  ruby -e 'puts rand(2**400).to_s(36)' > /var/lib/arvados/blob_signing_key
-fi
-blob_signing_key=$(cat /var/lib/arvados/blob_signing_key)
-
-# self signed key will be created by SSO server script.
-test -s /var/lib/arvados/self-signed.key
-
-sso_app_secret=$(cat /var/lib/arvados/sso_app_secret)
-
-cat >config/application.yml <<EOF
-common:
-  secret_token: $secret_token
-  blob_signing_key: $blob_signing_key
-  sso_app_secret: $sso_app_secret
-  sso_app_id: arvados-server
-  sso_provider_url: "https://$localip:3002"
-  workbench_address: "http://$localip/"
-  sso_insecure: true
-  auto_admin_first_user: true
-  git_repo_ssh_base: "git@$localip:"
-  git_repo_https_base: "http://$localip:9001/"
-development:
-  uuid_prefix: $uuid_prefix
-test:
-  uuid_prefix: zzzzz
-  git_repo_ssh_base: "git at git.zzzzz.arvadosapi.com:"
-EOF
-
-if ! test -f /var/lib/arvados/api_database_pw ; then
-    ruby -e 'puts rand(2**128).to_s(36)' > /var/lib/arvados/api_database_pw
-fi
-database_pw=$(cat /var/lib/arvados/api_database_pw)
-
-if ! test -f /var/lib/arvados/api_database_setup ; then
-   su postgres -c "psql -c \"create user arvados with password '$database_pw'\""
-   su postgres -c "psql -c \"ALTER USER arvados CREATEDB;\""
-fi
-
-cat >config/database.yml <<EOF
-development:
-  adapter: postgresql
-  encoding: utf8
-  database: arvados_development
-  username: arvados
-  password: $database_pw
-  host: localhost
-  template: template0
-test:
-  adapter: postgresql
-  encoding: utf8
-  database: arvados_test
-  username: arvados
-  password: $database_pw
-  host: localhost
-  template: template0
-EOF
-
-if ! test -f /var/lib/arvados/api_database_setup ; then
-   bundle exec rake db:setup
-   touch /var/lib/arvados/api_database_setup
-fi
-
-if ! test -s /var/lib/arvados/superuser_token ; then
-    bundle exec ./script/create_superuser_token.rb > /var/lib/arvados/superuser_token
-fi
-
-rm -rf tmp
-
-bundle exec rake db:migrate
-ARVADOS_WEBSOCKETS=1 bundle exec passenger start -p3001 --ssl --ssl-certificate=/var/lib/arvados/self-signed.pem --ssl-certificate-key=/var/lib/arvados/self-signed.key
diff --git a/arvbox/docker/service/api/run b/arvbox/docker/service/api/run
new file mode 120000
index 0000000..ef446b5
--- /dev/null
+++ b/arvbox/docker/service/api/run
@@ -0,0 +1 @@
+../runsu.sh
\ No newline at end of file
diff --git a/arvbox/docker/service/api/run b/arvbox/docker/service/api/run-service
similarity index 87%
copy from arvbox/docker/service/api/run
copy to arvbox/docker/service/api/run-service
index 68019e7..5bd8621 100755
--- a/arvbox/docker/service/api/run
+++ b/arvbox/docker/service/api/run-service
@@ -3,7 +3,7 @@
 exec 2>&1
 set -eux
 
-. /root/common.sh
+. /usr/local/lib/arvbox/common.sh
 
 cd /usr/src/arvados/services/api
 export RAILS_ENV=development
@@ -55,8 +55,8 @@ fi
 database_pw=$(cat /var/lib/arvados/api_database_pw)
 
 if ! test -f /var/lib/arvados/api_database_setup ; then
-   su postgres -c "psql -c \"create user arvados with password '$database_pw'\""
-   su postgres -c "psql -c \"ALTER USER arvados CREATEDB;\""
+   psql -c "create user arvados with password '$database_pw'"
+   psql -c "ALTER USER arvados CREATEDB;"
 fi
 
 cat >config/database.yml <<EOF
@@ -90,4 +90,5 @@ fi
 rm -rf tmp
 
 bundle exec rake db:migrate
-ARVADOS_WEBSOCKETS=1 bundle exec passenger start -p3001 --ssl --ssl-certificate=/var/lib/arvados/self-signed.pem --ssl-certificate-key=/var/lib/arvados/self-signed.key
+
+ARVADOS_WEBSOCKETS=1 exec bundle exec passenger start -p3001 --ssl --ssl-certificate=/var/lib/arvados/self-signed.pem --ssl-certificate-key=/var/lib/arvados/self-signed.key
diff --git a/arvbox/docker/service/crunch0/run b/arvbox/docker/service/crunch0/run
deleted file mode 100755
index dd864a0..0000000
--- a/arvbox/docker/service/crunch0/run
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-exec /root/crunch-setup.sh crunch0
diff --git a/arvbox/docker/service/crunch0/run b/arvbox/docker/service/crunch0/run
new file mode 120000
index 0000000..ef446b5
--- /dev/null
+++ b/arvbox/docker/service/crunch0/run
@@ -0,0 +1 @@
+../runsu.sh
\ No newline at end of file
diff --git a/arvbox/docker/service/crunch0/run-service b/arvbox/docker/service/crunch0/run-service
new file mode 100755
index 0000000..fa3a73a
--- /dev/null
+++ b/arvbox/docker/service/crunch0/run-service
@@ -0,0 +1,2 @@
+#!/bin/sh
+exec /usr/local/lib/arvbox/crunch-setup.sh crunch0
diff --git a/arvbox/docker/service/crunch1/run b/arvbox/docker/service/crunch1/run
deleted file mode 100755
index d7583e5..0000000
--- a/arvbox/docker/service/crunch1/run
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-sleep 1
-exec /root/crunch-setup.sh crunch1
diff --git a/arvbox/docker/service/crunch1/run b/arvbox/docker/service/crunch1/run
new file mode 120000
index 0000000..ef446b5
--- /dev/null
+++ b/arvbox/docker/service/crunch1/run
@@ -0,0 +1 @@
+../runsu.sh
\ No newline at end of file
diff --git a/arvbox/docker/service/crunch1/run-service b/arvbox/docker/service/crunch1/run-service
new file mode 100755
index 0000000..6430e9c
--- /dev/null
+++ b/arvbox/docker/service/crunch1/run-service
@@ -0,0 +1,3 @@
+#!/bin/sh
+sleep 1
+exec /usr/local/lib/arvbox/crunch-setup.sh crunch1
diff --git a/arvbox/docker/service/doc/run b/arvbox/docker/service/doc/run
deleted file mode 100755
index e12fdb4..0000000
--- a/arvbox/docker/service/doc/run
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/sh
-
-exec 2>&1
-set -eux
-
-. /root/common.sh
-
-cd /usr/src/arvados/doc
-run_bundler --without=development
-bundle exec rake generate baseurl=http://$localip:8000 arvados_api_host=$localip:3001 arvados_workbench_host=http://$localip
-exec bundle exec rake run
diff --git a/arvbox/docker/service/doc/run b/arvbox/docker/service/doc/run
new file mode 120000
index 0000000..ef446b5
--- /dev/null
+++ b/arvbox/docker/service/doc/run
@@ -0,0 +1 @@
+../runsu.sh
\ No newline at end of file
diff --git a/arvbox/docker/service/doc/run b/arvbox/docker/service/doc/run-service
similarity index 87%
copy from arvbox/docker/service/doc/run
copy to arvbox/docker/service/doc/run-service
index e12fdb4..bb0f0e4 100755
--- a/arvbox/docker/service/doc/run
+++ b/arvbox/docker/service/doc/run-service
@@ -3,7 +3,7 @@
 exec 2>&1
 set -eux
 
-. /root/common.sh
+. /usr/local/lib/arvbox/common.sh
 
 cd /usr/src/arvados/doc
 run_bundler --without=development
diff --git a/arvbox/docker/service/git/run b/arvbox/docker/service/git/run
deleted file mode 100755
index c87c25b..0000000
--- a/arvbox/docker/service/git/run
+++ /dev/null
@@ -1,78 +0,0 @@
-#!/bin/bash
-
-exec 2>&1
-set -eux
-
-. /root/common.sh
-
-mkdir -p /var/lib/arvados/git
-
-export ARVADOS_API_HOST=$localip:3001
-export ARVADOS_API_HOST_INSECURE=1
-export ARVADOS_API_TOKEN=$(cat /var/lib/arvados/superuser_token)
-
-if ! test -f /var/lib/arvados/gitolite-setup ; then
-   cp -r /root/gitolite-setup.sh /root/gitssh-setup.sh /root/gitolite.rc /var/lib/arvados/git/
-
-   chown -R git:git ~git
-
-   su git -c "/var/lib/arvados/git/gitssh-setup.sh"
-   su git -c "/var/lib/arvados/git/gitolite-setup.sh"
-
-   touch /var/lib/arvados/gitolite-setup
-else
-    chown -R git:git ~git
-    su git -c "/var/lib/arvados/git/gitssh-setup.sh"
-fi
-
-prefix=$(arv --format=uuid user current | cut -d- -f1)
-
-if ! test -s /var/lib/arvados/arvados-git-uuid ; then
-    repo_uuid=$(arv --format=uuid repository create --repository "{\"owner_uuid\":\"$prefix-tpzed-000000000000000\", \"name\":\"arvados\"}")
-    echo $repo_uuid > /var/lib/arvados/arvados-git-uuid
-fi
-
-repo_uuid=$(cat /var/lib/arvados/arvados-git-uuid)
-
-if ! test -s /var/lib/arvados/arvados-git-link-uuid ; then
-    all_users_group_uuid="$prefix-j7d0g-fffffffffffffff"
-
-    set +e
-    read -rd $'\000' newlink <<EOF
-{
- "tail_uuid":"$all_users_group_uuid",
- "head_uuid":"$repo_uuid",
- "link_class":"permission",
- "name":"can_read"
-}
-EOF
-    set -e
-    link_uuid=$(arv --format=uuid link create --link "$newlink")
-    echo $link_uuid > /var/lib/arvados/arvados-git-link-uuid
-fi
-
-if ! test -d /var/lib/arvados/git/repositories/$repo_uuid.git ; then
-    git clone --bare /usr/src/arvados /var/lib/arvados/git/repositories/$repo_uuid.git
-else
-    git --git-dir=/var/lib/arvados/git/repositories/$repo_uuid.git fetch -f /usr/src/arvados master:master
-fi
-
-cd /usr/src/arvados/services/api
-export RAILS_ENV=development
-
-git_user_key=$(cat ~git/.ssh/id_rsa.pub)
-
-cat > config/arvados-clients.yml <<EOF
-development:
-  gitolite_url: /var/lib/arvados/git/repositories/gitolite-admin.git
-  gitolite_tmp: /var/lib/arvados/git
-  arvados_api_host: $localip:3001
-  arvados_api_token: "$ARVADOS_API_TOKEN"
-  arvados_api_host_insecure: true
-  gitolite_arvados_git_user_key: "$git_user_key"
-EOF
-
-while true ; do
-    su git -c "bundle exec script/arvados-git-sync.rb development"
-    sleep 120
-done
diff --git a/arvbox/docker/service/git/run b/arvbox/docker/service/git/run
new file mode 120000
index 0000000..ef446b5
--- /dev/null
+++ b/arvbox/docker/service/git/run
@@ -0,0 +1 @@
+../runsu.sh
\ No newline at end of file
diff --git a/arvbox/docker/service/git/run b/arvbox/docker/service/git/run-service
similarity index 89%
copy from arvbox/docker/service/git/run
copy to arvbox/docker/service/git/run-service
index c87c25b..4f08040 100755
--- a/arvbox/docker/service/git/run
+++ b/arvbox/docker/service/git/run-service
@@ -3,7 +3,7 @@
 exec 2>&1
 set -eux
 
-. /root/common.sh
+. /usr/local/lib/arvbox/common.sh
 
 mkdir -p /var/lib/arvados/git
 
@@ -12,7 +12,7 @@ export ARVADOS_API_HOST_INSECURE=1
 export ARVADOS_API_TOKEN=$(cat /var/lib/arvados/superuser_token)
 
 if ! test -f /var/lib/arvados/gitolite-setup ; then
-   cp -r /root/gitolite-setup.sh /root/gitssh-setup.sh /root/gitolite.rc /var/lib/arvados/git/
+   cp -r /usr/local/lib/arvbox/gitolite-setup.sh /usr/local/lib/arvbox/gitssh-setup.sh /usr/local/lib/arvbox/gitolite.rc /var/lib/arvados/git/
 
    chown -R git:git ~git
 
@@ -73,6 +73,6 @@ development:
 EOF
 
 while true ; do
-    su git -c "bundle exec script/arvados-git-sync.rb development"
+    bundle exec script/arvados-git-sync.rb development
     sleep 120
 done
diff --git a/arvbox/docker/service/githttp/run b/arvbox/docker/service/githttp/run
deleted file mode 100755
index 390727d..0000000
--- a/arvbox/docker/service/githttp/run
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/sh
-
-exec 2>&1
-set -eux
-
-. /root/common.sh
-
-mkdir -p /var/lib/arvados/gostuff
-cd /var/lib/arvados/gostuff
-
-export GOPATH=$PWD
-mkdir -p "$GOPATH/src/git.curoverse.com"
-ln -sfn "/usr/src/arvados" "$GOPATH/src/git.curoverse.com/arvados.git"
-go get -t "git.curoverse.com/arvados.git/services/arv-git-httpd"
-install bin/arv-git-httpd /usr/local/bin
-
-export ARVADOS_API_HOST=$localip:3001
-export ARVADOS_API_HOST_INSECURE=1
-export GITOLITE_HTTP_HOME=/var/lib/arvados/git
-export GL_BYPASS_ACCESS_CHECKS=1
-export PATH="$PATH:/var/lib/arvados/git/bin"
-cd ~git
-exec chpst -u git:git /usr/local/bin/arv-git-httpd -address=:9001 -git-command=/var/lib/arvados/git/gitolite/src/gitolite-shell -repo-root=/var/lib/arvados/git/repositories 2>&1
diff --git a/arvbox/docker/service/githttp/run b/arvbox/docker/service/githttp/run
new file mode 120000
index 0000000..ef446b5
--- /dev/null
+++ b/arvbox/docker/service/githttp/run
@@ -0,0 +1 @@
+../runsu.sh
\ No newline at end of file
diff --git a/arvbox/docker/service/githttp/run b/arvbox/docker/service/githttp/run-service
similarity index 73%
copy from arvbox/docker/service/githttp/run
copy to arvbox/docker/service/githttp/run-service
index 390727d..7e4f1de 100755
--- a/arvbox/docker/service/githttp/run
+++ b/arvbox/docker/service/githttp/run-service
@@ -3,7 +3,7 @@
 exec 2>&1
 set -eux
 
-. /root/common.sh
+. /usr/local/lib/arvbox/common.sh
 
 mkdir -p /var/lib/arvados/gostuff
 cd /var/lib/arvados/gostuff
@@ -20,4 +20,4 @@ export GITOLITE_HTTP_HOME=/var/lib/arvados/git
 export GL_BYPASS_ACCESS_CHECKS=1
 export PATH="$PATH:/var/lib/arvados/git/bin"
 cd ~git
-exec chpst -u git:git /usr/local/bin/arv-git-httpd -address=:9001 -git-command=/var/lib/arvados/git/gitolite/src/gitolite-shell -repo-root=/var/lib/arvados/git/repositories 2>&1
+/usr/local/bin/arv-git-httpd -address=:9001 -git-command=/var/lib/arvados/git/gitolite/src/gitolite-shell -repo-root=/var/lib/arvados/git/repositories 2>&1
diff --git a/arvbox/docker/service/keep0/run b/arvbox/docker/service/keep0/run
deleted file mode 100755
index aa5b69c..0000000
--- a/arvbox/docker/service/keep0/run
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-exec /root/keep-setup.sh keep0 25107
\ No newline at end of file
diff --git a/arvbox/docker/service/keep0/run b/arvbox/docker/service/keep0/run
new file mode 120000
index 0000000..ef446b5
--- /dev/null
+++ b/arvbox/docker/service/keep0/run
@@ -0,0 +1 @@
+../runsu.sh
\ No newline at end of file
diff --git a/arvbox/docker/service/keep0/run-service b/arvbox/docker/service/keep0/run-service
new file mode 100755
index 0000000..7f87b88
--- /dev/null
+++ b/arvbox/docker/service/keep0/run-service
@@ -0,0 +1,2 @@
+#!/bin/sh
+exec /usr/local/lib/arvbox/keep-setup.sh keep0 25107
diff --git a/arvbox/docker/service/keep1/run b/arvbox/docker/service/keep1/run
deleted file mode 100755
index 8b0d907..0000000
--- a/arvbox/docker/service/keep1/run
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-sleep 1
-exec /root/keep-setup.sh keep1 25108
diff --git a/arvbox/docker/service/keep1/run b/arvbox/docker/service/keep1/run
new file mode 120000
index 0000000..ef446b5
--- /dev/null
+++ b/arvbox/docker/service/keep1/run
@@ -0,0 +1 @@
+../runsu.sh
\ No newline at end of file
diff --git a/arvbox/docker/service/keep1/run-service b/arvbox/docker/service/keep1/run-service
new file mode 100755
index 0000000..a44c8dd
--- /dev/null
+++ b/arvbox/docker/service/keep1/run-service
@@ -0,0 +1,3 @@
+#!/bin/sh
+sleep 1
+exec /usr/local/lib/arvbox/keep-setup.sh keep1 25108
diff --git a/arvbox/docker/service/keepproxy/run b/arvbox/docker/service/keepproxy/run
deleted file mode 100755
index fe52d6d..0000000
--- a/arvbox/docker/service/keepproxy/run
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/bin/bash
-
-exec 2>&1
-sleep 2
-set -eux
-
-. /root/common.sh
-
-mkdir -p /var/lib/arvados/gostuff
-cd /var/lib/arvados/gostuff
-
-export GOPATH=$PWD
-mkdir -p "$GOPATH/src/git.curoverse.com"
-ln -sfn "/usr/src/arvados" "$GOPATH/src/git.curoverse.com/arvados.git"
-go get -t "git.curoverse.com/arvados.git/services/keepproxy"
-install bin/keepproxy /usr/local/bin
-
-export ARVADOS_API_HOST=$localip:3001
-export ARVADOS_API_HOST_INSECURE=1
-export ARVADOS_API_TOKEN=$(cat /var/lib/arvados/superuser_token)
-
-if test -s /var/lib/arvados/keepproxy-uuid ; then
-    keep_uuid=$(cat /var/lib/arvados/keepproxy-uuid)
-    set +e
-    read -rd $'\000' keepservice <<EOF
-{
- "service_host":"$localip",
- "service_port":25100,
- "service_type":"proxy"
-}
-EOF
-   set -e
-   arv keep_service update --uuid $keep_uuid --keep-service "$keepservice"
-else
-    set +e
-    read -rd $'\000' keepservice <<EOF
-{
- "service_host":"$localip",
- "service_port":25100,
- "service_ssl_flag":false,
- "service_type":"proxy"
-}
-EOF
-    set -e
-    UUID=$(arv --format=uuid keep_service create --keep-service "$keepservice")
-    echo $UUID > /var/lib/arvados/keepproxy-uuid
-fi
-
-exec /usr/local/bin/keepproxy -listen=":25100"
diff --git a/arvbox/docker/service/keepproxy/run b/arvbox/docker/service/keepproxy/run
new file mode 120000
index 0000000..ef446b5
--- /dev/null
+++ b/arvbox/docker/service/keepproxy/run
@@ -0,0 +1 @@
+../runsu.sh
\ No newline at end of file
diff --git a/arvbox/docker/service/keepproxy/run b/arvbox/docker/service/keepproxy/run-service
similarity index 97%
copy from arvbox/docker/service/keepproxy/run
copy to arvbox/docker/service/keepproxy/run-service
index fe52d6d..87b46d9 100755
--- a/arvbox/docker/service/keepproxy/run
+++ b/arvbox/docker/service/keepproxy/run-service
@@ -4,7 +4,7 @@ exec 2>&1
 sleep 2
 set -eux
 
-. /root/common.sh
+. /usr/local/lib/arvbox/common.sh
 
 mkdir -p /var/lib/arvados/gostuff
 cd /var/lib/arvados/gostuff
diff --git a/arvbox/docker/service/keepweb/run b/arvbox/docker/service/keepweb/run
deleted file mode 100755
index ad808fe..0000000
--- a/arvbox/docker/service/keepweb/run
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/sh
-
-exec 2>&1
-set -eux
-
-. /root/common.sh
-
-mkdir -p /var/lib/arvados/gostuff
-cd /var/lib/arvados/gostuff
-
-export GOPATH=$PWD
-mkdir -p "$GOPATH/src/git.curoverse.com"
-ln -sfn "/usr/src/arvados" "$GOPATH/src/git.curoverse.com/arvados.git"
-go get -t "git.curoverse.com/arvados.git/services/keep-web"
-install bin/keep-web /usr/local/bin
-
-export ARVADOS_API_HOST=$localip:3001
-export ARVADOS_API_HOST_INSECURE=1
-export ARVADOS_API_TOKEN=$(cat /var/lib/arvados/superuser_token)
-
-exec /usr/local/bin/keep-web -trust-all-content -listen=":25099"
diff --git a/arvbox/docker/service/keepweb/run b/arvbox/docker/service/keepweb/run
new file mode 120000
index 0000000..ef446b5
--- /dev/null
+++ b/arvbox/docker/service/keepweb/run
@@ -0,0 +1 @@
+../runsu.sh
\ No newline at end of file
diff --git a/arvbox/docker/service/keepweb/run b/arvbox/docker/service/keepweb/run-service
similarity index 93%
copy from arvbox/docker/service/keepweb/run
copy to arvbox/docker/service/keepweb/run-service
index ad808fe..38c31f0 100755
--- a/arvbox/docker/service/keepweb/run
+++ b/arvbox/docker/service/keepweb/run-service
@@ -3,7 +3,7 @@
 exec 2>&1
 set -eux
 
-. /root/common.sh
+. /usr/local/lib/arvbox/common.sh
 
 mkdir -p /var/lib/arvados/gostuff
 cd /var/lib/arvados/gostuff
diff --git a/arvbox/docker/service/postgres/run b/arvbox/docker/service/postgres/run
index 2b7c497..cf8250c 100755
--- a/arvbox/docker/service/postgres/run
+++ b/arvbox/docker/service/postgres/run
@@ -1,13 +1,11 @@
 #!/bin/sh
 
-exec 2>&1
-set -eux
+HOSTUID=$(ls -nd /usr/src/arvados | sed 's/ */ /' | cut -d' ' -f4)
+HOSTGID=$(ls -nd /usr/src/arvados | sed 's/ */ /' | cut -d' ' -f5)
 
-chown postgres:postgres -R /var/lib/postgresql
-if ! test -d /var/lib/postgresql/9.4/main ; then
-   su postgres -c "/usr/lib/postgresql/9.4/bin/initdb -D /var/lib/postgresql/9.4/main"
-fi
-mkdir -p /var/run/postgresql/9.4-main.pg_stat_tmp
-chown postgres:postgres -R /var/run/postgresql
+chown -R $HOSTUID:$HOSTGID /var/lib/postgresql
+chown -R $HOSTUID:$HOSTGID /var/run/postgresql
+chown -R $HOSTUID:$HOSTGID /etc/postgresql
+chown -R $HOSTUID:$HOSTGID /etc/ssl/private
 
-exec su postgres -c "/usr/lib/postgresql/9.4/bin/postgres -D /var/lib/postgresql/9.4/main -c config_file=/etc/postgresql/9.4/main/postgresql.conf"
+exec chpst -u:$HOSTUID:$HOSTGID $0-service
diff --git a/arvbox/docker/service/postgres/run-service b/arvbox/docker/service/postgres/run-service
new file mode 100755
index 0000000..6f72ba6
--- /dev/null
+++ b/arvbox/docker/service/postgres/run-service
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+exec 2>&1
+set -eux
+
+if ! test -d /var/lib/postgresql/9.4/main ; then
+    /usr/lib/postgresql/9.4/bin/initdb -D /var/lib/postgresql/9.4/main
+    sh -c "while ! createdb ; do sleep 1 ; done" &
+fi
+mkdir -p /var/run/postgresql/9.4-main.pg_stat_tmp
+
+rm -f /var/lib/postgresql/9.4/main/postmaster.pid
+
+exec /usr/lib/postgresql/9.4/bin/postgres -D /var/lib/postgresql/9.4/main -c config_file=/etc/postgresql/9.4/main/postgresql.conf
diff --git a/arvbox/docker/service/ready/run b/arvbox/docker/service/ready/run
deleted file mode 100755
index 41732fd..0000000
--- a/arvbox/docker/service/ready/run
+++ /dev/null
@@ -1,94 +0,0 @@
-#!/bin/bash
-
-. /root/common.sh
-
-set -eu
-
-if ! [[ -d /root/ready ]] ; then
-   echo
-   echo "Arvados-in-a-box starting"
-   echo
-   echo "Note: if this is a fresh arvbox installation, it may take 10-15 minutes to download and"
-   echo "install dependencies.  Use \"arvbox log\" to monitor the progress of specific services."
-   echo
-   mkdir -p /root/ready
-fi
-
-sleep 2
-
-declare -A services
-services=(
-  [workbench]=80
-  [api]=3001
-  [sso]=3002
-  [githttp]=9001
-  [keepweb]=25099
-  [keepproxy]=25100
-  [keep0]=25107
-  [keep1]=25108
-  [ssh]=22
-  [doc]=8000
-)
-
-waiting=""
-
-. /root/common.sh
-
-for s in "${!services[@]}"
-do
-  if ! [[ -f /root/ready/$s ]] ; then
-    if nc -z $localip ${services[$s]} ; then
-      echo "$s is ready at $localip:${services[$s]}"
-      touch /root/ready/$s
-    else
-      waiting="$waiting $s"
-    fi
-  fi
-done
-
-if ! docker version >/dev/null 2>/dev/null ; then
-  waiting="$waiting docker"
-fi
-
-if ! which arv >/dev/null ; then
-  waiting="$waiting ruby_sdk"
-fi
-
-if ! which arv-get >/dev/null ; then
-  waiting="$waiting python_sdk"
-fi
-
-if ! [[ -z "$waiting" ]] ; then
-    if ps x | grep -v grep | grep "bundle install" > /dev/null; then
-        gemcount=$(ls /var/lib/gems/gems 2>/dev/null | wc -l)
-
-        gemlockcount=0
-        for l in /usr/src/arvados/services/api/Gemfile.lock \
-                     /usr/src/arvados/apps/workbench/Gemfile.lock \
-                     /usr/src/sso/Gemfile.lock ; do
-            gc=$(cat $l \
-                        | grep -vE "(GEM|PLATFORMS|DEPENDENCIES|$^|remote:|specs:)" \
-                        | sed 's/^ *//' | sed 's/(.*)//' | sed 's/ *$//' | sort | uniq | wc -l)
-            gemlockcount=$(($gemlockcount + $gc))
-        done
-        waiting="$waiting (installing ruby gems $gemcount/$gemlockcount)"
-    fi
-
-    if ps x | grep -v grep | grep "c++.*/var/lib/passenger" > /dev/null ; then
-        waiting="$waiting (compiling passenger)"
-    fi
-
-    if ps x | grep -v grep | grep "pip install" > /dev/null; then
-        waiting="$waiting (installing python packages)"
-    fi
-    echo "    Waiting for$waiting ..."
-    exit 1
-fi
-
-echo
-echo "Your Arvados-in-a-box is ready!"
-echo "Workbench is running at http://$localip"
-
-rm -r /root/ready
-
-sv stop ready >/dev/null
diff --git a/arvbox/docker/service/ready/run b/arvbox/docker/service/ready/run
new file mode 120000
index 0000000..ef446b5
--- /dev/null
+++ b/arvbox/docker/service/ready/run
@@ -0,0 +1 @@
+../runsu.sh
\ No newline at end of file
diff --git a/arvbox/docker/service/ready/run b/arvbox/docker/service/ready/run-service
similarity index 82%
copy from arvbox/docker/service/ready/run
copy to arvbox/docker/service/ready/run-service
index 41732fd..e99570b 100755
--- a/arvbox/docker/service/ready/run
+++ b/arvbox/docker/service/ready/run-service
@@ -1,17 +1,17 @@
 #!/bin/bash
 
-. /root/common.sh
+. /usr/local/lib/arvbox/common.sh
 
 set -eu
 
-if ! [[ -d /root/ready ]] ; then
+if ! [[ -d /tmp/arvbox-ready ]] ; then
    echo
    echo "Arvados-in-a-box starting"
    echo
    echo "Note: if this is a fresh arvbox installation, it may take 10-15 minutes to download and"
    echo "install dependencies.  Use \"arvbox log\" to monitor the progress of specific services."
    echo
-   mkdir -p /root/ready
+   mkdir -p /tmp/arvbox-ready
 fi
 
 sleep 2
@@ -32,14 +32,14 @@ services=(
 
 waiting=""
 
-. /root/common.sh
+. /usr/local/lib/arvbox/common.sh
 
 for s in "${!services[@]}"
 do
-  if ! [[ -f /root/ready/$s ]] ; then
+  if ! [[ -f /tmp/arvbox-ready/$s ]] ; then
     if nc -z $localip ${services[$s]} ; then
       echo "$s is ready at $localip:${services[$s]}"
-      touch /root/ready/$s
+      touch /tmp/arvbox-ready/$s
     else
       waiting="$waiting $s"
     fi
@@ -51,16 +51,14 @@ if ! docker version >/dev/null 2>/dev/null ; then
 fi
 
 if ! which arv >/dev/null ; then
-  waiting="$waiting ruby_sdk"
-fi
-
-if ! which arv-get >/dev/null ; then
-  waiting="$waiting python_sdk"
+  waiting="$waiting sdk"
+elif ! which arv-get >/dev/null ; then
+  waiting="$waiting sdk"
 fi
 
 if ! [[ -z "$waiting" ]] ; then
     if ps x | grep -v grep | grep "bundle install" > /dev/null; then
-        gemcount=$(ls /var/lib/gems/gems 2>/dev/null | wc -l)
+        gemcount=$(ls /var/lib/gems/ruby/2.1.0/gems 2>/dev/null | wc -l)
 
         gemlockcount=0
         for l in /usr/src/arvados/services/api/Gemfile.lock \
@@ -89,6 +87,6 @@ echo
 echo "Your Arvados-in-a-box is ready!"
 echo "Workbench is running at http://$localip"
 
-rm -r /root/ready
+rm -r /tmp/arvbox-ready
 
 sv stop ready >/dev/null
diff --git a/arvbox/docker/service/runsu.sh b/arvbox/docker/service/runsu.sh
new file mode 100755
index 0000000..329067f
--- /dev/null
+++ b/arvbox/docker/service/runsu.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+HOSTUID=$(ls -nd /usr/src/arvados | sed 's/ */ /' | cut -d' ' -f4)
+HOSTGID=$(ls -nd /usr/src/arvados | sed 's/ */ /' | cut -d' ' -f5)
+
+flock /var/lib/arvados/createusers.lock /usr/local/lib/arvbox/createusers.sh
+
+export HOME=/var/lib/arvados
+
+if test -z "$1" ; then
+    exec su arvbox -c -- "exec $0-service"
+else
+    exec su arvbox --shell /bin/bash -- $@
+fi
diff --git a/arvbox/docker/service/sdk/run b/arvbox/docker/service/sdk/run
index e5e8880..e6c844d 100755
--- a/arvbox/docker/service/sdk/run
+++ b/arvbox/docker/service/sdk/run
@@ -1,27 +1,5 @@
-#!/bin/bash
-
-exec 2>&1
-set -eux
-
-. /root/common.sh
-
-mkdir -p ~/.pip /var/lib/arvados/pip
-cat > ~/.pip/pip.conf <<EOF
-[global]
-download_cache = /var/lib/arvados/pip
-EOF
-
-cd /usr/src/arvados/sdk/cli
-run_bundler --binstubs=$PWD/binstubs
-ln -sf /usr/src/arvados/sdk/cli/binstubs/arv /usr/bin/arv
-
-
-cd /usr/src/arvados/sdk/python
-python setup.py sdist
-pip_install $(ls dist/arvados-python-client-*.tar.gz | tail -n1)
-
-cd /usr/src/arvados/services/fuse
-python setup.py sdist
-pip_install $(ls dist/arvados_fuse-*.tar.gz | tail -n1)
+#!/bin/sh
+set -e
 
+/etc/service/runsu.sh $0-service
 sv stop sdk
diff --git a/arvbox/docker/service/sdk/run b/arvbox/docker/service/sdk/run-service
similarity index 82%
copy from arvbox/docker/service/sdk/run
copy to arvbox/docker/service/sdk/run-service
index e5e8880..fd376ba 100755
--- a/arvbox/docker/service/sdk/run
+++ b/arvbox/docker/service/sdk/run-service
@@ -3,7 +3,7 @@
 exec 2>&1
 set -eux
 
-. /root/common.sh
+. /usr/local/lib/arvbox/common.sh
 
 mkdir -p ~/.pip /var/lib/arvados/pip
 cat > ~/.pip/pip.conf <<EOF
@@ -13,8 +13,7 @@ EOF
 
 cd /usr/src/arvados/sdk/cli
 run_bundler --binstubs=$PWD/binstubs
-ln -sf /usr/src/arvados/sdk/cli/binstubs/arv /usr/bin/arv
-
+ln -sf /usr/src/arvados/sdk/cli/binstubs/arv /usr/local/bin/arv
 
 cd /usr/src/arvados/sdk/python
 python setup.py sdist
@@ -23,5 +22,3 @@ pip_install $(ls dist/arvados-python-client-*.tar.gz | tail -n1)
 cd /usr/src/arvados/services/fuse
 python setup.py sdist
 pip_install $(ls dist/arvados_fuse-*.tar.gz | tail -n1)
-
-sv stop sdk
diff --git a/arvbox/docker/service/sso/run b/arvbox/docker/service/sso/run
deleted file mode 100755
index 73f6df5..0000000
--- a/arvbox/docker/service/sso/run
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/bin/sh
-
-exec 2>&1
-set -eux
-
-. /root/common.sh
-
-cd /usr/src/sso
-export RAILS_ENV=development
-export GEM_HOME=/var/lib/gems
-
-run_bundler --without=development
-
-if ! test -s /var/lib/arvados/sso_uuid_prefix ; then
-  ruby -e 'puts "#{rand(2**64).to_s(36)[0,5]}"' > /var/lib/arvados/sso_uuid_prefix
-fi
-uuid_prefix=$(cat /var/lib/arvados/sso_uuid_prefix)
-
-if ! test -s /var/lib/arvados/sso_secret_token ; then
-  ruby -e 'puts rand(2**400).to_s(36)' > /var/lib/arvados/sso_secret_token
-fi
-secret_token=$(cat /var/lib/arvados/sso_secret_token)
-
-if ! test -s /var/lib/arvados/self-signed.key ; then
-  openssl req -new -x509 -nodes -out /var/lib/arvados/self-signed.pem -keyout /var/lib/arvados/self-signed.key -days 365 -subj '/CN=localhost'
-fi
-
-cat >config/application.yml <<EOF
-common:
-  uuid_prefix: $uuid_prefix
-  secret_token: $secret_token
-  default_link_url: "http://$localip"
-  allow_account_registration: true
-EOF
-
-if ! test -f /var/lib/arvados/sso_database_pw ; then
-    ruby -e 'puts rand(2**128).to_s(36)' > /var/lib/arvados/sso_database_pw
-fi
-database_pw=$(cat /var/lib/arvados/sso_database_pw)
-
-if ! test -f /var/lib/arvados/sso_database_setup ; then
-    su postgres -c "psql -c \"create user arvados_sso with password '$database_pw'\""
-    su postgres -c "psql -c \"ALTER USER arvados_sso CREATEDB;\""
-fi
-
-cat >config/database.yml <<EOF
-development:
-  adapter: postgresql
-  encoding: utf8
-  database: arvados_sso_development
-  username: arvados_sso
-  password: $database_pw
-  host: localhost
-  template: template0
-test:
-  adapter: postgresql
-  encoding: utf8
-  database: arvados_sso_test
-  username: arvados_sso
-  password: $database_pw
-  host: localhost
-  template: template0
-EOF
-
-if ! test -f /var/lib/arvados/sso_database_setup ; then
-   bundle exec rake db:setup
-
-   if ! test -s /var/lib/arvados/sso_app_secret ; then
-       ruby -e 'puts rand(2**400).to_s(36)' > /var/lib/arvados/sso_app_secret
-   fi
-   app_secret=$(cat /var/lib/arvados/sso_app_secret)
-
-   bundle exec rails console <<EOF
-c = Client.new
-c.name = "joshid"
-c.app_id = "arvados-server"
-c.app_secret = "$app_secret"
-c.save!
-EOF
-
-   touch /var/lib/arvados/sso_database_setup
-fi
-
-rm -rf tmp
-
-bundle exec rake db:migrate
-bundle exec passenger start -p3002 --ssl --ssl-certificate=/var/lib/arvados/self-signed.pem --ssl-certificate-key=/var/lib/arvados/self-signed.key
diff --git a/arvbox/docker/service/sso/run b/arvbox/docker/service/sso/run
new file mode 120000
index 0000000..ef446b5
--- /dev/null
+++ b/arvbox/docker/service/sso/run
@@ -0,0 +1 @@
+../runsu.sh
\ No newline at end of file
diff --git a/arvbox/docker/service/sso/run b/arvbox/docker/service/sso/run-service
similarity index 85%
copy from arvbox/docker/service/sso/run
copy to arvbox/docker/service/sso/run-service
index 73f6df5..085b79a 100755
--- a/arvbox/docker/service/sso/run
+++ b/arvbox/docker/service/sso/run-service
@@ -3,7 +3,7 @@
 exec 2>&1
 set -eux
 
-. /root/common.sh
+. /usr/local/lib/arvbox/common.sh
 
 cd /usr/src/sso
 export RAILS_ENV=development
@@ -39,8 +39,8 @@ fi
 database_pw=$(cat /var/lib/arvados/sso_database_pw)
 
 if ! test -f /var/lib/arvados/sso_database_setup ; then
-    su postgres -c "psql -c \"create user arvados_sso with password '$database_pw'\""
-    su postgres -c "psql -c \"ALTER USER arvados_sso CREATEDB;\""
+    psql -c "create user arvados_sso with password '$database_pw'"
+    psql -c "ALTER USER arvados_sso CREATEDB;"
 fi
 
 cat >config/database.yml <<EOF
@@ -84,4 +84,5 @@ fi
 rm -rf tmp
 
 bundle exec rake db:migrate
-bundle exec passenger start -p3002 --ssl --ssl-certificate=/var/lib/arvados/self-signed.pem --ssl-certificate-key=/var/lib/arvados/self-signed.key
+export HOME=/var/lib/passenger
+exec bundle exec passenger start -p3002 --ssl --ssl-certificate=/var/lib/arvados/self-signed.pem --ssl-certificate-key=/var/lib/arvados/self-signed.key
diff --git a/arvbox/docker/service/vm/run b/arvbox/docker/service/vm/run
deleted file mode 100755
index 807d976..0000000
--- a/arvbox/docker/service/vm/run
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/bin/bash
-
-exec 2>&1
-sleep 2
-set -eux
-
-. /root/common.sh
-
-git config --system "credential.http://$localip:9001/.username" none
-git config --system "credential.http://$localip:9001/.helper" '!cred(){ cat >/dev/null; if [ "$1" = get ]; then echo password=$ARVADOS_API_TOKEN; fi; };cred'
-
-export ARVADOS_API_HOST=$localip:3001
-export ARVADOS_API_HOST_INSECURE=1
-export ARVADOS_API_TOKEN=$(cat /var/lib/arvados/superuser_token)
-
-if test -s /var/lib/arvados/vm-uuid ; then
-    ARVADOS_VIRTUAL_MACHINE_UUID=$(cat /var/lib/arvados/vm-uuid)
-    set +e
-    read -rd $'\000' vm <<EOF
-{
- "hostname":"$localip"
-}
-EOF
-    set -e
-    arv virtual_machine update --uuid $ARVADOS_VIRTUAL_MACHINE_UUID --virtual-machine "$vm"
-else
-    set +e
-    read -rd $'\000' vm <<EOF
-{
- "hostname":"$localip"
-}
-EOF
-    set -e
-    ARVADOS_VIRTUAL_MACHINE_UUID=$(arv --format=uuid virtual_machine create --virtual-machine "$vm")
-    echo $ARVADOS_VIRTUAL_MACHINE_UUID > /var/lib/arvados/vm-uuid
-fi
-
-export ARVADOS_VIRTUAL_MACHINE_UUID
-
-cd /usr/src/arvados/services/login-sync
-run_bundler
-
-while true ; do
-      bundle exec arvados-login-sync
-      sleep 120
-done
diff --git a/arvbox/docker/service/vm/run b/arvbox/docker/service/vm/run
new file mode 120000
index 0000000..ef446b5
--- /dev/null
+++ b/arvbox/docker/service/vm/run
@@ -0,0 +1 @@
+../runsu.sh
\ No newline at end of file
diff --git a/arvbox/docker/service/vm/run b/arvbox/docker/service/vm/run-service
similarity index 97%
copy from arvbox/docker/service/vm/run
copy to arvbox/docker/service/vm/run-service
index 807d976..f6844d8 100755
--- a/arvbox/docker/service/vm/run
+++ b/arvbox/docker/service/vm/run-service
@@ -4,7 +4,7 @@ exec 2>&1
 sleep 2
 set -eux
 
-. /root/common.sh
+. /usr/local/lib/arvbox/common.sh
 
 git config --system "credential.http://$localip:9001/.username" none
 git config --system "credential.http://$localip:9001/.helper" '!cred(){ cat >/dev/null; if [ "$1" = get ]; then echo password=$ARVADOS_API_TOKEN; fi; };cred'
diff --git a/arvbox/docker/service/workbench/run b/arvbox/docker/service/workbench/run
index ccdbc54..7838220 100755
--- a/arvbox/docker/service/workbench/run
+++ b/arvbox/docker/service/workbench/run
@@ -1,37 +1,12 @@
 #!/bin/sh
+set -e
 
-exec 2>&1
-set -eux
-
-. /root/common.sh
+/etc/service/runsu.sh $0-service
 
 cd /usr/src/arvados/apps/workbench
-export RAILS_ENV=development
-export GEM_HOME=/var/lib/gems
-
-run_bundler --without=development
-
-if ! test -s /var/lib/arvados/workbench_secret_token ; then
-  ruby -e 'puts rand(2**400).to_s(36)' > /var/lib/arvados/workbench_secret_token
-fi
-secret_token=$(cat /var/lib/arvados/workbench_secret_token)
-
-if ! test -s self-signed.key ; then
-  openssl req -new -x509 -nodes -out self-signed.pem -keyout self-signed.key -days 365 -subj '/CN=localhost'
-fi
-
-cat >config/application.yml <<EOF
-common:
-  secret_token: $secret_token
-  arvados_login_base: https://$localip:3001/login
-  arvados_v1_base: https://$localip:3001/arvados/v1
-  arvados_insecure_https: true
-  keep_web_download_url: http://$localip:25099/c=%{uuid_or_pdh}
-  keep_web_url: http://$localip:25099/c=%{uuid_or_pdh}
-  arvados_docsite: http://$localip:8000/
-EOF
 
 rm -rf tmp
+mkdir tmp
+chown arvbox:arvbox tmp
 
-#bundle exec passenger start -p443 --ssl --ssl-certificate=self-signed.pem --ssl-certificate-key=self-signed.key
-bundle exec passenger start -p80
+exec bundle exec passenger start --port 80 --user arvbox
diff --git a/arvbox/docker/service/workbench/run b/arvbox/docker/service/workbench/run-service
similarity index 92%
copy from arvbox/docker/service/workbench/run
copy to arvbox/docker/service/workbench/run-service
index ccdbc54..09f929f 100755
--- a/arvbox/docker/service/workbench/run
+++ b/arvbox/docker/service/workbench/run-service
@@ -3,7 +3,7 @@
 exec 2>&1
 set -eux
 
-. /root/common.sh
+.  /usr/local/lib/arvbox/common.sh
 
 cd /usr/src/arvados/apps/workbench
 export RAILS_ENV=development
@@ -31,7 +31,6 @@ common:
   arvados_docsite: http://$localip:8000/
 EOF
 
-rm -rf tmp
-
 #bundle exec passenger start -p443 --ssl --ssl-certificate=self-signed.pem --ssl-certificate-key=self-signed.key
-bundle exec passenger start -p80
+
+bundle exec passenger start --runtime-check-only
diff --git a/arvbox/docker/tests-service/docker b/arvbox/docker/tests-service/docker
new file mode 120000
index 0000000..9374f25
--- /dev/null
+++ b/arvbox/docker/tests-service/docker
@@ -0,0 +1 @@
+../service/docker
\ No newline at end of file
diff --git a/arvbox/docker/tests-service/docker/log/run b/arvbox/docker/tests-service/docker/log/run
deleted file mode 120000
index f99cc1d..0000000
--- a/arvbox/docker/tests-service/docker/log/run
+++ /dev/null
@@ -1 +0,0 @@
-../../logger
\ No newline at end of file
diff --git a/arvbox/docker/tests-service/docker/run b/arvbox/docker/tests-service/docker/run
deleted file mode 100755
index 99540e6..0000000
--- a/arvbox/docker/tests-service/docker/run
+++ /dev/null
@@ -1,95 +0,0 @@
-#!/bin/bash
-
-# Taken from https://github.com/jpetazzo/dind
-
-exec 2>&1
-
-#!/bin/bash
-
-# Ensure that all nodes in /dev/mapper correspond to mapped devices currently loaded by the device-mapper kernel driver
-dmsetup mknodes
-
-# First, make sure that cgroups are mounted correctly.
-CGROUP=/sys/fs/cgroup
-: {LOG:=stdio}
-
-[ -d $CGROUP ] ||
-	mkdir $CGROUP
-
-mountpoint -q $CGROUP ||
-	mount -n -t tmpfs -o uid=0,gid=0,mode=0755 cgroup $CGROUP || {
-		echo "Could not make a tmpfs mount. Did you use --privileged?"
-		exit 1
-	}
-
-if [ -d /sys/kernel/security ] && ! mountpoint -q /sys/kernel/security
-then
-    mount -t securityfs none /sys/kernel/security || {
-        echo "Could not mount /sys/kernel/security."
-        echo "AppArmor detection and --privileged mode might break."
-    }
-fi
-
-# Mount the cgroup hierarchies exactly as they are in the parent system.
-for SUBSYS in $(cut -d: -f2 /proc/1/cgroup)
-do
-        [ -d $CGROUP/$SUBSYS ] || mkdir $CGROUP/$SUBSYS
-        mountpoint -q $CGROUP/$SUBSYS ||
-                mount -n -t cgroup -o $SUBSYS cgroup $CGROUP/$SUBSYS
-
-        # The two following sections address a bug which manifests itself
-        # by a cryptic "lxc-start: no ns_cgroup option specified" when
-        # trying to start containers withina container.
-        # The bug seems to appear when the cgroup hierarchies are not
-        # mounted on the exact same directories in the host, and in the
-        # container.
-
-        # Named, control-less cgroups are mounted with "-o name=foo"
-        # (and appear as such under /proc/<pid>/cgroup) but are usually
-        # mounted on a directory named "foo" (without the "name=" prefix).
-        # Systemd and OpenRC (and possibly others) both create such a
-        # cgroup. To avoid the aforementioned bug, we symlink "foo" to
-        # "name=foo". This shouldn't have any adverse effect.
-        echo $SUBSYS | grep -q ^name= && {
-                NAME=$(echo $SUBSYS | sed s/^name=//)
-                ln -s $SUBSYS $CGROUP/$NAME
-        }
-
-        # Likewise, on at least one system, it has been reported that
-        # systemd would mount the CPU and CPU accounting controllers
-        # (respectively "cpu" and "cpuacct") with "-o cpuacct,cpu"
-        # but on a directory called "cpu,cpuacct" (note the inversion
-        # in the order of the groups). This tries to work around it.
-        [ $SUBSYS = cpuacct,cpu ] && ln -s $SUBSYS $CGROUP/cpu,cpuacct
-done
-
-# Note: as I write those lines, the LXC userland tools cannot setup
-# a "sub-container" properly if the "devices" cgroup is not in its
-# own hierarchy. Let's detect this and issue a warning.
-grep -q :devices: /proc/1/cgroup ||
-	echo "WARNING: the 'devices' cgroup should be in its own hierarchy."
-grep -qw devices /proc/1/cgroup ||
-	echo "WARNING: it looks like the 'devices' cgroup is not mounted."
-
-# Now, close extraneous file descriptors.
-pushd /proc/self/fd >/dev/null
-for FD in *
-do
-	case "$FD" in
-	# Keep stdin/stdout/stderr
-	[012])
-		;;
-	# Nuke everything else
-	*)
-		eval exec "$FD>&-"
-		;;
-	esac
-done
-popd >/dev/null
-
-
-# If a pidfile is still around (for example after a container restart),
-# delete it so that docker can start.
-rm -rf /var/run/docker.pid
-
-exec docker daemon --storage-driver=overlay $DOCKER_DAEMON_ARGS
diff --git a/arvbox/docker/tests-service/logger b/arvbox/docker/tests-service/logger
deleted file mode 100755
index a79a518..0000000
--- a/arvbox/docker/tests-service/logger
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-exec svlogd -tt ./main
diff --git a/arvbox/docker/tests-service/logger b/arvbox/docker/tests-service/logger
new file mode 120000
index 0000000..b30194b
--- /dev/null
+++ b/arvbox/docker/tests-service/logger
@@ -0,0 +1 @@
+../service/logger
\ No newline at end of file
diff --git a/arvbox/docker/tests-service/postgres b/arvbox/docker/tests-service/postgres
new file mode 120000
index 0000000..9b2d8a0
--- /dev/null
+++ b/arvbox/docker/tests-service/postgres
@@ -0,0 +1 @@
+../service/postgres
\ No newline at end of file
diff --git a/arvbox/docker/tests-service/postgres/log/main/.gitstub b/arvbox/docker/tests-service/postgres/log/main/.gitstub
deleted file mode 100644
index e69de29..0000000
diff --git a/arvbox/docker/tests-service/postgres/log/run b/arvbox/docker/tests-service/postgres/log/run
deleted file mode 120000
index f99cc1d..0000000
--- a/arvbox/docker/tests-service/postgres/log/run
+++ /dev/null
@@ -1 +0,0 @@
-../../logger
\ No newline at end of file
diff --git a/arvbox/docker/tests-service/postgres/run b/arvbox/docker/tests-service/postgres/run
deleted file mode 100755
index 2b7c497..0000000
--- a/arvbox/docker/tests-service/postgres/run
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/sh
-
-exec 2>&1
-set -eux
-
-chown postgres:postgres -R /var/lib/postgresql
-if ! test -d /var/lib/postgresql/9.4/main ; then
-   su postgres -c "/usr/lib/postgresql/9.4/bin/initdb -D /var/lib/postgresql/9.4/main"
-fi
-mkdir -p /var/run/postgresql/9.4-main.pg_stat_tmp
-chown postgres:postgres -R /var/run/postgresql
-
-exec su postgres -c "/usr/lib/postgresql/9.4/bin/postgres -D /var/lib/postgresql/9.4/main -c config_file=/etc/postgresql/9.4/main/postgresql.conf"
diff --git a/arvbox/docker/tests-service/runsu.sh b/arvbox/docker/tests-service/runsu.sh
new file mode 120000
index 0000000..22030b0
--- /dev/null
+++ b/arvbox/docker/tests-service/runsu.sh
@@ -0,0 +1 @@
+../service/runsu.sh
\ No newline at end of file

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list