Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deduplicate deploy script case statements #2962

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 20 additions & 50 deletions deploy/setup
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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
;;
*)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading