blob: f17304fae62da58f46455c8105f90841d2c4a124 [file] [log] [blame]
# Copyright 2021 The Chromium OS 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
# This script assumes an $LABEL is set of autopush/beta/release or a custom label
# for development
echo "Enviroment variable LABEL is ${LABEL}"
echo "Enviroment variable COMMON_CORE_LABEL is ${COMMON_CORE_LABEL}"
echo "Enviroment variable COMMON_CORE_URI is ${COMMON_CORE_URI}"
echo "Enviroment variable REGISTRY_URI is ${REGISTRY_URI}"
echo "Enviroment variable SATLAB_REGISTRY_URI is ${SATLAB_REGISTRY_URI}"
echo "Enviroment variable BUILD_VERSION is ${BUILD_VERSION}"
echo "Merging main.env and override.env into .env"
egrep -oh '^[^#]+' main.env override.env | egrep . | awk -F= '{a[$1]=$2}END{for(i in a) print i "=" a[i]}' > .env
echo "Command is ${1}"
# Stop any old style docker containers that are named default_
/usr/local/bin/docker stop $(/usr/local/bin/docker ps --filter name="default_" --format "{{.ID}}")
# TODO(prasadv): Find an alternative to support user suppiled service_account key.
if [ -s "${SERVICE_ACCOUNT_KEY}" ]
cat ${SERVICE_ACCOUNT_KEY} | docker login -u _json_key --password-stdin
if [ "$?" -ne 0 ]; then
echo "Failed to authenticate docker, please try again!"
echo "Service account key missing, you need service account key to access Satlab images."
if [ "${1}" == "down" ]
docker-compose down -t 1
docker-compose rm -s -f
docker-compose -f ./docker-compose.watchtower.yaml down -t 1
# This is in case the device was not shutdown cleanly there might be
# restarted containers (restarted by dockerd)
docker-compose down -t 1
docker-compose -f ./docker-compose.watchtower.yaml down -t 1
docker-compose pull conf_creator
docker-compose up -d conf_creator
docker-compose pull satlab_secrets
docker-compose up -d satlab_secrets
docker-compose -f ./docker-compose.watchtower.yaml pull
docker-compose -f ./docker-compose.watchtower.yaml up -d
docker-compose pull dns
docker-compose up -d dns
MACADDR=$(echo "$(get_host_identifier)" | awk '{print tolower($0)}')
echo "Drone Name: ${DRONE_HOSTNAME}"
docker-compose pull drone gsa_server openssh_server nginx
docker-compose up -d drone gsa_server openssh_server nginx
# set permission for ssp volume to create lxc containers
# b/190623503
docker exec drone chmod 0777 /usr/local/autotest/containers/ssp_volume
# Drone uses chromeos-test user for running tasks, need this to set
# access to chromeos-test user to access docker.sock in order to launch
# servod.
docker exec drone chmod 666 /var/run/docker.sock
# Set permission for device profile created and maintanse by repair
# tasks.
docker exec drone chmod 777 /var/servod/profile/
# Connect satlab_remote_access container to satlab network
# so that user can use the local dns serice to resolve
# DUT hostname and allow SSH to DUTs
docker network connect default_satlab satlab_remote_access
docker-compose pull
docker-compose up -d
# Use labels to filter out containers that shouldn't be pruned.
docker system prune --filter "label!=skip.while.pruning.docker.system=yes" -f
docker-compose logs -f