#!/usr/bin/env bash set -e # Bootstrap script for prox_scripts # This script will be downloaded and run directly, so it needs to be self-contained initially REPO_URL="https://github.com/dbir0/prox_scripts" TARGET_DIR="/opt/prox_scripts" update_repo() { if [ -f /etc/debian_version ]; then echo "Updating system repos..." apt-get update || echo "Warning: Some repositories failed to update." else echo "Unsupported OS. Please update your system manually." exit 1 fi } check_or_install_git() { if ! command -v git &> /dev/null; then echo "Git is not installed. Installing git..." if [ -f /etc/debian_version ]; then apt-get update apt-get install -y git else echo "Unsupported OS. Please install git manually." exit 1 fi fi } clone_or_update_repo() { if [ -d "$TARGET_DIR/.git" ]; then echo "Repository already exists. Pulling latest changes..." git -C "$TARGET_DIR" pull --ff-only else echo "Cloning repository..." git clone "$REPO_URL" "$TARGET_DIR" fi } run_setup() { bash "$TARGET_DIR/setup.sh" } update_repo check_or_install_git clone_or_update_repo run_setup