3 # Copyright (C) The Arvados Authors. All rights reserved.
5 # SPDX-License-Identifier: AGPL-3.0
11 read -d] -r SCOPES <<EOF
13 '["GET /arvados/v1/virtual_machines",\n
14 "GET /arvados/v1/keep_services",\n
15 "GET /arvados/v1/keep_services/",\n
16 "GET /arvados/v1/groups",\n
17 "GET /arvados/v1/groups/",\n
18 "GET /arvados/v1/links",\n
19 "GET /arvados/v1/collections",\n
20 "POST /arvados/v1/collections",\n
21 "POST /arvados/v1/links",\n
22 "GET /arvados/v1/users/current",\n
23 "POST /arvados/v1/users/current",\n
24 "GET /arvados/v1/jobs",\n
25 "POST /arvados/v1/jobs",\n
26 "GET /arvados/v1/pipeline_instances",\n
27 "POST /arvados/v1/pipeline_instances",\n
28 "PUT /arvados/v1/pipeline_instances/",\n
29 "GET /arvados/v1/collections/",\n
30 "POST /arvados/v1/collections/",\n
31 "GET /arvados/v1/logs"]'
36 echo >&2 "usage: $0 [options] <identifier>"
38 echo >&2 " <identifier> Arvados cluster name or single node salt identifier"
40 echo >&2 "$0 options:"
41 echo >&2 " -d, --debug Enable debug output"
42 echo >&2 " -h, --help Display this help and exit"
44 echo >&2 "Note: the SALT_MASTER environment variable needs to be set to the ssh host"
45 echo >&2 " of your salt master."
47 echo >&2 "Note: this script requires an arvados token created with these permissions:"
48 echo >&2 ' arv api_client_authorization create_system_auth \'
49 echo -e $SCOPES"]'" >&2
54 # NOTE: This requires GNU getopt (part of the util-linux package on Debian-based distros).
59 if [ $? != 0 ] ; then echo "Use -h for help"; exit 1 ; fi
60 # Note the quotes around `$TEMP': they are essential!
84 if [[ "$IDENTIFIER" == '' ]]; then
90 date=`date +'%Y-%m-%d %H:%M:%S'`
96 if [[ ! -z "$2" ]]; then
103 ssh -o "ConnectTimeout 5" -o "LogLevel QUIET" $SALT_MASTER salt --out=txt \'$cluster*\' cmd.run \'$(IFS=\0;echo "$@")\' $E
106 if [[ -z "$SALT_MASTER" ]]; then
107 title "ERROR: SALT_MASTER environment variable is not set."
111 run_salt "*$IDENTIFIER" '' 'apt update && DEBIAN_FRONTEND=noninteractive apt -y upgrade'
113 if [[ "$IDENTIFIER" =~ \. ]]; then
114 title "Single node deploy requested, done"
118 title "Loading ARVADOS_API_HOST and ARVADOS_API_TOKEN"
119 if [[ -f "$HOME/.config/arvados/$IDENTIFIER.arvadosapi.com.conf" ]]; then
120 . $HOME/.config/arvados/$IDENTIFIER.arvadosapi.com.conf
122 title "WARNING: $HOME/.config/arvados/$IDENTIFIER.arvadosapi.com.conf not found."
124 if [[ "$ARVADOS_API_HOST" == "" ]] || [[ "$ARVADOS_API_TOKEN" == "" ]]; then
125 title "ERROR: ARVADOS_API_HOST and/or ARVADOS_API_TOKEN environment variables are not set."
129 title "Locating Arvados Standard Docker images project"
131 JSON_FILTER="[[\"name\", \"=\", \"Arvados Standard Docker Images\"], [\"owner_uuid\", \"=\", \"$IDENTIFIER-tpzed-000000000000000\"]]"
132 DOCKER_IMAGES_PROJECT=`ARVADOS_API_HOST=$ARVADOS_API_HOST ARVADOS_API_TOKEN=$ARVADOS_API_TOKEN arv --format=uuid group list --filters="$JSON_FILTER"`
134 if [[ "$DOCKER_IMAGES_PROJECT" == "" ]]; then
135 title "Warning: Arvados Standard Docker Images project not found. Creating it."
137 DOCKER_IMAGES_PROJECT=`ARVADOS_API_HOST=$ARVADOS_API_HOST ARVADOS_API_TOKEN=$ARVADOS_API_TOKEN arv --format=uuid group create --group "{\"owner_uuid\":\"$IDENTIFIER-tpzed-000000000000000\", \"name\":\"Arvados Standard Docker Images\", \"group_class\":\"project\"}"`
138 ARVADOS_API_HOST=$ARVADOS_API_HOST ARVADOS_API_TOKEN=$ARVADOS_API_TOKEN arv link create --link "{\"tail_uuid\":\"$IDENTIFIER-j7d0g-fffffffffffffff\", \"head_uuid\":\"$DOCKER_IMAGES_PROJECT\", \"link_class\":\"permission\", \"name\":\"can_read\" }"
139 if [[ "$?" != "0" ]]; then
140 title "ERROR: could not create standard Docker images project Please create it, cf. http://doc.arvados.org/install/create-standard-objects.html"
145 title "Found Arvados Standard Docker Images project with uuid $DOCKER_IMAGES_PROJECT"
146 VERSION=$(run_salt "shell.$IDENTIFIER" '' 'apt-cache policy python3-arvados-cwl-runner' | grep Candidate |awk '{print $3}' |cut -f1 -d-)
148 if [[ "$?" != "0" ]] || [[ "$VERSION" == "" ]]; then
149 title "ERROR: unable to get python3-arvados-cwl-runner version"
152 title "Found version for python3-arvados-cwl-runner: $VERSION"
156 CLEAN_VERSION=`echo $VERSION | sed s/~dev/.dev/g | sed s/~rc/rc/g`
157 run_salt "shell.$IDENTIFIER" "'{\"ARVADOS_API_HOST\": \"$ARVADOS_API_HOST\", \"ARVADOS_API_TOKEN\": \"$ARVADOS_API_TOKEN\"}'" "arv-keepdocker" |grep -qP "arvados/jobs +$CLEAN_VERSION "
158 if [[ $? -eq 0 ]]; then
160 title "Found arvados/jobs Docker image version $CLEAN_VERSION, nothing to upload"
163 title "Installing arvados/jobs Docker image version $CLEAN_VERSION"
164 run_salt "shell.$IDENTIFIER" "'{\"ARVADOS_API_HOST\": \"$ARVADOS_API_HOST\", \"ARVADOS_API_TOKEN\": \"$ARVADOS_API_TOKEN\"}'" "arv-keepdocker --pull --project-uuid=$DOCKER_IMAGES_PROJECT arvados/jobs $CLEAN_VERSION"
165 if [[ $? -ne 0 ]]; then
166 title "'arv-keepdocker' failed..."