From 489f4c65da048c26bc13db8d2572b2e4135f590c Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Thu, 4 Jan 2024 10:16:32 -0800 Subject: [PATCH] Deduplicate deploy script case statements --- deploy/setup | 70 +++++++++++++++------------------------------------- 1 file changed, 20 insertions(+), 50 deletions(-) diff --git a/deploy/setup b/deploy/setup index 86dfe216c6..b32ac5d891 100755 --- a/deploy/setup +++ b/deploy/setup @@ -10,35 +10,8 @@ BRANCH=$3 COMMIT=$4 REVISION="ord-$BRANCH-$COMMIT" -case $CHAIN in - main) - CSP_ORIGIN=ordinals.com - ;; - regtest) - CSP_ORIGIN=regtest.ordinals.com - ;; - signet) - CSP_ORIGIN=signet.ordinals.com - ;; - test) - CSP_ORIGIN=testnet.ordinals.com - ;; - *) - echo "Unknown chain: $CHAIN" - exit 1 - ;; -esac - touch ~/.hushlogin -mkdir -p \ - /etc/systemd/system/bitcoind.service.d \ - /etc/systemd/system/ord.service.d - -printf "[Service]\nEnvironment=CHAIN=%s\nEnvironment=CSP_ORIGIN=%s\n" $CHAIN $CSP_ORIGIN \ - | tee /etc/systemd/system/bitcoind.service.d/override.conf \ - > /etc/systemd/system/ord.service.d/override.conf - hostnamectl set-hostname $DOMAIN apt-get install --yes \ @@ -60,21 +33,25 @@ ufw allow http ufw allow https ufw allow ssh -sed -i -E 's/#?PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config -sshd -t -systemctl restart sshd - case $CHAIN in main) + COOKIE_FILE_DIR=/var/lib/bitcoind + CSP_ORIGIN=ordinals.com ufw allow 8333 ;; regtest) + COOKIE_FILE_DIR=/var/lib/bitcoind/regtest + CSP_ORIGIN=regtest.ordinals.com ufw allow 18444 ;; signet) + COOKIE_FILE_DIR=/var/lib/bitcoind/signet + CSP_ORIGIN=signet.ordinals.com ufw allow 38333 ;; test) + COOKIE_FILE_DIR=/var/lib/bitcoind/testnet3 + CSP_ORIGIN=testnet.ordinals.com ufw allow 18333 ;; *) @@ -83,6 +60,18 @@ case $CHAIN in ;; esac +mkdir -p \ + /etc/systemd/system/bitcoind.service.d \ + /etc/systemd/system/ord.service.d + +printf "[Service]\nEnvironment=CHAIN=%s\nEnvironment=CSP_ORIGIN=%s\n" $CHAIN $CSP_ORIGIN \ + | tee /etc/systemd/system/bitcoind.service.d/override.conf \ + > /etc/systemd/system/ord.service.d/override.conf + +sed -i -E 's/#?PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config +sshd -t +systemctl restart sshd + ufw --force enable if ! which bitcoind; then @@ -119,25 +108,6 @@ systemctl daemon-reload systemctl enable bitcoind systemctl restart bitcoind -case $CHAIN in - main) - COOKIE_FILE_DIR=/var/lib/bitcoind - ;; - regtest) - COOKIE_FILE_DIR=/var/lib/bitcoind/regtest - ;; - signet) - COOKIE_FILE_DIR=/var/lib/bitcoind/signet - ;; - test) - COOKIE_FILE_DIR=/var/lib/bitcoind/testnet3 - ;; - *) - echo "Unknown chain: $CHAIN" - exit 1 - ;; -esac - while [[ ! -f $COOKIE_FILE_DIR/.cookie ]]; do echo "Waiting for bitcoind…" sleep 1