blob: c1bf6b8ea7bbd43430c378639a26ca5a58c3edb2 [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.
description "Start the satlab remote access docker container."
author "chromium-os-dev@chromium.org"
start on (stopped moblab-network-init RESULT=ok and
started moblab-dockerd )
script
mkdir -p /var/log/bootup/
exec >>/var/log/bootup/${UPSTART_JOB}.log 2>&1
set -x
set +e
APP_KEY="$(vpd -i RW_VPD -g application)"
if [ "$?" != "0" ] || [ "${APP_KEY}" != "satlab" ]; then
echo "Cannot start ${UPSTART_JOB} for APP_KEY = ${APP_KEY}."
exit 1
fi
set -e
LABEL=release
REPO_ADDR=us-docker.pkg.dev/chromeos-partner-moblab/satlab
if [ -e /etc/lsb-release ]; then
track=$(cat /etc/lsb-release | \
grep "CHROMEOS_RELEASE_TRACK" | \
awk -F = '{ print $2 }')
case $track in
beta-channel)
LABEL=beta
;;
testimage-channel | dev-channel | developer-build )
LABEL=autopush
if [ -e /dev/disk/by-label/SATLAB-DEV ] ; then
mkdir -p /usr/local/tmp/satlab-dev
umount /usr/local/tmp/satlab-dev || true
mount "$(readlink -f /dev/disk/by-label/SATLAB-DEV)" \
/usr/local/tmp/satlab-dev || true
LABEL=$(cat /usr/local/tmp/satlab-dev/dev-remote-access-label || echo autopush)
REPO_ADDR=$(cat /usr/local/tmp/satlab-dev/dev-remote-access-repo || echo "us-docker.pkg.dev/chromeos-partner-moblab/satlab")
fi
;;
esac
fi
SSH_PORT=22
case $track in
testimage-channel )
SSH_PORT=2223
;;
esac
reps=0
while [ ${reps} -lt 100 ] && ! docker info ; do
: $((reps += 1))
sleep 1
done
# On boot get rid of any prior containers and make sure we have the latest
# satlab_remote_access container.
docker stop satlab_remote_access || true
docker rm satlab_remote_access || true
docker pull "${REPO_ADDR}/satlab_remote_access:${LABEL}"
docker run -ti -d -v logs:/var/log/satlab \
-v /var/log/bootup:/var/log/bootup \
-v /var/run/docker.sock:/var/run/docker.sock \
-v satlab_keys:/home/satlab/keys \
-v cache_server:/home/satlab/cache_server \
-v leases:/leases:ro \
--name satlab_remote_access \
-e PUBLIC_KEY_FILE=/testing_rsa.pub \
-e PUID=246 \
-e PGID=246 \
-e TZ=Etc/UTC \
-e USER_NAME=moblab \
-e DOCKER_MODS=linuxserver/mods:openssh-server-ssh-tunnel \
-e SUDO_ACCESS=true \
-p ${SSH_PORT}:2222 \
--dns 192.168.100.51 \
--add-host dockerhost:172.17.0.1 \
"${REPO_ADDR}/satlab_remote_access:${LABEL}"
end script