blob: 7d59a86b12f074806325a3bcad758de8ae96dbd6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#!/bin/bash
# deploy — Build and deploy claudomator to /site/doot.terst.org
# Usage: ./scripts/deploy [--dirty]
# Example: sudo ./scripts/deploy
set -euo pipefail
DIRTY=false
for arg in "$@"; do
if [ "$arg" == "--dirty" ]; then
DIRTY=true
fi
done
FQDN="doot.terst.org"
SITE_DIR="/site/${FQDN}"
BIN_DIR="${SITE_DIR}/bin"
SERVICE="claudomator@${FQDN}.service"
REPO_DIR="$(cd "$(dirname "$0")/.." && pwd)"
cd "${REPO_DIR}"
echo "==> Pulling latest from bare repo..."
git pull --ff-only local master
STASHED=false
if [ "$DIRTY" = false ] && [ -n "$(git status --porcelain)" ]; then
echo "==> Stashing uncommitted changes..."
git stash push -u -m "Auto-stash before deploy"
STASHED=true
trap 'if [ "$STASHED" = true ]; then echo "==> Popping stash..."; git stash pop; fi' EXIT
fi
echo "==> Verifying (build + tests)..."
"${REPO_DIR}/scripts/verify"
echo "==> Building claudomator..."
export GOCACHE="${SITE_DIR}/cache/go-build"
export GOPATH="${SITE_DIR}/cache/gopath"
mkdir -p "${GOCACHE}" "${GOPATH}"
go build -o "${BIN_DIR}/claudomator" ./cmd/claudomator/
chown www-data:www-data "${BIN_DIR}/claudomator"
chmod +x "${BIN_DIR}/claudomator"
echo "==> Copying scripts..."
mkdir -p "${SITE_DIR}/scripts"
find "${REPO_DIR}/scripts" -maxdepth 1 -type f -exec cp -p {} "${SITE_DIR}/scripts/" \;
chown -R www-data:www-data "${SITE_DIR}/scripts"
find "${SITE_DIR}/scripts" -maxdepth 1 -type f -exec chmod +x {} +
if [ -f "${BIN_DIR}/claude" ]; then
echo "==> Fixing Claude permissions..."
chown www-data:www-data "${BIN_DIR}/claude"
chmod +x "${BIN_DIR}/claude"
fi
echo "==> Installing to /usr/local/bin..."
cp "${BIN_DIR}/claudomator" /usr/local/bin/claudomator
chmod +x /usr/local/bin/claudomator
echo "==> Restarting service..."
sudo systemctl restart "${SERVICE}"
sudo systemctl status "${SERVICE}" --no-pager -l
echo "==> Done!"
|