From 72f0365b4b61ce6e5ee6e1679a84d70c5718d4c0 Mon Sep 17 00:00:00 2001 From: thomasabishop Date: Sun, 14 Dec 2025 15:34:47 +0000 Subject: [PATCH] add deploy eolas script --- deploy_eolas.sh | 61 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100755 deploy_eolas.sh diff --git a/deploy_eolas.sh b/deploy_eolas.sh new file mode 100755 index 0000000..3f1aacd --- /dev/null +++ b/deploy_eolas.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +source /home/thomas/.env + +SOURCE="$(whoami)@$(hostname) ($(hostname -i | awk '{print $1}'))" +EOLAS_DIR="/home/thomas/repos/eolas" +EOLAS_DB_EXECUTABLE="/usr/local/bin/eolas-db/app" + +function notify() { + message="" + if [ "$1" == 'error' ]; then + message="🟥 $2" + else + message="🟩 $2" + fi + + curl -s -u thomas:${NTFY_PASSWORD} \ + -H "Tags: $SOURCE" \ + -d "${message} " \ + https://ntfy.systemsobscure.net/eolas +} + +echo "TB-INFO Running script deploy_eolas.sh" + +cd "$EOLAS_DIR" || exit + +${EOLAS_DIR}/scripts/upload_images_to_s3.sh + +echo "TB-INFO Uploaded images to S3" + +echo "TB-INFO Generating database" +sudo ${EOLAS_DB_EXECUTABLE} --source="${EOLAS_DIR}/zk" --target="/tmp" + +db_size=$(stat --printf="%s" /tmp/eolas.db | awk '{printf "%.2f", $1/1000000}') + +echo "TB-INFO Stopping eolas-api on VPS" + +ssh -T -i /home/thomas/.ssh/deploy_self_host_server deploy@systemsobscure.net <<'EOF' + sudo systemctl stop eolas-api.service +EOF + +sudo scp -i /home/thomas/.ssh/deploy_self_host_server /tmp/eolas.db deploy@systemsobscure.net:/data/sqlite/eolas >/dev/null + +echo "TB-INFO scp new database file to VPS" + +ssh -T -i /home/thomas/.ssh/deploy_self_host_server deploy@systemsobscure.net <<'EOF' + sudo systemctl start eolas-api.service +EOF + +echo "TB-INFO Restarting eolas-api on VPS" + +bucket_info=$(aws --profile garage --endpoint-url https://s3.systemsobscure.net s3 ls --summarize --human-readable s3://eolas/ | tail --lines=2 | tr -ds '\n' " ") + +last_commit=$(cd "$EOLAS_DIR" && git rev-parse HEAD) +last_commit_trimmed=$(echo "$last_commit" | cut -b -6) + +notify 'success' "eolas deployed at commit ${last_commit_trimmed}. +Database size: ${db_size}MB +Image bucket info: $bucket_info +https://forgejo.systemsobscure.net/thomasabishop/eolas/commit/${last_commit} +" >/dev/null