From 2db6c0d853597b977a6be269c902a17ec78881f7 Mon Sep 17 00:00:00 2001 From: Dimi Kot Date: Sun, 25 Aug 2024 19:53:46 -0700 Subject: [PATCH] Fix validate.sh variables defaults in guest scripts --- docker/ci-runner/root/entrypoint.01-validate.sh | 9 +++++++++ docker/ci-scaler/root/entrypoint.01-validate.sh | 4 ++-- docker/compose-up-dev.sh | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docker/ci-runner/root/entrypoint.01-validate.sh b/docker/ci-runner/root/entrypoint.01-validate.sh index b638f39..1eedcf4 100644 --- a/docker/ci-runner/root/entrypoint.01-validate.sh +++ b/docker/ci-runner/root/entrypoint.01-validate.sh @@ -4,46 +4,55 @@ # set -u -e +export GH_TOKEN if [[ "${GH_TOKEN:=}" == "" ]]; then say "GH_TOKEN must be set." exit 1 fi +export GH_REPOSITORY if [[ "${GH_REPOSITORY:=}" != */* ]]; then say "GH_REPOSITORY must be set, and the format should be {owner}/{repo}." exit 1 fi +export GH_LABELS if [[ "${GH_LABELS:=}" == "" ]]; then say "GH_LABELS must be set." exit 1 fi +export TZ if [[ "${TZ:=}" != "" && ! "$TZ" =~ ^[-+_/a-zA-Z0-9]+$ ]]; then say "If TZ is passed, it must be a valid TZ Idenfitier from https://en.wikipedia.org/wiki/List_of_tz_database_time_zones" exit 1 fi +export FORWARD_HOST if [[ "${FORWARD_HOST:=}" != "" && ! "$FORWARD_HOST" =~ ^[-.[:alnum:]]+(:[0-9]+)?$ ]]; then say "If FORWARD_HOST is passed, it must be a hostname." exit 1 fi +export FORWARD_PORTS if [[ "${FORWARD_PORTS:=}" != "" && ! "$FORWARD_PORTS" =~ ^([[:space:]]*[0-9]+(/tcp|/udp)?[[:space:]]*)+$ ]]; then echo 'If FORWARD_PORTS is passed, it must be in the form of (example): "123 456/udp 789/tcp".'; exit 1 fi +export CI_STORAGE_HOST if [[ "${CI_STORAGE_HOST:=}" != "" && ! "$CI_STORAGE_HOST" =~ ^([-.[:alnum:]]+@)?[-.[:alnum:]]+(:[0-9]+)?$ ]]; then say "If CI_STORAGE_HOST is passed, it must be in the form of [user@]host[:port]." exit 1 fi +export BTIME if [[ "${BTIME:=}" != "" && ! "$BTIME" =~ ^[0-9]+$ ]]; then say "If BTIME is passed, it must be a number (boot timestamp)." exit 1 fi +export DEBUG_SHUTDOWN_DELAY_SEC if [[ "${DEBUG_SHUTDOWN_DELAY_SEC:=}" != "" && ! "$DEBUG_SHUTDOWN_DELAY_SEC" =~ ^[0-9]+$ ]]; then say "If DEBUG_SHUTDOWN_DELAY_SEC is passed, it must be a number." exit 1 diff --git a/docker/ci-scaler/root/entrypoint.01-validate.sh b/docker/ci-scaler/root/entrypoint.01-validate.sh index 5ce1cc3..89241ab 100644 --- a/docker/ci-scaler/root/entrypoint.01-validate.sh +++ b/docker/ci-scaler/root/entrypoint.01-validate.sh @@ -4,20 +4,20 @@ # set -u -e +export ASGS if [[ "${ASGS:=}" != "" && "${GH_TOKEN:=}" == "" ]]; then say "When ASGS is set, GH_TOKEN must also be set." exit 1 fi - if [[ "${ASGS:=}" != "" && "$ASGS" != */*:*:* ]]; then say "If ASGS is set, its format should be a space-delimited list of {owner}/{repo}:{label}:{asg_name}." exit 1 fi - if [[ "$ASGS" == "" ]]; then say "For this container to operate, ASGS environment variable should be passed. The container will start, but it'll do nothing, which may be fine in dev environment." fi +export DOMAIN if [[ "${DOMAIN:=}" != "" && "$DOMAIN" != *.* ]]; then say "If DOMAIN is set, it should be a fully qualified domain name." exit 1 diff --git a/docker/compose-up-dev.sh b/docker/compose-up-dev.sh index 68c80be..820238b 100755 --- a/docker/compose-up-dev.sh +++ b/docker/compose-up-dev.sh @@ -3,6 +3,7 @@ set -e echo "Building & booting containters on the local laptop for debugging purposes..." +# This is for debugging/illustration purposes only. btime=1719410000 if [[ "$OSTYPE" == darwin* ]]; then btime=$(sysctl -n kern.boottime | awk '{print $4}' | tr -d ',')