44 lines
1.2 KiB
Bash
Executable file
44 lines
1.2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# NextWorkspace Installer — bootstraps a bare Linux VM
|
|
# Idempotent: safe to run multiple times.
|
|
|
|
echo "=== NextWorkspace Installer ==="
|
|
|
|
# ---- Go ----
|
|
if command -v go &>/dev/null; then
|
|
echo "[SKIP] Go already installed: $(go version)"
|
|
else
|
|
echo "[INSTALL] Installing Go..."
|
|
GO_URL="https://go.dev/dl/$(curl -sL https://go.dev/VERSION?m=text | head -1).linux-amd64.tar.gz"
|
|
curl -sL "$GO_URL" -o /tmp/go.tar.gz
|
|
rm -rf /usr/local/go
|
|
tar -C /usr/local -xzf /tmp/go.tar.gz
|
|
rm /tmp/go.tar.gz
|
|
echo 'export PATH=$PATH:/usr/local/go/bin' > /etc/profile.d/go.sh
|
|
chmod +x /etc/profile.d/go.sh
|
|
export PATH=$PATH:/usr/local/go/bin
|
|
echo "[OK] Go installed: $(go version)"
|
|
fi
|
|
|
|
# ---- System deps ----
|
|
echo "[INSTALL] git, build-essential, podman..."
|
|
apt-get update -qq
|
|
apt-get install -y -qq git build-essential curl podman
|
|
|
|
# ---- Clone / pull repo ----
|
|
REPO_DIR="/opt/NextWks"
|
|
REPO_URL="https://git.lohmar.co.uk/lexton-it/NextWks.git"
|
|
|
|
if [ -d "$REPO_DIR/.git" ]; then
|
|
echo "[UPDATE] Repository exists — pulling latest..."
|
|
cd "$REPO_DIR"
|
|
git pull
|
|
else
|
|
echo "[CLONE] Cloning repository..."
|
|
git clone "$REPO_URL" "$REPO_DIR"
|
|
fi
|
|
|
|
echo "[DONE] Bootstrapping complete. Running first deploy..."
|
|
"$REPO_DIR/deploy.sh" --destroy
|