From f40936ae618c31de67de169c4e9e4199153bb093 Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Sat, 28 Aug 2021 16:33:15 -0500 Subject: [PATCH] Tweak some scripts, make executable --- server/deploy.sh | 0 server/deploy_hook.sh | 0 server/serversetup.sh | 27 ++++++++++++++++++++++----- server/start.sh | 0 server/stop.sh | 0 src/config/config.go.example | 2 +- 6 files changed, 23 insertions(+), 6 deletions(-) mode change 100644 => 100755 server/deploy.sh mode change 100644 => 100755 server/deploy_hook.sh mode change 100644 => 100755 server/serversetup.sh mode change 100644 => 100755 server/start.sh mode change 100644 => 100755 server/stop.sh diff --git a/server/deploy.sh b/server/deploy.sh old mode 100644 new mode 100755 diff --git a/server/deploy_hook.sh b/server/deploy_hook.sh old mode 100644 new mode 100755 diff --git a/server/serversetup.sh b/server/serversetup.sh old mode 100644 new mode 100755 index 7cff9ca..16fc082 --- a/server/serversetup.sh +++ b/server/serversetup.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -euxo pipefail + BLACK_BOLD=$'\e[1;30m' RESET=$'\e[0m' @@ -64,23 +66,37 @@ sudo apt-get update sudo apt-get -y install postgresql # Configure Postgres +# TODO: This was supposed to create a user without a password - why didn't it? +# ...or was it? sudo -u postgres createuser --createdb --login --pwprompt hmn # Set up the folder structure, clone the repo sudo -u hmn bash -s <<'SCRIPT' +set -euxo pipefail + cd ~ mkdir log mkdir bin +echo 'PATH=$PATH:/usr/local/go/bin' >> ~/.profile +source ~/.profile + ssh-keygen -t ed25519 -C "beta-server" -N "" -f ~/.ssh/gitlab git config --global core.sshCommand "ssh -i ~/.ssh/gitlab" echo "" +echo "" echo "Copy the following key and add it as a Deploy Key in the project in GitLab (https://git.handmade.network/hmn/hmn/-/settings/ci_cd#js-deploy-keys-settings):" +echo "" cat ~/.ssh/gitlab.pub +echo "" echo "Press enter to continue when you're done." read git clone git@gitssh.handmade.network:hmn/hmn.git +pushd hmn + echo "Building the site for the first time. This may take a while..." + go build -o hmn src/main.go +popd SCRIPT # Copy config files to the right places @@ -92,10 +108,7 @@ cp /home/hmn/hmn/src/config/config.go.example /home/hmn/hmn/src/config/config.go cp /home/hmn/hmn/cinera/cinera.conf.sample /home/hmn/hmn/cinera/cinera.conf chmod 600 ~/.monitrc -# TODO: Work this message in with all the others about config files you need to update -echo "The Caddyfile has been written to the home folder. Please edit it and add the Cloudflare key so that the ACME challenge can pass." - -echo <