From a932232da77ff68453680ec576d7cc143922f49d Mon Sep 17 00:00:00 2001 From: FailedProxy Date: Sat, 21 Mar 2026 21:34:42 +0000 Subject: [PATCH] imporved --- Master.conf | 25 +++++++----------- Rsync/README_Rsync_Setup.md | 18 +++++++++++++ Rsync/git_pull_execute.sh | 37 ++++++++++++++++++++++++++ Rsync/rsync.sh | 7 ++--- Rsync/user_script_pluin.sh | 52 +++++++++++++++++++++++++++++++++++++ 5 files changed, 121 insertions(+), 18 deletions(-) create mode 100644 Rsync/README_Rsync_Setup.md create mode 100644 Rsync/git_pull_execute.sh create mode 100644 Rsync/user_script_pluin.sh diff --git a/Master.conf b/Master.conf index 967566d..21e3680 100644 --- a/Master.conf +++ b/Master.conf @@ -4,13 +4,12 @@ ################################################################################################## #----------------------------------------------------------------------------------------------- -#----------------------------- Host Detection --------------------------------------------------- +#----------------------------- Host and Remote Detection --------------------------------------- #----------------------------------------------------------------------------------------------- # Define the hostnames of both servers HOST1="unRAID-Gmer4Lfe" HOST2="unRAID-Jayred365" - # Detect local hostname LOCAL_HOSTNAME="$(hostname)" if [[ "$LOCAL_HOSTNAME" == "$HOST1" ]]; then @@ -27,7 +26,7 @@ echo "Local server: $LOCAL_SERVER_NAME" echo "Remote server: $REMOTE_SERVER_NAME" #----------------------------------------------------------------------------------------------- -#----------------------------- Remote Server Resolution ----------------------------------------- +#--------------------------- Remote Server Ip Resolution ---------------------------------------- #----------------------------------------------------------------------------------------------- # Resolve Tailscale IP dynamically REMOTE_SERVER=$(tailscale ip -4 "$REMOTE_SERVER_NAME" 2>/dev/null) @@ -78,19 +77,15 @@ CONTAINER_DELAY=5 #----------------------------------------------------------------------------------------------- # Profiles are inferred from the directory basename (lowercased) -#----------------------------------------------------------------------------------------------- -#----------------------------- Profile Performance Tuning --------------------------------------- -#----------------------------------------------------------------------------------------------- - # Max rsync processes per profile declare -A PROFILE_MAX_PROCS PROFILE_MAX_PROCS["arrs_stack"]=2 -PROFILE_MAX_PROCS["movies"]=1 +PROFILE_MAX_PROCS["critical-data"]=2 PROFILE_MAX_PROCS["shows"]=1 # Bandwidth limits per profile (KB/s, 0 = unlimited) declare -A PROFILE_BW_LIMIT PROFILE_BW_LIMIT["arrs_stack"]=5000 -PROFILE_BW_LIMIT["movies"]=0 +PROFILE_BW_LIMIT["critical-data"]=9500 PROFILE_BW_LIMIT["shows"]=8000 # Retry logic per profile declare -A PROFILE_RETRY_COUNT @@ -100,22 +95,22 @@ PROFILE_RETRY_COUNT["shows"]=3 # Sleep between retries per profile (seconds) declare -A PROFILE_SLEEP PROFILE_SLEEP["arrs_stack"]=300 -PROFILE_SLEEP["movies"]=300 +PROFILE_SLEEP["critical-data"]=300 PROFILE_SLEEP["shows"]=300 # Containers to stop/start per profile (space-separated strings) declare -A PROFILE_CRITICAL_CONTAINER_NAMES PROFILE_CRITICAL_CONTAINER_NAMES["arrs_stack"]="Sonarr Lidarr Readarr Radarr Prowlarr Bazarr Pinchflat" -PROFILE_CRITICAL_CONTAINER_NAMES["movies"]="" +PROFILE_CRITICAL_CONTAINER_NAMES["critical-data"]="" PROFILE_CRITICAL_CONTAINER_NAMES["shows"]="" # Delayed containers per profile (space-separated strings) declare -A PROFILE_DELAYED_CONTAINERS -PROFILE_DELAYED_CONTAINERS["arrs_stack"]="" -PROFILE_DELAYED_CONTAINERS["movies"]="" +PROFILE_DELAYED_CONTAINERS["arrs_stack"]="Mariadb-Authelia Redis-Authelia Lldap-Gmer4Lfe NginxProxyManager Authelia" +PROFILE_DELAYED_CONTAINERS["critical-data"]="Authelia" PROFILE_DELAYED_CONTAINERS["shows"]="" -# Delay in seconds before starting delayed containers per profile +# Delay in seconds before starting delayed containers per profile (seconds) declare -A PROFILE_CONTAINER_DELAY PROFILE_CONTAINER_DELAY["arrs_stack"]=5 -PROFILE_CONTAINER_DELAY["movies"]=0 +PROFILE_CONTAINER_DELAY["critical-data"]=10 PROFILE_CONTAINER_DELAY["shows"]=0 #----------------------------------------------------------------------------------------------- diff --git a/Rsync/README_Rsync_Setup.md b/Rsync/README_Rsync_Setup.md new file mode 100644 index 0000000..23275db --- /dev/null +++ b/Rsync/README_Rsync_Setup.md @@ -0,0 +1,18 @@ +This is the Rsync Setup Guide + This guide is a work in progress + + +First git Repository need installed at /mnt/user/appdata/unraid_scripts/ + Then made executable, copy and paste contents of git_pull_execute.sh script to a new script in unRAID User Scripts + +in unRAID User Scripts, to use scripts in git + Create a new Script and name it whatever + You can copy contents of user_script_pluin.sh and paste then change acordingly + or + add a line pointing to script plus local folder to be synced + Exampl = /mnt/user/appdata/unraid_scripts/Rsync/rsync.sh /mnt/user/appdata-test/Arrs/ + +This opens the script and passes the folder overas an argument + This allows for multiple rsync ops running off a single core script + +All changes made to 1 single core script then works for all user scripts that point to rsync.sh diff --git a/Rsync/git_pull_execute.sh b/Rsync/git_pull_execute.sh new file mode 100644 index 0000000..ed2154f --- /dev/null +++ b/Rsync/git_pull_execute.sh @@ -0,0 +1,37 @@ +#!/bin/bash +set -e + +# ----------------------------- +# Configurable variables +# ----------------------------- +REPO_SSH="git@192.168.50.2:FailedProxy/Unraid_Scripts.git" +TARGET_DIR="/mnt/user/appdata/unraid_scripts" +SSH_KEY="/root/.ssh/id_gitea_rsync" +SSH_PORT=221 + +# ----------------------------- +# Create target directory if it doesn't exist +# ----------------------------- +mkdir -p "$TARGET_DIR" +cd "$TARGET_DIR" + +# ----------------------------- +# Clone or pull repo (discard local changes) +# ----------------------------- +if [ -d ".git" ]; then + echo "Repository already exists. Resetting local changes and pulling latest..." + git reset --hard + git clean -fd + GIT_SSH_COMMAND="ssh -i $SSH_KEY -p $SSH_PORT" git pull +else + echo "Cloning $REPO_SSH into $TARGET_DIR..." + GIT_SSH_COMMAND="ssh -i $SSH_KEY -p $SSH_PORT" git clone "$REPO_SSH" . +fi + +# ----------------------------- +# Ensure scripts are executable +# ----------------------------- +echo "Setting executable permissions on scripts..." +find "$TARGET_DIR" -type f -name "*.sh" -exec chmod +x {} \; + +echo "Repository is up to date and scripts are executable." \ No newline at end of file diff --git a/Rsync/rsync.sh b/Rsync/rsync.sh index 4735f55..46f59a1 100644 --- a/Rsync/rsync.sh +++ b/Rsync/rsync.sh @@ -3,6 +3,7 @@ set -e #----------------------------------------------------------------------------------------------- #----------------- User Variables, Please adjust in Master.cong as needed ---------------------- #----------------------------------------------------------------------------------------------- +# This is the main Core Rsync script # # User vaiables can be adjusted in Master.conf # scripts now just contain runtime codes @@ -10,10 +11,10 @@ set -e # This allows for profiles and multiple things to use the core script # use arguments in unRAID User Plugin for directory # Example = /mnt/user/appdata/unraid_scripts/Rsync/rsync.sh -# /mnt/user/appdata-Failover/Arrs_Stack/ +# /mnt/user/appdata-test/Arrs/ # -# /mnt/user/appdata-Failover/Arrs_Stack/ is the argument -# If the last name /Arrs-Stack/ matches a profile in Master.conf then profiles are used +# /mnt/user/appdata-test/Arrs/ is the argument +# If the last name /Arrs/ matches a profile in Master.conf then profiles are used # If no matches then Global Configureation is used in Master.conf # #----------------------------------------------------------------------------------------------- diff --git a/Rsync/user_script_pluin.sh b/Rsync/user_script_pluin.sh new file mode 100644 index 0000000..6519636 --- /dev/null +++ b/Rsync/user_script_pluin.sh @@ -0,0 +1,52 @@ +!/bin/bash +#----------------------------------------------------------------------------------------------- +#------------------------------------- Rsync command ------------------------------------------- +#----------------------------------------------------------------------------------------------- + +/mnt/user/appdata/unraid_scripts/Rsync/rsync.sh /mnt/user/appdata-test/Arrs/ + +#----------------------------------------------------------------------------------------------- +#-------------------------------------------- Info --------------------------------------------- +#----------------------------------------------------------------------------------------------- +# +# These global configuartions can be added as arguments at the end of the script after folder location +# Its better to add profile in Master.conf for perm changes +# Profiles in Master.conf match the last string of folder location +# if a match is made with a list in Master.conf then the associated profile will be used +# If no match is made it defualts to global defualts +# +#----------------------------------------------------------------------------------------------- +#----------------- User Variables, Please adjust in Master.cong as needed ---------------------- +#----------------------------------------------------------------------------------------------- +# +# Does a dry run making no changes +#--dry-run +# +# Network speed limit (KB/s) +#BW_LIMIT=12500 +# +# Retry logic +#RETRY_COUNT=3 +# +# Sleep between retries (seconds) +#SLEEP=300 +# +# Max number of concurrently running rsync processes +#MAX_RSYNC_PROCS=1 +# +# Container start/stop/restart before and after rsync +#CRITICAL_CONTAINER_NAMES=() +# +# Containers that need delayed before starting +#DELAYED_CONTAINERS=() +# +# Delay in seconds between starting containers, useful for things like Authelia +#CONTAINER_DELAY=5 +# +#----------------------------------------------------------------------------------------------- +#---------------End Of User Variables, Please adjust in Master.cong as needed ------------------ +#----------------------------------------------------------------------------------------------- +# +#Examples +#/mnt/user/appdata/unraid_scripts/Rsync/rsync.sh /mnt/user/appdata-test/Arrs/ MAX_RSYNC_PROCS=2 +#/mnt/user/appdata/unraid_scripts/Rsync/rsync.sh /mnt/user/appdata-test/Arrs/ --dry-run MAX_RSYNC_PROCS=2 \ No newline at end of file