diff --git a/install.sh b/install.sh index 268ce5f..f58ac38 100755 --- a/install.sh +++ b/install.sh @@ -89,12 +89,20 @@ apt-get install -y -qq git build-essential curl podman podman-compose REPO_DIR="/opt/NextWks" mkdir -p "$REPO_DIR" -# Copy current code to REPO_DIR (includes all latest changes) -echo "[COPY] Deploying current code to $REPO_DIR..." +# Clone or update repo, then overlay our current code +echo "[SETUP] Preparing /opt/NextWks..." +if [ -d "$REPO_DIR/.git" ]; then + cd "$REPO_DIR" && git pull +elif command -v git &>/dev/null; then + # Try to clone the remote first, so git history is intact + git clone "https://git.lohmar.co.uk/lexton-it/NextWks.git" "$REPO_DIR.tmp" 2>/dev/null && \ + mv "$REPO_DIR.tmp" "$REPO_DIR" || true +fi + +# Copy current code on top (ensures latest changes) +mkdir -p "$REPO_DIR" cp -r "$SCRIPT_DIR"/* "$REPO_DIR/" cp "$SCRIPT_DIR"/.gitignore "$REPO_DIR/" 2>/dev/null || true - -# Ensure tools are executable chmod +x "$REPO_DIR/deploy.sh" "$REPO_DIR/install.sh" 2>/dev/null || true echo "[DONE] Bootstrapping complete. Running first deploy..."