15877: Accept JSON-encoded param values in JSON request body.
[arvados.git] / tools / arvbox / lib / arvbox / docker / service / workbench2 / run-service
1 #!/bin/bash
2 # Copyright (C) The Arvados Authors. All rights reserved.
3 #
4 # SPDX-License-Identifier: AGPL-3.0
5
6 exec 2>&1
7 set -ex -o pipefail
8
9 .  /usr/local/lib/arvbox/common.sh
10
11 cd /usr/src/workbench2
12
13 npm -d install --prefix /usr/local --global yarn@1.17.3
14
15 yarn install
16
17 if test "$1" = "--only-deps" ; then
18     exit
19 fi
20
21 cat <<EOF > /usr/src/workbench2/public/config.json
22 {
23   "API_HOST": "${localip}:${services[controller-ssl]}",
24   "VOCABULARY_URL": "vocabulary-example.json",
25   "FILE_VIEWERS_CONFIG_URL": "file-viewers-example.json"
26 }
27 EOF
28
29 export ARVADOS_API_HOST=$localip:${services[controller-ssl]}
30 export ARVADOS_API_TOKEN=$(cat /var/lib/arvados/superuser_token)
31
32 url_prefix="https://$localip:${services[workbench2-ssl]}/"
33
34 set +e
35 read -rd $'\000' apiclient <<EOF
36 {
37    "url_prefix": "$url_prefix",
38    "is_trusted": true
39 }
40 EOF
41 set -e
42
43 clientuuid=$(arv --format=uuid api_client list --filters '[["url_prefix", "=", "'$url_prefix'"]]')
44 if [[ -n "$clientuuid" ]] ; then
45     arv api_client update --uuid $clientuuid --api-client "$apiclient"
46 else
47     arv api_client create --api-client "$apiclient"
48 fi
49
50 export HTTPS=false
51 # Can't use "yarn start", need to run the dev server script
52 # directly so that the TERM signal from "sv restart" gets to the
53 # right process.
54 exec node node_modules/react-scripts-ts/scripts/start.js