#!/bin/bash # ============================================================================================== # ================================= MASTER CONFIGURATION ======================================= # ============================================================================================== # All user-facing variables for the unRAID script ecosystem. # Scripts source this file — edit here, changes apply everywhere on next git pull. # # ── INDEX ───────────────────────────────────────────────────────────────────────────────────── # # Section Description # ─────────────────────────────────────────────────────────────────────────────────────────── # HOST CONFIGURATION Server hostnames and SSH key paths # LOGGING Enable or disable verbose logging # NOTIFICATIONS unRAID native and Discord webhook settings # GIT / REPO Gitea repository and SSH settings # # ── RSYNC ────────────────────────────────────────────────────────────────────────────────── # RSYNC DEFAULTS Global fallback rsync settings # REMOTE HEALTH CHECKS Rootfs threshold for pre-flight abort # DAILY SYNC SHARES Media shares synced by daily_sync.sh # RSYNC PROFILE SYSTEM Per-profile overrides (appdata profiles) # # ── FAILOVER ─────────────────────────────────────────────────────────────────────────────── # FAILOVER Mutual container failover between two servers # # ── DOCKER ESSENTIALS ────────────────────────────────────────────────────────────────────── # DOCKER DAILY RESTART Containers restarted daily # DOCKER WEEKLY RESTART Containers restarted weekly # DOCKER WATCHDOG Container health monitoring — memory, CPU, HTTP # DOCKER NETWORK CONNECT Connect containers to extra networks on boot # # ── UNRAID ESSENTIALS ────────────────────────────────────────────────────────────────────── # REBOOT User warning delay before scheduled reboot # MOVER Mover stop timeout # SYSLOG FILTER Docker veth noise filter file path # PHP-FPM PHP-FPM max children config # CLEAR LOGS System log file paths # WEBGUI WATCHDOG WebGUI nginx + emhttp monitoring and restart # ZFS MEMORY SNAPSHOT Weekly ZFS health and memory diagnostic report # # ── MEDIA ────────────────────────────────────────────────────────────────────────────────── # MEDIA PERMISSIONS Share list, mode and owner for permissions script # MEDIA CLEANER Anime and media folder lists and file patterns # # ── TRANSCODES ───────────────────────────────────────────────────────────────────────────── # TRANSCODE MANAGER Ramdisk and SSD fallback transcode management # # ── SYSTEM WATCHDOG ──────────────────────────────────────────────────────────────────────── # SYSTEM WATCHDOG System health monitoring — last line of defense # # ============================================================================================== # ━━━ Host Configuration ━━━ HOST1="unRAID-Gmer4Lfe" HOST2="unRAID-Jayred365" HOST1_SSH_KEY="/root/.ssh/Gmer4Lfe-rsync-key" HOST2_SSH_KEY="/root/.ssh/Jayred365-rsync-key" # ━━━ Logging ━━━ ENABLE_LOGGING=true # ━━━ Notifications ━━━ NOTIFY_UNRAID=true DISCORD_WEBHOOK="" # ━━━ Git / Repo ━━━ REPO_SSH="git@192.168.50.2:FailedProxy/Unraid_Scripts.git" TARGET_DIR="/mnt/user/appdata/unraid_scripts" GITEA_SSH_KEY="/root/.ssh/id_gitea_rsync" SSH_PORT=221 # ============================================================================================== # ── RSYNC ───────────────────────────────────────────────────────────────────────────────────── # ============================================================================================== # ━━━ Rsync Defaults ━━━ BW_LIMIT=12500 RETRY_COUNT=3 SLEEP=300 CRITICAL_CONTAINER_NAMES=() DELAYED_CONTAINERS=() CONTAINER_DELAY=5 EXCLUDE_DIRS=() DEFAULT_RSYNC_OPTS=(-av --info=progress2 --human-readable --bwlimit="$BW_LIMIT" --delete --inplace --no-whole-file) # ━━━ Remote Health Checks ━━━ ROOTFS_WARN=75 # ━━━ Daily Sync Shares ━━━ DAILY_SYNC_SHARES=( /mnt/user/Anime_Movies-Old /mnt/user/Anime_Shows-Old /mnt/user/Anime_Shows /mnt/user/Books /mnt/user/Intros /mnt/user/Kids_Movies /mnt/user/Kids_Tv_Shows /mnt/user/Movies /mnt/user/Music_Videos /mnt/user/Nextcloud /mnt/user/stand-up_comedy /mnt/user/Tv_Shows ) # ━━━ Rsync Profile System ━━━ declare -A PROFILE_RSYNC_OPTS=( [arrs_stack]="-av --info=progress2 --human-readable --bwlimit=$BW_LIMIT --delete --inplace" [critical-data]="-av --human-readable --bwlimit=$BW_LIMIT --delete" [gmer4lfe]="-av --info=progress2 --bwlimit=$BW_LIMIT" [important-data]="-av --human-readable --bwlimit=$BW_LIMIT" [emby]="-av --human-readable --bwlimit=$BW_LIMIT" ) declare -A PROFILE_BW_LIMIT=( [arrs_stack]=5000 [critical-data]=9500 [gmer4lfe]=8000 [important-data]=9500 [emby]=8000 ) declare -A PROFILE_RETRY_COUNT=( [arrs_stack]=3 [critical-data]=3 [gmer4lfe]=3 [important-data]=3 [emby]=3 ) declare -A PROFILE_SLEEP=( [arrs_stack]=300 [critical-data]=300 [gmer4lfe]=300 [important-data]=300 [emby]=300 ) declare -A PROFILE_CRITICAL_CONTAINER_NAMES=( [arrs_stack]="Sonarr Lidarr Readarr Radarr Prowlarr Bazarr Pinchflat" [critical-data]="Mariadb-Authelia Redis-Authelia Lldap-Gmer4Lfe NginxProxyManager Authelia" [gmer4lfe]="Organizrv2-Gmer4Lfe UptimeKuma-Gmer4Lfe VaultWarden-Gmer4Lfe" [important-data]="Postgres-NextCloud NextCloud" [emby]="" ) declare -A PROFILE_DELAYED_CONTAINERS=( [arrs_stack]="" [critical-data]="Authelia" [gmer4lfe]="" [important-data]="NextCloud" [emby]="" ) declare -A PROFILE_CONTAINER_DELAY=( [arrs_stack]=5 [critical-data]=10 [gmer4lfe]=5 [important-data]=10 [emby]=5 ) declare -A PROFILE_EXCLUDE_DIRS=( [arrs_stack]="logs *.tmp" [critical-data]="logs *.tmp" [gmer4lfe]="logs *.tmp" [important-data]="logs *.tmp" [emby]="logs *.tmp" ) # ============================================================================================== # ── FAILOVER ────────────────────────────────────────────────────────────────────────────────── # ============================================================================================== # Mutual container failover between two unRAID servers. # Each server runs failover.sh independently — no coordination between servers. # Decisions based solely on two ping checks: remote reachable + internet reachable. # Comment out any container or rsync job to disable without removing the entry. EXTERNAL_IP="8.8.8.8" FAILOVER_CHECK_INTERVAL=120 FAILOVER_HANDBACK_STRIKES=2 FAILOVER_STATE_FILE="/boot/config/failover_state.db" # Containers HOST1 starts locally when HOST2 goes down FAILOVER_HOST1_STARTS_FOR_HOST2=( "Vaultwarden-Jayred365" "Nextcloud-Jayred365" "Cloudflare-DDNS-Jayred365" ) # Containers HOST1 stops when it loses internet FAILOVER_HOST1_STOP_ON_NO_NET=( "Emby" "Cloudflare-DDNS-Gmer4Lfe" ) # Rsync jobs HOST1 runs before handing containers back to HOST2 FAILOVER_HOST1_RSYNC_JOBS=( "/mnt/user/appdata-Failover/Jayred365" "/mnt/user/Media_Server/Emby-Jayred" ) # Containers HOST2 starts locally when HOST1 goes down FAILOVER_HOST2_STARTS_FOR_HOST1=( "Emby" "Cloudflare-DDNS-Gmer4Lfe" ) # Containers HOST2 stops when it loses internet FAILOVER_HOST2_STOP_ON_NO_NET=( "Cloudflare-DDNS-Jayred365" ) # Rsync jobs HOST2 runs before handing containers back to HOST1 FAILOVER_HOST2_RSYNC_JOBS=( "/mnt/user/appdata-Failover/Gmer4Lfe" ) # ============================================================================================== # ── DOCKER ESSENTIALS ───────────────────────────────────────────────────────────────────────── # ============================================================================================== # ━━━ Docker Daily Restart ━━━ DAILY_RESTART_CONTAINERS=( "NginxProxyManager" "Authelia" "Dispatcharr-Iptv-Users" "Dispatcharr" "Dispatcharr-Basic" "Code-Server" ) # ━━━ Docker Weekly Restart ━━━ WEEKLY_RESTART_CONTAINERS=( "NginxProxyManager" "Authelia" "Dispatcharr-Iptv-Users" "Dispatcharr" "Dispatcharr-Basic" "Code-Server" ) # ━━━ Docker Watchdog ━━━ # 20GB=20480 16GB=16384 14GB=14336 12GB=12288 10GB=10240 # 8GB=8192 6GB=6144 4GB=4096 2GB=2048 1GB=1024 declare -A WATCHDOG_CONTAINERS=( ["Emby"]=16384 ["jellyfin_with_request"]=12288 ["LidaTube"]=6144 ["Tdarr"]=6144 ["Code-Server"]=1024 ) declare -A WATCHDOG_CONTAINER_URLS=( ["Emby"]="http://localhost:8096" ["Jellyfin-Gmer4Lfe"]="http://localhost:8095" ) WATCHDOG_REQUIRED_CONTAINERS=( "NginxProxyManager" "Authelia" "Emby" ) WATCHDOG_STATE_FILE="/tmp/container_watchdog_state.db" SOFT_CPU_THRESHOLD=80 HARD_CPU_THRESHOLD=85 CPU_FAIL_LIMIT=2 SOFT_MEM_THRESHOLD=80 RESP_FAIL_LIMIT=2 CURL_TIMEOUT=5 # ━━━ Docker Network Connect ━━━ # Containers connected to extra networks on array start — many-to-many # Every container connects to every network listed # Comment out entries to disable without removing them NETWORK_CONNECT_CONTAINERS=( "memcached" "Npm-CrowdSec" ) NETWORK_CONNECT_NETWORKS=( "nextcloud-aio" ) # ============================================================================================== # ── UNRAID ESSENTIALS ───────────────────────────────────────────────────────────────────────── # ============================================================================================== # ━━━ Reboot ━━━ REBOOT_SLEEP=300 # ━━━ Mover ━━━ MOVER_STOP_TIMEOUT=300 # ━━━ Syslog Filter ━━━ FILTER_FILE="/etc/rsyslog.d/ignore-docker-veth.conf" # ━━━ PHP-FPM ━━━ PHP_CONF="/etc/php-fpm.d/www.conf" PHP_MAX_CHILDREN=250 # ━━━ Clear Logs ━━━ LOG_FILES=(/var/log/syslog /var/log/messages /var/log/dmesg) # ━━━ WebGUI Watchdog ━━━ # Monitors unRAID WebGUI — escalates from nginx restart to emhttp restart if needed WEBGUI_URL="http://localhost" # adjust port if running non-standard e.g. http://localhost:8080 WEBGUI_TIMEOUT=5 # seconds before curl gives up WEBGUI_NGINX_WAIT=15 # seconds to wait after nginx restart before recheck WEBGUI_EMHTTP_WAIT=30 # seconds to wait after emhttp restart before recheck # ━━━ ZFS Memory Snapshot ━━━ # Weekly ZFS health and memory diagnostic report ZFS_REPORT_LOG="/var/log/zfs-weekly-health.log" ZFS_REPORT_ARC_WARN_PCT=90 # warn if ARC utilization above this % ZFS_REPORT_FREE_WARN_GB=10 # warn if free RAM below this GB ZFS_REPORT_AVAIL_WARN_GB=20 # warn if available RAM below this GB ZFS_REPORT_DOCKER_TOP=10 # number of top Docker memory users to show # ============================================================================================== # ── MEDIA ───────────────────────────────────────────────────────────────────────────────────── # ============================================================================================== # ━━━ Media Permissions ━━━ PERMISSIONS_MODE="777" PERMISSIONS_OWNER="nobody:users" MEDIA_PERMISSION_SHARES=( /mnt/user/Anime_Movies /mnt/user/Anime_Movies-Old /mnt/user/Anime_Shows /mnt/user/Anime_Shows-Old /mnt/user/appcache /mnt/user/Books /mnt/user/Downloads /mnt/user/Games /mnt/user/Intros /mnt/user/Kids_Movies /mnt/user/Kids_Tv_Shows /mnt/user/Movie_Recordings /mnt/user/Movies /mnt/user/Music /mnt/user/Music_Videos /mnt/user/Photo /mnt/user/Sports /mnt/user/stand-up_comedy /mnt/user/Temp_Storage /mnt/user/Tv_Recordings /mnt/user/Tv_Shows /mnt/user/YouTube ) # ━━━ Media Cleaner ━━━ ANIME_CLEAN_FOLDERS=( /mnt/user/Anime_Movies /mnt/user/Anime_Movies-Old /mnt/user/Anime_Shows /mnt/user/Anime_Shows-Old ) MEDIA_CLEAN_FOLDERS=( /mnt/user/Kids_Movies /mnt/user/Kids_Tv_Shows /mnt/user/Movies /mnt/user/Music /mnt/user/Sports /mnt/user/stand-up_comedy /mnt/user/Tv_Shows ) ANIME_FILE_PATTERNS=( '*.sfv' '*.md5' '*.sha1' '*.txt' '*.url' '*.lnk' '*.rar' '*.zip' '*.info' '*.torrent' '*.sample*' '*.proof*' '*sync-conflict*' '*.scr' '*.srr' '*.exe' '*.webp' '*.log' '*.json' ) MEDIA_FILE_PATTERNS=( '*.sfv' '*.md5' '*.sha1' '*.txt' '*.url' '*.lnk' '*.rar' '*.zip' '*.info' '*.torrent' '*.sample*' '*.proof*' '*sync-conflict*' '*.scr' '*.srr' '*.exe' '*.webp' '*.log' '*.json' '*.iso' '*.lrc' ) # ============================================================================================== # ── TRANSCODES ──────────────────────────────────────────────────────────────────────────────── # ============================================================================================== RAMDISK_PATH="/mnt/ramdisk_transcodes" RAMDISK_SIZE="8G" TRANSCODE_LINK="/mnt/ram-transcode" TRANSCODE_SSD="/mnt/cache/Temp_Storage/Emby/Transcodes/" RAMDISK_WARN_GB=6.8 RAMDISK_LOW_GB=5.5 RAMDISK_SSD_MIN_GB=20 TRANSCODE_MAX_AGE=20 TRANSCODE_ORPHAN_AGE=30 TRANSCODE_FLIP_WARN=3 TRANSCODE_OWNER="nobody:users" TRANSCODE_MODE="755" # ============================================================================================== # ── SYSTEM WATCHDOG ─────────────────────────────────────────────────────────────────────────── # ============================================================================================== SYS_WATCHDOG_STATE_FILE="/tmp/system_watchdog_state.db" SYS_WATCHDOG_FAILED_FILE="/boot/config/system_watchdog_failed.db" SYS_WATCHDOG_REBOOT_LOG="/boot/config/system_watchdog_reboots.db" SYS_WATCHDOG_STRIKE_LIMIT=2 SYS_WATCHDOG_REBOOT_LIMIT=3 SYS_WATCHDOG_REBOOT_WINDOW_HRS=12 SYS_WATCHDOG_ROOTFS_PCT=95 SYS_WATCHDOG_LOG_PCT=95 SYS_WATCHDOG_MEM_GB=4 SYS_WATCHDOG_ARC_PINNED_PCT=98 SYS_WATCHDOG_ARC_RELEASE_PCT=95 SYS_WATCHDOG_LOAD_MULTIPLIER=3 SYS_WATCHDOG_ZOMBIE_LIMIT=50 SYS_WATCHDOG_CPU_TEMP_MAX=95 SYS_WATCHDOG_CHECK_ROOTFS=true SYS_WATCHDOG_CHECK_LOG=true SYS_WATCHDOG_CHECK_RAM=true SYS_WATCHDOG_CHECK_ARC=true SYS_WATCHDOG_CHECK_CPU_TEMP=true SYS_WATCHDOG_CHECK_LOAD=false SYS_WATCHDOG_CHECK_ZOMBIES=true SYS_WATCHDOG_CHECK_CONTAINERS=true SYS_WATCHDOG_CHECK_DOCKER_DAEMON=true SYS_WATCHDOG_ABORT_ON_ZFS_UNHEALTHY=true SYS_WATCHDOG_ABORT_ON_PARITY=true SYS_WATCHDOG_ABORT_ON_MOVER=true # ============================================================================================== # ──────────────────────── End Of User Variables ─────────────────────────────────────────────── # ==============================================================================================