icorp host profiles into scripts that needed it
This commit is contained in:
+29
-3
@@ -4,7 +4,13 @@
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
# Pulls latest scripts from Gitea repo via SSH and sets executable permissions.
|
||||
# Lives at the repo root — sources Master.conf and common.sh from the same directory.
|
||||
# Uses GITEA_SSH_KEY, SSH_PORT and REPO_SSH from Master.conf.
|
||||
# Uses GITEA_SSH_KEY, SSH_PORT, GITEA_CONTAINER and GITEA_REPO_PATH from Master.conf.
|
||||
#
|
||||
# Detects where the Gitea container is running at runtime:
|
||||
# Gitea running locally → connects via local IP
|
||||
# Gitea running remotely → connects via remote server's Tailscale IP
|
||||
# Works correctly through failover — no hardcoded assumptions about which server hosts Gitea.
|
||||
#
|
||||
# Supports --dry-run, --log, --status flags via common.sh parse_args.
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -22,7 +28,6 @@ parse_args "$@"
|
||||
echo ""
|
||||
echo "━━━ $ICON_GEAR Setup ━━━"
|
||||
|
||||
# ROOT CHECK
|
||||
if [[ "$EUID" -ne 0 ]]; then
|
||||
error "Must be run as root"
|
||||
exit 1
|
||||
@@ -30,7 +35,28 @@ fi
|
||||
|
||||
success "Running as root"
|
||||
|
||||
# VALIDATION
|
||||
# Detect which server we're on and where Gitea is running
|
||||
detect_hosts
|
||||
|
||||
# Check if Gitea container is running locally
|
||||
if docker ps --format "{{.Names}}" 2>/dev/null | grep -q "^${GITEA_CONTAINER}$"; then
|
||||
# Gitea is running on this server — use local IP
|
||||
GITEA_IP=$(hostname -I | awk '{print $1}')
|
||||
info "$ICON_CONTAINERS Gitea running locally — connecting via $GITEA_IP"
|
||||
else
|
||||
# Gitea is not running locally — find it on the remote server via Tailscale
|
||||
info "$ICON_CONTAINERS Gitea not running locally — checking remote server"
|
||||
GITEA_IP=$(tailscale ip -4 "$REMOTE_SERVER_NAME" 2>/dev/null)
|
||||
if [[ -z "$GITEA_IP" ]]; then
|
||||
error "Cannot resolve Tailscale IP for $REMOTE_SERVER_NAME — is Tailscale running?"
|
||||
notify "Git pull failed on $(hostname) — cannot find Gitea container or resolve remote IP" "Git Sync" "alert"
|
||||
exit 1
|
||||
fi
|
||||
info "$ICON_NET Gitea on $REMOTE_SERVER_NAME — connecting via $GITEA_IP"
|
||||
fi
|
||||
|
||||
REPO_SSH="git@${GITEA_IP}:${GITEA_REPO_PATH}"
|
||||
|
||||
require_var REPO_SSH
|
||||
require_var TARGET_DIR
|
||||
require_var GITEA_SSH_KEY
|
||||
|
||||
Reference in New Issue
Block a user