From 93b9c2e9e1283b3b4728624993d39fe7c65d6068 Mon Sep 17 00:00:00 2001 From: Tuan Pham Anh Date: Sun, 28 May 2023 00:11:02 +0700 Subject: [PATCH] put `CHAIN_REGISTRY_INI_URL` into `env.sh` (#339) https://github.com/notional-labs/cosmosia/issues/338 --- load_balancer/run.sh | 1 + proxy/generate_upstream.sh | 5 +++++ proxy/run.sh | 7 +++++++ proxy_internal/run.sh | 8 ++++++++ proxy_public/run.sh | 6 ++++++ 5 files changed, 27 insertions(+) diff --git a/load_balancer/run.sh b/load_balancer/run.sh index ed88fde2..7424cc7d 100644 --- a/load_balancer/run.sh +++ b/load_balancer/run.sh @@ -15,6 +15,7 @@ pacman -S --noconfirm base-devel jq dnsutils python caddy screen wget cronie # write env vars to bash file, so that cronjobs or other scripts could know cat <> $HOME/env.sh +CHAIN_REGISTRY_INI_URL="$CHAIN_REGISTRY_INI_URL" CONFIG_FILE="/etc/caddy/Caddyfile" TMP_CONFIG_FILE="/etc/caddy/Caddyfile.tmp" rpc_service_name="$rpc_service_name" diff --git a/proxy/generate_upstream.sh b/proxy/generate_upstream.sh index 7e852d35..230e4851 100644 --- a/proxy/generate_upstream.sh +++ b/proxy/generate_upstream.sh @@ -1,3 +1,8 @@ +if [[ -z "$CHAIN_REGISTRY_INI_URL" ]]; then + echo "no env var CHAIN_REGISTRY_INI_URL. Make sure put it into \$HOME/env.sh" + exit +fi + SERVICES=$(curl -s "$CHAIN_REGISTRY_INI_URL" |grep -E "\[.*\]" | sed 's/^\[\(.*\)\]$/\1/') diff --git a/proxy/run.sh b/proxy/run.sh index d5886aa5..de879002 100644 --- a/proxy/run.sh +++ b/proxy/run.sh @@ -1,6 +1,11 @@ pacman -Syu --noconfirm pacman -S --noconfirm base-devel dnsutils nginx cronie +# write env vars to bash file, so that cronjobs or other scripts could know +cat <> $HOME/env.sh +CHAIN_REGISTRY_INI_URL="$CHAIN_REGISTRY_INI_URL" +EOT + ######################################################################################################################## # nginx @@ -33,6 +38,7 @@ cat < /usr/share/nginx/html/index.html EOT ######################################################################################################################## +source $HOME/env.sh # generate config for the first time curl -Ls "https://raw.githubusercontent.com/notional-labs/cosmosia/main/proxy/generate_upstream.sh" > $HOME/generate_upstream.sh @@ -49,6 +55,7 @@ sleep 1 ######################################################################################################################## # cron cat <<'EOT' > $HOME/cron_update_upstream.sh +source $HOME/env.sh source $HOME/generate_upstream.sh sleep 1 diff --git a/proxy_internal/run.sh b/proxy_internal/run.sh index ecbfd133..26ca4c44 100644 --- a/proxy_internal/run.sh +++ b/proxy_internal/run.sh @@ -1,6 +1,13 @@ pacman -Syu --noconfirm pacman -S --noconfirm base-devel wget dnsutils nginx cronie screen logrotate +# write env vars to bash file, so that cronjobs or other scripts could know +cat <> $HOME/env.sh +CHAIN_REGISTRY_INI_URL="$CHAIN_REGISTRY_INI_URL" +EOT + +source $HOME/env.sh + ######################################################################################################################## # SSL for notional.ventures (fullchain.pem and privkey.pem files) wget "http://tasks.web_config/config/fullchain.pem" -O /etc/nginx/fullchain.pem @@ -244,6 +251,7 @@ echo "0 0 * * * root logrotate /etc/logrotate.d/nginx" > /etc/cron.d/cron_logrot ######################################################################################################################## # cron cat <<'EOT' > $HOME/cron_update_upstream.sh +source $HOME/env.sh source $HOME/generate_upstream.sh sleep 1 diff --git a/proxy_public/run.sh b/proxy_public/run.sh index 565bfdc1..ef363dcc 100644 --- a/proxy_public/run.sh +++ b/proxy_public/run.sh @@ -1,6 +1,11 @@ pacman -Syu --noconfirm pacman -S --noconfirm base-devel wget dnsutils nginx cronie screen +# write env vars to bash file, so that cronjobs or other scripts could know +cat <> $HOME/env.sh +CHAIN_REGISTRY_INI_URL="$CHAIN_REGISTRY_INI_URL" +EOT + ######################################################################################################################## # SSL for notional.ventures (fullchain.pem and privkey.pem files) # tar -xvf "/run/secrets/ssl_notional.ventures.tar.gz" -C /etc/nginx/ @@ -56,6 +61,7 @@ screen -S nginx -dm /usr/sbin/nginx -g "daemon off;" ######################################################################################################################## # cron cat <<'EOT' > $HOME/cron_update_upstream.sh +source $HOME/env.sh source $HOME/generate_upstream.sh sleep 1