Structure change and vissually fixing code to make it easier to read
This commit is contained in:
+35
-30
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#-----------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------
|
||||||
#----------------------------- Master Variables for unRAID scripts -----------------------------
|
# ---------------------------- Master Variables for unRAID scripts -----------------------------
|
||||||
#-----------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------
|
||||||
# This is the master.conf file, it contains all the variables used by
|
# This is the master.conf file, it contains all the variables used by
|
||||||
# all scripts.
|
# all scripts.
|
||||||
#
|
#
|
||||||
@@ -11,56 +11,61 @@
|
|||||||
# This is where you should adjust any settings or variables
|
# This is where you should adjust any settings or variables
|
||||||
# that you want to apply globally across all your scripts
|
# that you want to apply globally across all your scripts
|
||||||
#
|
#
|
||||||
#-----------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------
|
||||||
#----------------- User Variables, Please adjust here in Master.conf as needed -----------------
|
# ---------------- User Variables, Please adjust here in Master.conf as needed -----------------
|
||||||
#-----------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#-------------------- Host Configuration --------------------
|
# ----------------------- Host Configuration --------------------
|
||||||
# List the Hostnames of both servers
|
# List the Hostnames of both servers
|
||||||
HOST1="unRAID-Gmer4Lfe"
|
HOST1="unRAID-Gmer4Lfe"
|
||||||
HOST2="unRAID-Jayred365"
|
HOST2="unRAID-Jayred365"
|
||||||
# Assign SSH keys for each host pair (adjust paths as needed) HOST1 from above
|
# Assign SSH keys for each host pair (adjust paths as needed) HOST1 from above
|
||||||
# Must have its key added to HOST1_SSH_Key same applies for HOST2
|
# Must have its key added to HOST1_SSH_Key same applies for HOST2
|
||||||
HOST1_SSH_KEY="/root/.ssh/Gmer4Lfe-rsync-key"
|
HOST1_SSH_KEY="/root/.ssh/Gmer4Lfe-rsync-key"
|
||||||
HOST2_SSH_KEY="/root/.ssh/Jayred365-rsync-key"
|
HOST2_SSH_KEY="/root/.ssh/Jayred365-rsync-key"
|
||||||
|
|
||||||
# -------------------------- Logging ---------------------------
|
# -------------------------- Logging ----------------------------
|
||||||
ENABLE_LOGGING=true # false = only echo user-facing messages
|
ENABLE_LOGGING=true # false = only echo user-facing messages
|
||||||
|
|
||||||
|
# ------------------ Git, Pull & Execute Script -----------------
|
||||||
|
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
|
||||||
|
|
||||||
#--------------------Rsync Script Defaults-----------------------
|
# -------------------Rsync Script Defaults-----------------------
|
||||||
# Network speed limit (KB/s)
|
# Network speed limit (KB/s)
|
||||||
BW_LIMIT=12500
|
BW_LIMIT=12500
|
||||||
# Retry logic
|
# Retry logic
|
||||||
RETRY_COUNT=3
|
RETRY_COUNT=3
|
||||||
# Sleep between retries (seconds)
|
# Sleep between retries (seconds)
|
||||||
SLEEP=300
|
SLEEP=300
|
||||||
# Max number of concurrently running rsync processes
|
# Max number of concurrently running rsync processes
|
||||||
MAX_RSYNC_PROCS=1
|
MAX_RSYNC_PROCS=1
|
||||||
# Container start/stop/restart before and after rsync
|
# Container start/stop/restart before and after rsync
|
||||||
CRITICAL_CONTAINER_NAMES=("")
|
CRITICAL_CONTAINER_NAMES=("")
|
||||||
# Containers that need delayed before starting
|
# Containers that need delayed before starting
|
||||||
DELAYED_CONTAINERS=("")
|
DELAYED_CONTAINERS=("")
|
||||||
# Delay in seconds between starting containers, useful for things like Authelia
|
# Delay in seconds between starting containers, useful for things like Authelia
|
||||||
CONTAINER_DELAY=5
|
CONTAINER_DELAY=5
|
||||||
# Not include logs during transfer
|
# Not include logs during transfer
|
||||||
EXCLUDE_DIRS=("")
|
EXCLUDE_DIRS=("")
|
||||||
# Default global rsync options
|
# Default global rsync options
|
||||||
DEFAULT_RSYNC_OPTS=(-av --info=progress2 --human-readable --bwlimit="$BW_LIMIT" --delete --inplace --no-whole-file)
|
DEFAULT_RSYNC_OPTS=(-av --info=progress2 --human-readable --bwlimit="$BW_LIMIT" --delete --inplace --no-whole-file)
|
||||||
|
|
||||||
#-------------------- unRAID essentail scripts ------------------
|
# ------------------- unRAID essentail scripts ------------------
|
||||||
# unRAID reboot script user warning time (seconds)
|
# unRAID reboot script user warning time (seconds)
|
||||||
REBOOT_SLEEP=300
|
REBOOT_SLEEP=300
|
||||||
# unRAID mover stop script timeout (seconds)
|
# unRAID mover stop script timeout (seconds)
|
||||||
MOVER_STOP_TIMEOUT=300
|
MOVER_STOP_TIMEOUT=300
|
||||||
# docker_syslog_filter.sh filter file path
|
# docker_syslog_filter.sh filter file path
|
||||||
FILTER_FILE="/etc/rsyslog.d/ignore-docker-veth.conf"
|
FILTER_FILE="/etc/rsyslog.d/ignore-docker-veth.conf"
|
||||||
# php_fpm_max_children.sh php-fpm config file path
|
# php_fpm_max_children.sh php-fpm config file path
|
||||||
PHP_CONF="/etc/php-fpm.d/www.conf"
|
PHP_CONF="/etc/php-fpm.d/www.conf"
|
||||||
# php_fpm_max_children.sh max children value
|
# php_fpm_max_children.sh max children value
|
||||||
PHP_MAX_CHILDREN=250
|
PHP_MAX_CHILDREN=250
|
||||||
|
|
||||||
#---------------------- Profile System -------------------------
|
# --------------------- Profile System -------------------------
|
||||||
# Profiles are inferred from the directory basename (lowercased)
|
# Profiles are inferred from the directory basename (lowercased)
|
||||||
# Profile-specific rsync options (override global) must list all options as they do not inherit from global
|
# Profile-specific rsync options (override global) must list all options as they do not inherit from global
|
||||||
# For example, look up at global rsync options above
|
# For example, look up at global rsync options above
|
||||||
|
|||||||
@@ -12,7 +12,12 @@ in unRAID User Scripts, to use scripts in git
|
|||||||
add a line pointing to script plus local folder to be synced
|
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/
|
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 opens the script and passes the folder over as an argument
|
||||||
This allows for multiple rsync ops running off a single core script
|
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
|
All changes made to 1 single core script then works for all user scripts that point to rsync.sh
|
||||||
|
|
||||||
|
The Master.conf file is where all user changeable variables live, This is for all scripts
|
||||||
|
|
||||||
|
A common.sh file also is used to share all common codes that multiple scripts use
|
||||||
|
This allows for easier managment of scripts, editing, and what not
|
||||||
+88
-26
@@ -1,37 +1,99 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
# ----------------------------------------------------------------------------------------------
|
||||||
|
# --------------------------------- Git, Pull & Exectute Script --------------------------------
|
||||||
|
# ----------------------------------------------------------------------------------------------
|
||||||
|
# ---------------- User Variables, Please adjust in Master.conf as needed ----------------------
|
||||||
|
# ----------------------------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# User variables can be adjusted in Master.conf
|
||||||
|
#
|
||||||
|
# Scripts now just contain runtime logic
|
||||||
|
#
|
||||||
|
# This new setup allows for profiles and arguments to use the core script
|
||||||
|
# ----------------------------------------------------------------------------------------------
|
||||||
|
# -------------- End Of User Variables, Please adjust in Master.conf as needed -----------------
|
||||||
|
# ----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# -----------------------------
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
# Configurable variables
|
|
||||||
# -----------------------------
|
# Core System
|
||||||
REPO_SSH="git@192.168.50.2:FailedProxy/Unraid_Scripts.git"
|
source "$SCRIPT_DIR/../Master.conf"
|
||||||
TARGET_DIR="/mnt/user/appdata/unraid_scripts"
|
source "$SCRIPT_DIR/../common.sh"
|
||||||
SSH_KEY="/root/.ssh/id_gitea_rsync"
|
|
||||||
SSH_PORT=221
|
parse_args "$@"
|
||||||
|
|
||||||
|
# Status Mode
|
||||||
|
echo "===== GIT SYNC STATUS ====="
|
||||||
|
echo "Repo: $REPO_SSH"
|
||||||
|
echo "Target: $TARGET_DIR"
|
||||||
|
echo "SSH Key: $SSH_KEY"
|
||||||
|
echo "SSH Port: $SSH_PORT"
|
||||||
|
echo "Logging: $ENABLE_LOGGING"
|
||||||
|
echo "Dry Run: $DRY_RUN"
|
||||||
|
echo "==========================="
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Validation
|
||||||
|
require_var REPO_SSH
|
||||||
|
require_var TARGET_DIR
|
||||||
|
require_var SSH_KEY
|
||||||
|
require_var SSH_PORT
|
||||||
|
|
||||||
|
# Start
|
||||||
|
info "Starting repository sync"
|
||||||
|
log "Repo: $REPO_SSH"
|
||||||
|
log "Target: $TARGET_DIR"
|
||||||
|
|
||||||
# -----------------------------
|
|
||||||
# Create target directory if it doesn't exist
|
|
||||||
# -----------------------------
|
|
||||||
mkdir -p "$TARGET_DIR"
|
mkdir -p "$TARGET_DIR"
|
||||||
cd "$TARGET_DIR"
|
cd "$TARGET_DIR"
|
||||||
|
|
||||||
# -----------------------------
|
# Dry Run
|
||||||
# Clone or pull repo (discard local changes)
|
if [[ "$DRY_RUN" == true ]]; then
|
||||||
# -----------------------------
|
info "Dry-run mode enabled"
|
||||||
if [ -d ".git" ]; then
|
info "Would sync repository: $REPO_SSH"
|
||||||
echo "Repository already exists. Resetting local changes and pulling latest..."
|
info "Would target directory: $TARGET_DIR"
|
||||||
git reset --hard
|
exit 0
|
||||||
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
|
fi
|
||||||
|
|
||||||
# -----------------------------
|
# Git Logic
|
||||||
# Ensure scripts are executable
|
if [[ -d ".git" ]]; then
|
||||||
# -----------------------------
|
info "Existing repo detected → updating"
|
||||||
echo "Setting executable permissions on scripts..."
|
|
||||||
|
log "git reset --hard"
|
||||||
|
git reset --hard
|
||||||
|
|
||||||
|
log "git clean -fd"
|
||||||
|
git clean -fd
|
||||||
|
|
||||||
|
info "Pulling latest changes..."
|
||||||
|
GIT_SSH_COMMAND="ssh -i $SSH_KEY -p $SSH_PORT" git pull
|
||||||
|
|
||||||
|
else
|
||||||
|
info "No repo found → cloning"
|
||||||
|
|
||||||
|
log "git clone $REPO_SSH"
|
||||||
|
|
||||||
|
GIT_SSH_COMMAND="ssh -i $SSH_KEY -p $SSH_PORT" \
|
||||||
|
git clone "$REPO_SSH" .
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Permissions
|
||||||
|
info "Setting script permissions..."
|
||||||
|
|
||||||
find "$TARGET_DIR" -type f -name "*.sh" -exec chmod +x {} \;
|
find "$TARGET_DIR" -type f -name "*.sh" -exec chmod +x {} \;
|
||||||
|
|
||||||
echo "Repository is up to date and scripts are executable."
|
# Summary
|
||||||
|
echo "===== GIT SYNC SUMMARY ====="
|
||||||
|
echo "Repository: $REPO_SSH"
|
||||||
|
echo "Directory: $TARGET_DIR"
|
||||||
|
echo "Status: SUCCESS"
|
||||||
|
echo "Logging: $ENABLE_LOGGING"
|
||||||
|
echo "Dry Run: $DRY_RUN"
|
||||||
|
echo "============================"
|
||||||
|
|
||||||
|
info "Repository sync complete"
|
||||||
+24
-7
@@ -1,5 +1,22 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
# ----------------------------------------------------------------------------------------------
|
||||||
|
# --------------------------------- Rsync Core Script ------------------------------------------
|
||||||
|
# ----------------------------------------------------------------------------------------------
|
||||||
|
# ---------------- User Variables, Please adjust in Master.conf as needed ----------------------
|
||||||
|
# ----------------------------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# User variables can be adjusted in Master.conf
|
||||||
|
#
|
||||||
|
# Scripts now just contain runtime logic
|
||||||
|
#
|
||||||
|
# This new setup allows for profiles and arguments to use the core script
|
||||||
|
#
|
||||||
|
# Use arguments in unRAID User Plugin for directory
|
||||||
|
# Example = /mnt/user/appdata/unraid_scripts/Rsync/rsync.sh --dry-run
|
||||||
|
# ----------------------------------------------------------------------------------------------
|
||||||
|
# -------------- End Of User Variables, Please adjust in Master.conf as needed -----------------
|
||||||
|
# ----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
@@ -7,7 +24,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|||||||
source "$SCRIPT_DIR/../Master.conf"
|
source "$SCRIPT_DIR/../Master.conf"
|
||||||
source "$SCRIPT_DIR/../common.sh"
|
source "$SCRIPT_DIR/../common.sh"
|
||||||
|
|
||||||
# ----------------------------- Input -----------------------------
|
# Input
|
||||||
DIRECTORY="$1"
|
DIRECTORY="$1"
|
||||||
if [[ -z "$DIRECTORY" ]]; then
|
if [[ -z "$DIRECTORY" ]]; then
|
||||||
echo "Usage: $0 <directory-to-sync> [--dry-run] [VAR=value ...]"
|
echo "Usage: $0 <directory-to-sync> [--dry-run] [VAR=value ...]"
|
||||||
@@ -16,11 +33,11 @@ fi
|
|||||||
shift
|
shift
|
||||||
parse_args "$@"
|
parse_args "$@"
|
||||||
|
|
||||||
# ----------------------------- Host & IP -----------------------------
|
# Host & IP
|
||||||
detect_hosts
|
detect_hosts
|
||||||
resolve_remote_ip
|
resolve_remote_ip
|
||||||
|
|
||||||
# ----------------------------- Profile -----------------------------
|
# Profile
|
||||||
PROFILE_NAME=$(basename "$DIRECTORY" | tr '[:upper:]' '[:lower:]')
|
PROFILE_NAME=$(basename "$DIRECTORY" | tr '[:upper:]' '[:lower:]')
|
||||||
|
|
||||||
MAX_RSYNC_PROCS=${PROFILE_MAX_PROCS[$PROFILE_NAME]:-$MAX_RSYNC_PROCS}
|
MAX_RSYNC_PROCS=${PROFILE_MAX_PROCS[$PROFILE_NAME]:-$MAX_RSYNC_PROCS}
|
||||||
@@ -32,14 +49,14 @@ RETRY_COUNT=${PROFILE_RETRY_COUNT[$PROFILE_NAME]:-$RETRY_COUNT}
|
|||||||
SLEEP=${PROFILE_SLEEP[$PROFILE_NAME]:-$SLEEP}
|
SLEEP=${PROFILE_SLEEP[$PROFILE_NAME]:-$SLEEP}
|
||||||
EXCLUDE_DIRS=(${PROFILE_EXCLUDE_DIRS[$PROFILE_NAME]:-${EXCLUDE_DIRS[@]}})
|
EXCLUDE_DIRS=(${PROFILE_EXCLUDE_DIRS[$PROFILE_NAME]:-${EXCLUDE_DIRS[@]}})
|
||||||
|
|
||||||
# ----------------------------- Status Mode -----------------------------
|
# Status Mode
|
||||||
if [[ "$SHOW_STATUS" == true ]]; then
|
if [[ "$SHOW_STATUS" == true ]]; then
|
||||||
show_status
|
show_status
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------- User Info -----------------------------
|
# User Info
|
||||||
echo "============================================================"
|
echo "============================================================"
|
||||||
echo " Sync Job Starting"
|
echo " Sync Job Starting"
|
||||||
echo "------------------------------------------------------------"
|
echo "------------------------------------------------------------"
|
||||||
@@ -53,7 +70,7 @@ log "Settings: MAX_RSYNC_PROCS=$MAX_RSYNC_PROCS, BW_LIMIT=$BW_LIMIT"
|
|||||||
log "Containers: ${CRITICAL_CONTAINER_NAMES[*]}"
|
log "Containers: ${CRITICAL_CONTAINER_NAMES[*]}"
|
||||||
log "Excludes: ${EXCLUDE_DIRS[*]}"
|
log "Excludes: ${EXCLUDE_DIRS[*]}"
|
||||||
|
|
||||||
# ----------------------------- Rsync Wait -----------------------------
|
# Rsync Wait
|
||||||
wait_for_rsync() {
|
wait_for_rsync() {
|
||||||
for attempt in $(seq 1 "$RETRY_COUNT"); do
|
for attempt in $(seq 1 "$RETRY_COUNT"); do
|
||||||
RSYNC_COUNT=$(pgrep -fc "rsync.*root@${REMOTE_SERVER}" || true)
|
RSYNC_COUNT=$(pgrep -fc "rsync.*root@${REMOTE_SERVER}" || true)
|
||||||
@@ -69,7 +86,7 @@ wait_for_rsync() {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# ----------------------------- Main -----------------------------
|
# Main
|
||||||
main() {
|
main() {
|
||||||
echo ""
|
echo ""
|
||||||
echo "🔍 Checking remote connectivity..."
|
echo "🔍 Checking remote connectivity..."
|
||||||
|
|||||||
+25
-22
@@ -1,17 +1,20 @@
|
|||||||
!/bin/bash
|
!/bin/bash
|
||||||
#-----------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------
|
||||||
#------------------------------------- Rsync command -------------------------------------------
|
# ------------------------------------ Rsync command -------------------------------------------
|
||||||
#-----------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
/mnt/user/appdata/unraid_scripts/Rsync/rsync.sh /mnt/user/appdata-test/Arrs/
|
/mnt/user/appdata/unraid_scripts/Rsync/rsync.sh /mnt/user/appdata-test/Arrs/
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------
|
||||||
#-------------------------------------------- Info ---------------------------------------------
|
# ------------------------------------------- Info ---------------------------------------------
|
||||||
#-----------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# These global configuartions can be added as arguments at the end of the script after folder location
|
# 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
|
# Its better to add profile in Master.conf for perm changes
|
||||||
|
#
|
||||||
# Profiles in Master.conf match the last string of folder location
|
# 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 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
|
# If no match is made it defualts to global defualts
|
||||||
|
|
||||||
@@ -20,15 +23,15 @@
|
|||||||
#----------------------------- Arguments, add after rsync command ------------------------------
|
#----------------------------- Arguments, add after rsync command ------------------------------
|
||||||
#-----------------------------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------------------------
|
||||||
# Does a dry run making no changes
|
# Does a dry run making no changes
|
||||||
#--dry-run
|
# --dry-run
|
||||||
#
|
#
|
||||||
#Force logging
|
# Force logging
|
||||||
#--log)
|
# --log)
|
||||||
#
|
#
|
||||||
#Force logging to be dissabled
|
# Force logging to be dissabled
|
||||||
#--no-log
|
# --no-log
|
||||||
#
|
#
|
||||||
#--help
|
# --help
|
||||||
#
|
#
|
||||||
# Example = /mnt/user/appdata/unraid_scripts/Rsync/rsync.sh /mnt/user/appdata-test/Arrs/ --dry-run --no-log
|
# Example = /mnt/user/appdata/unraid_scripts/Rsync/rsync.sh /mnt/user/appdata-test/Arrs/ --dry-run --no-log
|
||||||
#-----------------------------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------------------------
|
||||||
@@ -37,32 +40,32 @@
|
|||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Network speed limit (KB/s)
|
# Network speed limit (KB/s)
|
||||||
#BW_LIMIT=12500
|
# BW_LIMIT=12500
|
||||||
#
|
#
|
||||||
# Retry logic
|
# Retry logic
|
||||||
#RETRY_COUNT=3
|
# RETRY_COUNT=3
|
||||||
#
|
#
|
||||||
# Sleep between retries (seconds)
|
# Sleep between retries (seconds)
|
||||||
#SLEEP=300
|
# SLEEP=300
|
||||||
#
|
#
|
||||||
# Max number of concurrently running rsync processes
|
# Max number of concurrently running rsync processes
|
||||||
#MAX_RSYNC_PROCS=1
|
# MAX_RSYNC_PROCS=1
|
||||||
#
|
#
|
||||||
# Container start/stop/restart before and after rsync
|
# Container start/stop/restart before and after rsync
|
||||||
#CRITICAL_CONTAINER_NAMES=()
|
# CRITICAL_CONTAINER_NAMES=()
|
||||||
#
|
#
|
||||||
# Containers that need delayed before starting
|
# Containers that need delayed before starting
|
||||||
#DELAYED_CONTAINERS=()
|
# DELAYED_CONTAINERS=()
|
||||||
#
|
#
|
||||||
# Delay in seconds between starting containers, useful for things like Authelia
|
# Delay in seconds between starting containers, useful for things like Authelia
|
||||||
#CONTAINER_DELAY=5
|
# CONTAINER_DELAY=5
|
||||||
#
|
#
|
||||||
#-----------------------------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------------------------
|
||||||
#---------------End Of User Variables, Please adjust in Master.cong as needed ------------------
|
#---------------End Of User Variables, Please adjust in Master.cong as needed ------------------
|
||||||
#-----------------------------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
#Examples
|
# 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/ MAX_RSYNC_PROCS=2
|
||||||
#/mnt/user/appdata/unraid_scripts/Rsync/rsync.sh /mnt/user/appdata-test/Arrs/ --dry-run MAX_RSYNC_PROCS=2
|
# /mnt/user/appdata/unraid_scripts/Rsync/rsync.sh /mnt/user/appdata-test/Arrs/ --dry-run MAX_RSYNC_PROCS=2
|
||||||
#
|
#
|
||||||
# Copy and paste into unRAID User Script plugin
|
# Copy and paste into unRAID User Script plugin
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
# ----------------------- Common Helpers for Unraid Scripts -------------------------------------
|
# ----------------------- Common Helpers for Unraid Scripts -------------------------------------
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
# ----------------------------- Output Helpers -----------------------------
|
# Output Helpers
|
||||||
info() {
|
info() {
|
||||||
echo "[INFO] $*"
|
echo "[INFO] $*"
|
||||||
}
|
}
|
||||||
@@ -20,8 +20,7 @@ log() {
|
|||||||
[[ "$ENABLE_LOGGING" == true ]] && echo "[LOG] $*"
|
[[ "$ENABLE_LOGGING" == true ]] && echo "[LOG] $*"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ----------------------------- Argument Parsing -----------------------------
|
# Argument Parsing
|
||||||
parse_args() {
|
|
||||||
DRY_RUN=${DRY_RUN:-false}
|
DRY_RUN=${DRY_RUN:-false}
|
||||||
ENABLE_LOGGING=${ENABLE_LOGGING:-false}
|
ENABLE_LOGGING=${ENABLE_LOGGING:-false}
|
||||||
|
|
||||||
@@ -79,7 +78,7 @@ parse_args() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# ----------------------------- Validation -----------------------------
|
# Validation
|
||||||
require_var() {
|
require_var() {
|
||||||
local var="$1"
|
local var="$1"
|
||||||
if [[ -z "${!var:-}" ]]; then
|
if [[ -z "${!var:-}" ]]; then
|
||||||
@@ -98,7 +97,7 @@ validate_int() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# ----------------------------- Host Detection -----------------------------
|
# Host Detection
|
||||||
detect_hosts() {
|
detect_hosts() {
|
||||||
LOCAL_HOSTNAME="$(hostname)"
|
LOCAL_HOSTNAME="$(hostname)"
|
||||||
|
|
||||||
@@ -129,7 +128,7 @@ detect_hosts() {
|
|||||||
log "SSH key: $SSH_KEY"
|
log "SSH key: $SSH_KEY"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ----------------------------- Remote IP -----------------------------
|
# Remote IP
|
||||||
resolve_remote_ip() {
|
resolve_remote_ip() {
|
||||||
log "Resolving Tailscale IP for $REMOTE_SERVER_NAME..."
|
log "Resolving Tailscale IP for $REMOTE_SERVER_NAME..."
|
||||||
|
|
||||||
@@ -143,13 +142,13 @@ resolve_remote_ip() {
|
|||||||
info "Remote IP: $REMOTE_SERVER"
|
info "Remote IP: $REMOTE_SERVER"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ----------------------------- Connectivity -----------------------------
|
# Connectivity
|
||||||
check_remote_online() {
|
check_remote_online() {
|
||||||
log "Pinging $REMOTE_SERVER..."
|
log "Pinging $REMOTE_SERVER..."
|
||||||
ping -c 1 "$REMOTE_SERVER" &>/dev/null
|
ping -c 1 "$REMOTE_SERVER" &>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
# ----------------------------- Containers -----------------------------
|
# Containers
|
||||||
declare -a RUNNING_CONTAINERS=()
|
declare -a RUNNING_CONTAINERS=()
|
||||||
|
|
||||||
stop_containers() {
|
stop_containers() {
|
||||||
@@ -196,7 +195,7 @@ start_containers() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# ----------------------------- Rsync Options -----------------------------
|
# Rsync Options
|
||||||
get_rsync_opts() {
|
get_rsync_opts() {
|
||||||
if [[ -n "${PROFILE_RSYNC_OPTS[$PROFILE_NAME]:-}" ]]; then
|
if [[ -n "${PROFILE_RSYNC_OPTS[$PROFILE_NAME]:-}" ]]; then
|
||||||
read -r -a RSYNC_OPTS <<< "${PROFILE_RSYNC_OPTS[$PROFILE_NAME]}"
|
read -r -a RSYNC_OPTS <<< "${PROFILE_RSYNC_OPTS[$PROFILE_NAME]}"
|
||||||
@@ -207,7 +206,7 @@ get_rsync_opts() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# ----------------------------- Status Output -----------------------------
|
# Status Output
|
||||||
show_status() {
|
show_status() {
|
||||||
echo "===== RSYNC STATUS ====="
|
echo "===== RSYNC STATUS ====="
|
||||||
echo "Local: $LOCAL_SERVER_NAME"
|
echo "Local: $LOCAL_SERVER_NAME"
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
# ----------------------------------------------------------------------------------------------
|
||||||
#-----------------------------------------------------------------------------------------------
|
# ------------- Clear Unraid system logs and Docker container logs safely ----------------------
|
||||||
# Clear Unraid system logs and Docker container logs safely
|
# ----------------------------------------------------------------------------------------------
|
||||||
#-----------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
source "$SCRIPT_DIR/../common.sh"
|
source "$SCRIPT_DIR/../common.sh"
|
||||||
|
|||||||
@@ -1,9 +1,21 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
# ----------------------------------------------------------------------------------------------
|
||||||
#-----------------------------------------------------------------------------------------------
|
# ----------- Suppress noisy Docker veth/docker0 syslog messages on Unraid boot ----------------
|
||||||
# Suppress noisy Docker veth/docker0 syslog messages on Unraid boot
|
# ----------------------------------------------------------------------------------------------
|
||||||
#-----------------------------------------------------------------------------------------------
|
# ---------------- User Variables, Please adjust in Master.conf as needed ----------------------
|
||||||
|
# ----------------------------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# User variables can be adjusted in Master.conf
|
||||||
|
#
|
||||||
|
# Scripts now just contain runtime logic
|
||||||
|
#
|
||||||
|
# This new setup allows for profiles and arguments to use the core script
|
||||||
|
# Use arguments in unRAID User Plugin for directory
|
||||||
|
# Example: /mnt/user/appdata/unraid_scripts/Rsync/rsync.sh --dry-run
|
||||||
|
# ----------------------------------------------------------------------------------------------
|
||||||
|
# -------------- End Of User Variables, Please adjust in Master.conf as needed -----------------
|
||||||
|
# ----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
source "$SCRIPT_DIR/../common.sh"
|
source "$SCRIPT_DIR/../common.sh"
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
# ----------------------------------------------------------------------------------------------
|
||||||
#-----------------------------------------------------------------------------------------------
|
|
||||||
# --------------------------- Mover Stop Script for Unraid -------------------------------------
|
# --------------------------- Mover Stop Script for Unraid -------------------------------------
|
||||||
#-----------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------
|
||||||
#----------------- User Variables, Please adjust in Master.conf as needed ----------------------
|
# ---------------- User Variables, Please adjust in Master.conf as needed ----------------------
|
||||||
#-----------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# User variables can be adjusted in Master.conf
|
# User variables can be adjusted in Master.conf
|
||||||
#
|
#
|
||||||
@@ -14,9 +13,10 @@ set -e
|
|||||||
# This new setup allows for profiles and arguments to use the core script
|
# This new setup allows for profiles and arguments to use the core script
|
||||||
# Use arguments in unRAID User Plugin for directory
|
# Use arguments in unRAID User Plugin for directory
|
||||||
# Example: /mnt/user/appdata/unraid_scripts/Rsync/rsync.sh --dry-run
|
# Example: /mnt/user/appdata/unraid_scripts/Rsync/rsync.sh --dry-run
|
||||||
#-----------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------
|
||||||
#---------------End Of User Variables, Please adjust in Master.conf as needed ------------------
|
# -------------- End Of User Variables, Please adjust in Master.conf as needed -----------------
|
||||||
#-----------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
source "$SCRIPT_DIR/../common.sh"
|
source "$SCRIPT_DIR/../common.sh"
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,21 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
# ----------------------------------------------------------------------------------------------
|
||||||
#-----------------------------------------------------------------------------------------------
|
# ------------------ Persistently set PHP-FPM pm.max_children on Unraid ------------------------
|
||||||
# Persistently set PHP-FPM pm.max_children on Unraid
|
# ----------------------------------------------------------------------------------------------
|
||||||
#-----------------------------------------------------------------------------------------------
|
# ---------------- User Variables, Please adjust in Master.conf as needed ----------------------
|
||||||
|
# ----------------------------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# User variables can be adjusted in Master.conf
|
||||||
|
#
|
||||||
|
# Scripts now just contain runtime logic
|
||||||
|
#
|
||||||
|
# This new setup allows for profiles and arguments to use the core script
|
||||||
|
# Use arguments in unRAID User Plugin for directory
|
||||||
|
# Example: /mnt/user/appdata/unraid_scripts/Rsync/rsync.sh --dry-run
|
||||||
|
# ----------------------------------------------------------------------------------------------
|
||||||
|
# -------------- End Of User Variables, Please adjust in Master.conf as needed -----------------
|
||||||
|
# ----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
source "$SCRIPT_DIR/../common.sh"
|
source "$SCRIPT_DIR/../common.sh"
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
# ----------------------------------------------------------------------------------------------
|
||||||
#-----------------------------------------------------------------------------------------------
|
# ------------------------ Stop all running Rsync processes for Unraid -------------------------
|
||||||
# Stop all running Rsync processes for Unraid
|
# ----------------------------------------------------------------------------------------------
|
||||||
#-----------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
source "$SCRIPT_DIR/../common.sh"
|
source "$SCRIPT_DIR/../common.sh"
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
#-----------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------
|
||||||
# ---------------------------- Unattended Reboot Script for Unraid -----------------------------
|
# ---------------------------- Unattended Reboot Script for Unraid -----------------------------
|
||||||
#-----------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------
|
||||||
#----------------- User Variables, Please adjust in Master.conf as needed ----------------------
|
# ---------------- User Variables, Please adjust in Master.conf as needed ----------------------
|
||||||
#-----------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# User variables can be adjusted in Master.conf
|
# User variables can be adjusted in Master.conf
|
||||||
#
|
#
|
||||||
@@ -13,9 +13,9 @@
|
|||||||
# This new setup allows for profiles and arguments to use the core script
|
# This new setup allows for profiles and arguments to use the core script
|
||||||
# Use arguments in unRAID User Plugin for directory
|
# Use arguments in unRAID User Plugin for directory
|
||||||
# Example: /mnt/user/appdata/unraid_scripts/Rsync/rsync.sh --dry-run
|
# Example: /mnt/user/appdata/unraid_scripts/Rsync/rsync.sh --dry-run
|
||||||
#-----------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------
|
||||||
#---------------End Of User Variables, Please adjust in Master.conf as needed ------------------
|
# -------------- End Of User Variables, Please adjust in Master.conf as needed -----------------
|
||||||
#-----------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
source "$SCRIPT_DIR/../common.sh"
|
source "$SCRIPT_DIR/../common.sh"
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
# ----------------------------------------------------------------------------------------------
|
||||||
#-----------------------------------------------------------------------------------------------
|
# ----------------- Stop all running User Scripts spawned by the User Scripts plugin -----------
|
||||||
# Stop all running User Scripts spawned by the User Scripts plugin
|
# ----------------------------------------------------------------------------------------------
|
||||||
#-----------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
source "$SCRIPT_DIR/../common.sh"
|
source "$SCRIPT_DIR/../common.sh"
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------
|
||||||
# ZFS ARC & Memory Snapshot for Unraid
|
# --------------------------- ZFS ARC & Memory Snapshot for Unraid -----------------------------
|
||||||
#-----------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
source "$SCRIPT_DIR/../common.sh"
|
source "$SCRIPT_DIR/../common.sh"
|
||||||
|
|||||||
Reference in New Issue
Block a user