Monorepo for Aesthetic.Computer
aesthetic.computer
1#!/usr/bin/env fish
2# First-time provisioning for help.aesthetic.computer
3# Run this once to set up the droplet after SSH access is established.
4#
5# Prerequisites:
6# - SSH access to 146.190.150.173 via vault key
7# - Vault .env file at aesthetic-computer-vault/help/.env
8
9set RED '\033[0;31m'
10set GREEN '\033[0;32m'
11set YELLOW '\033[1;33m'
12set NC '\033[0m'
13
14set SCRIPT_DIR (dirname (status --current-filename))
15set VAULT_DIR "$SCRIPT_DIR/../aesthetic-computer-vault"
16set SSH_KEY "$VAULT_DIR/home/.ssh/id_rsa"
17set HELP_HOST "help.aesthetic.computer"
18set HELP_USER "root"
19
20if not test -f $SSH_KEY
21 echo -e "$RED x SSH key not found: $SSH_KEY$NC"
22 exit 1
23end
24
25echo -e "$GREEN-> Provisioning help.aesthetic.computer...$NC"
26
27# Test SSH
28if not ssh -i $SSH_KEY -o StrictHostKeyChecking=no -o ConnectTimeout=10 $HELP_USER@$HELP_HOST "echo ok" &>/dev/null
29 echo -e "$RED x Cannot connect to $HELP_HOST$NC"
30 exit 1
31end
32
33echo -e "$GREEN-> Installing Node.js 22...$NC"
34ssh -i $SSH_KEY -o StrictHostKeyChecking=no $HELP_USER@$HELP_HOST '
35 # Clean up any judge remnants
36 systemctl stop judge 2>/dev/null || true
37 systemctl disable judge 2>/dev/null || true
38 systemctl stop ollama 2>/dev/null || true
39 systemctl disable ollama 2>/dev/null || true
40 rm -rf /opt/judge
41 rm -f /etc/systemd/system/judge.service
42
43 # Install Node.js 22
44 if ! command -v node &>/dev/null || [[ "$(node --version)" != v22* ]]; then
45 curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
46 apt-get install -y nodejs
47 fi
48 echo "node $(node --version)"
49
50 # Create help user
51 id help &>/dev/null || useradd --system --create-home help
52 mkdir -p /opt/help
53 chown help:help /opt/help
54'
55
56echo -e "$GREEN-> Installing Caddy...$NC"
57ssh -i $SSH_KEY -o StrictHostKeyChecking=no $HELP_USER@$HELP_HOST '
58 if ! command -v caddy &>/dev/null; then
59 apt-get install -y debian-keyring debian-archive-keyring apt-transport-https curl
60 curl -1sLf "https://dl.cloudsmith.io/public/caddy/stable/gpg.key" | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
61 curl -1sLf "https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt" | tee /etc/apt/sources.list.d/caddy-stable.list
62 apt-get update && apt-get install -y caddy
63 fi
64 echo "caddy $(caddy version)"
65
66 # Caddy config
67 cat > /etc/caddy/Caddyfile <<CADDY
68help.aesthetic.computer {
69 reverse_proxy localhost:3004
70}
71CADDY
72
73 systemctl enable caddy
74 systemctl restart caddy
75'
76
77echo -e "$GREEN-> Creating systemd service...$NC"
78ssh -i $SSH_KEY -o StrictHostKeyChecking=no $HELP_USER@$HELP_HOST '
79 cat > /etc/systemd/system/help.service <<SERVICE
80[Unit]
81Description=help.aesthetic.computer
82After=network.target
83
84[Service]
85Type=simple
86User=help
87WorkingDirectory=/opt/help
88ExecStart=/usr/bin/node server.mjs
89Restart=always
90RestartSec=5
91Environment=NODE_ENV=production
92
93[Install]
94WantedBy=multi-user.target
95SERVICE
96
97 systemctl daemon-reload
98 systemctl enable help
99'
100
101echo -e "$GREEN-> Provisioning complete.$NC"
102echo -e "$YELLOW Next: run deploy.fish to upload code$NC"