icorp host profiles into scripts that needed it

This commit is contained in:
2026-04-19 17:39:40 -04:00
parent cbfdc488c3
commit 4103e1be65
4 changed files with 64 additions and 6 deletions
+11 -3
View File
@@ -104,10 +104,18 @@
# Gitea self-hosted repository settings used by git_pull_execute.sh.
# Running git_pull_execute.sh on either server pulls the latest scripts and sets
# executable permissions automatically — keeps both servers in sync with one command.
REPO_SSH="git@192.168.50.2:FailedProxy/Unraid_Scripts.git"
#
# git_pull_execute.sh 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
# No hardcoded assumptions about which server hosts Gitea — works through failover.
# If Gitea fails over to HOST2, HOST1 automatically finds it there and vice versa.
GITEA_CONTAINER="Gitea" # exact Docker container name
GITEA_REPO_PATH="FailedProxy/Unraid_Scripts.git" # repo path on Gitea
TARGET_DIR="/mnt/user/appdata/unraid_scripts"
GITEA_SSH_KEY="/root/.ssh/unraid_gitea" # SSH key for authenticating to Gitea
SSH_PORT=221 # Gitea SSH port — default Gitea uses 22
GITEA_SSH_KEY="/root/.ssh/unraid_gitea" # SSH key for authenticating to Gitea
SSH_PORT=221 # Gitea SSH port
# ==============================================================================================
# ── RSYNC ─────────────────────────────────────────────────────────────────────────────────────
+13
View File
@@ -43,6 +43,19 @@ if ! command -v jq >/dev/null 2>&1; then
exit 1
fi
# Select correct Emby instance based on which server is running this script
detect_hosts
if [[ "$LOCAL_SERVER_NAME" == "$HOST1" ]]; then
EMBY_URL="$HOST1_EMBY_URL"
EMBY_API_KEY="$HOST1_EMBY_API_KEY"
else
EMBY_URL="$HOST2_EMBY_URL"
EMBY_API_KEY="$HOST2_EMBY_API_KEY"
fi
info "Emby instance: $LOCAL_SERVER_NAME$EMBY_URL"
require_var EMBY_URL
require_var EMBY_API_KEY
+11
View File
@@ -47,6 +47,17 @@ fi
success "Running as root"
# Select correct Emby instance for session display
detect_hosts
if [[ "$LOCAL_SERVER_NAME" == "$HOST1" ]]; then
EMBY_URL="${HOST1_EMBY_URL}"
EMBY_API_KEY="${HOST1_EMBY_API_KEY}"
else
EMBY_URL="${HOST2_EMBY_URL}"
EMBY_API_KEY="${HOST2_EMBY_API_KEY}"
fi
case "$TRANSCODE_MANAGER_MODE" in
smart|ramdisk|ssd) info "$ICON_GEAR Mode: $TRANSCODE_MANAGER_MODE" ;;
*)
+29 -3
View File
@@ -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