reconf the master and common scripts and all unraid essential scripts# Please enter the commit message for your changes. Lines starting
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
#-----------------------------------------------------------------------------------------------
|
||||
# Clear Unraid system logs and Docker container logs safely
|
||||
#-----------------------------------------------------------------------------------------------
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "$SCRIPT_DIR/../common.sh"
|
||||
|
||||
# Load central config
|
||||
load_master_conf
|
||||
|
||||
# Parse CLI args (supports --dry-run)
|
||||
parse_args "$@"
|
||||
|
||||
# Colors for output
|
||||
RED="\033[0;31m"
|
||||
GREEN="\033[0;32m"
|
||||
YELLOW="\033[1;33m"
|
||||
RESET="\033[0m"
|
||||
|
||||
# Log files to clear (can also be overridden in Master.conf)
|
||||
LOG_FILES=("${LOG_FILES[@]:-/var/log/syslog /var/log/messages /var/log/dmesg}")
|
||||
|
||||
# Require root
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
printf "${RED}❌ Please run as root.${RESET}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "${YELLOW}Starting log cleanup...${RESET}\n"
|
||||
|
||||
# Functions
|
||||
clear_file() {
|
||||
local file="$1"
|
||||
if [ ! -f "$file" ]; then
|
||||
printf "${RED}Not found:${RESET} %s\n" "$file"
|
||||
return
|
||||
fi
|
||||
|
||||
if [ "$DRY_RUN" = true ]; then
|
||||
printf "${YELLOW}Would clear:${RESET} %s\n" "$file"
|
||||
else
|
||||
: > "$file"
|
||||
printf "${GREEN}Cleared:${RESET} %s\n" "$file"
|
||||
fi
|
||||
}
|
||||
|
||||
clear_docker_logs() {
|
||||
if [ ! -d /var/lib/docker/containers ]; then
|
||||
printf "${RED}Docker containers directory not found. Skipping Docker log cleanup.${RESET}\n"
|
||||
return
|
||||
fi
|
||||
|
||||
local files
|
||||
files=$(find /var/lib/docker/containers/ -name "*-json.log" 2>/dev/null)
|
||||
for file in $files; do
|
||||
if [ "$DRY_RUN" = true ]; then
|
||||
printf "${YELLOW}Would clear Docker log:${RESET} %s\n" "$file"
|
||||
else
|
||||
: > "$file"
|
||||
printf "${GREEN}Cleared Docker log:${RESET} %s\n" "$file"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# MAIN
|
||||
for log in "${LOG_FILES[@]}"; do
|
||||
clear_file "$log"
|
||||
done
|
||||
|
||||
clear_docker_logs
|
||||
|
||||
if [ "$DRY_RUN" = true ]; then
|
||||
printf "\n${YELLOW}🧪 Dry run complete. No files were cleared.${RESET}\n"
|
||||
else
|
||||
printf "\n${GREEN}🎉 Done clearing logs.${RESET}\n"
|
||||
fi
|
||||
@@ -0,0 +1,55 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
#-----------------------------------------------------------------------------------------------
|
||||
# Suppress noisy Docker veth/docker0 syslog messages on Unraid boot
|
||||
#-----------------------------------------------------------------------------------------------
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "$SCRIPT_DIR/../common.sh"
|
||||
|
||||
# Load central config
|
||||
load_master_conf
|
||||
|
||||
# Parse CLI args (supports --dry-run)
|
||||
parse_args "$@"
|
||||
|
||||
# Filter file location (can also be overridden in Master.conf)
|
||||
FILTER_FILE=${FILTER_FILE:-"/etc/rsyslog.d/ignore-docker-veth.conf"}
|
||||
|
||||
# Require root
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo -e "\033[0;31m❌ Please run as root.${RESET}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Functions
|
||||
create_filter() {
|
||||
if [ "$DRY_RUN" = true ]; then
|
||||
echo "[DRY-RUN] Would create rsyslog filter file at $FILTER_FILE"
|
||||
else
|
||||
echo "Creating rsyslog filter file at $FILTER_FILE"
|
||||
cat <<'EOF' > "$FILTER_FILE"
|
||||
if ($msg contains "veth" or $msg contains "docker0") then {
|
||||
stop
|
||||
}
|
||||
EOF
|
||||
fi
|
||||
}
|
||||
|
||||
restart_rsyslog() {
|
||||
if [ "$DRY_RUN" = true ]; then
|
||||
echo "[DRY-RUN] Would restart rsyslog: /etc/rc.d/rc.rsyslogd restart"
|
||||
else
|
||||
echo "Restarting rsyslog..."
|
||||
/etc/rc.d/rc.rsyslogd restart
|
||||
fi
|
||||
}
|
||||
|
||||
# MAIN
|
||||
echo "==== Docker Syslog Filter Script Started: $(date) ===="
|
||||
|
||||
create_filter
|
||||
restart_rsyslog
|
||||
|
||||
echo "✅ Docker veth/docker0 syslog filter applied."
|
||||
@@ -0,0 +1,64 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
#-----------------------------------------------------------------------------------------------
|
||||
# --------------------------- Mover Stop Script for 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)"
|
||||
source "$SCRIPT_DIR/../common.sh"
|
||||
|
||||
# Load central config
|
||||
load_master_conf
|
||||
|
||||
# Parse CLI args (flags + VAR=value)
|
||||
parse_args "$@"
|
||||
|
||||
# Optional: MOVER_STOP_TIMEOUT in seconds (default from Master.conf or 30s)
|
||||
MOVER_STOP_TIMEOUT=${MOVER_STOP_TIMEOUT:-30}
|
||||
validate_int MOVER_STOP_TIMEOUT "$MOVER_STOP_TIMEOUT"
|
||||
|
||||
# Functions
|
||||
|
||||
notify_users() {
|
||||
wall "⚠️ Unraid Mover will stop in ${MOVER_STOP_TIMEOUT} second(s)."
|
||||
}
|
||||
|
||||
check_mover_running() {
|
||||
pgrep -f "emhttp.*Mover" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
stop_mover() {
|
||||
if [ "$DRY_RUN" = true ]; then
|
||||
echo "[DRY-RUN] Would stop the Mover process"
|
||||
else
|
||||
echo "Stopping Mover..."
|
||||
# Unraid native way: kill the mover process gracefully
|
||||
pkill -f "emhttp.*Mover"
|
||||
fi
|
||||
}
|
||||
|
||||
# MAIN
|
||||
|
||||
echo "==== Mover Stop Script Started: $(date) ===="
|
||||
|
||||
if check_mover_running; then
|
||||
notify_users
|
||||
sleep "$MOVER_STOP_TIMEOUT"
|
||||
stop_mover
|
||||
echo "Mover stopped."
|
||||
else
|
||||
echo "Mover is not running."
|
||||
fi
|
||||
@@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
#-----------------------------------------------------------------------------------------------
|
||||
# Persistently set PHP-FPM pm.max_children on Unraid
|
||||
#-----------------------------------------------------------------------------------------------
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "$SCRIPT_DIR/../common.sh"
|
||||
|
||||
# Load central config
|
||||
load_master_conf
|
||||
|
||||
# Parse CLI args (supports --dry-run)
|
||||
parse_args "$@"
|
||||
|
||||
# Require root
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo -e "\033[0;31m❌ Please run as root.${RESET}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
validate_int PHP_MAX_CHILDREN "$PHP_MAX_CHILDREN"
|
||||
|
||||
# Functions
|
||||
apply_php_max_children() {
|
||||
local target="pm.max_children = $PHP_MAX_CHILDREN"
|
||||
|
||||
if [ "$DRY_RUN" = true ]; then
|
||||
echo "[DRY-RUN] Would set PHP-FPM max_children to $PHP_MAX_CHILDREN in $PHP_CONF"
|
||||
echo "[DRY-RUN] Would restart PHP-FPM service"
|
||||
else
|
||||
echo "Applying persistent PHP-FPM max_children = $PHP_MAX_CHILDREN"
|
||||
sed -i "s/^pm\.max_children.*/$target/" "$PHP_CONF"
|
||||
|
||||
# Restart PHP-FPM
|
||||
/etc/rc.d/rc.php-fpm restart
|
||||
|
||||
local current
|
||||
current=$(grep -E "^pm\.max_children" "$PHP_CONF")
|
||||
logger "Userscript: php-fpm setting applied: $current"
|
||||
|
||||
echo "PHP-FPM max_children persistently set to: $current"
|
||||
echo "PHP-FPM restarted successfully."
|
||||
fi
|
||||
}
|
||||
|
||||
# MAIN
|
||||
echo "==== PHP-FPM Max Children Script Started: $(date) ===="
|
||||
apply_php_max_children
|
||||
@@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
#-----------------------------------------------------------------------------------------------
|
||||
# Stop all running Rsync processes for Unraid
|
||||
#-----------------------------------------------------------------------------------------------
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "$SCRIPT_DIR/../common.sh"
|
||||
|
||||
# Load central config
|
||||
load_master_conf
|
||||
|
||||
# Parse CLI args (supports --dry-run)
|
||||
parse_args "$@"
|
||||
|
||||
# Functions
|
||||
|
||||
stop_rsync_processes() {
|
||||
if [ "$DRY_RUN" = true ]; then
|
||||
echo "[DRY-RUN] Would stop all running rsync processes"
|
||||
else
|
||||
echo "Stopping all rsync processes..."
|
||||
if pkill -f rsync; then
|
||||
echo "All rsync processes stopped successfully."
|
||||
else
|
||||
echo "No rsync processes found or failed to stop."
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# MAIN
|
||||
echo "==== Rsync Stop Script Started: $(date) ===="
|
||||
|
||||
stop_rsync_processes
|
||||
@@ -7,7 +7,6 @@
|
||||
#-----------------------------------------------------------------------------------------------
|
||||
#
|
||||
# User variables can be adjusted in Master.conf
|
||||
# This script is using the SLEEP Variable from Master.conf for the delay before reboot
|
||||
#
|
||||
# Scripts now just contain runtime logic
|
||||
#
|
||||
@@ -27,23 +26,25 @@ load_master_conf
|
||||
# Parse CLI args (flags + VAR=value)
|
||||
parse_args "$@"
|
||||
|
||||
# Validate SLEEP
|
||||
validate_int SLEEP "$SLEEP"
|
||||
# Validate REBOOT_SLEEP
|
||||
validate_int REBOOT_SLEEP "$REBOOT_SLEEP"
|
||||
|
||||
# --- Functions
|
||||
|
||||
notify_users() {
|
||||
wall "⚠️ Unraid server will reboot in ${SLEEP} second(s). Save your work."
|
||||
wall "⚠️ Unraid server will reboot in ${REBOOT_SLEEP} second(s). Save your work."
|
||||
}
|
||||
|
||||
# --- MAIN
|
||||
|
||||
echo "==== Scheduled Reboot Script Started: $(date) ===="
|
||||
|
||||
# Optional warning before reboot
|
||||
if [ "$SLEEP" -gt 0 ]; then
|
||||
if [ "$REBOOT_SLEEP" -gt 0 ]; then
|
||||
notify_users
|
||||
sleep "$SLEEP"
|
||||
sleep "$REBOOT_SLEEP"
|
||||
|
||||
|
||||
|
||||
|
||||
fi
|
||||
|
||||
# Stop Docker
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
#-----------------------------------------------------------------------------------------------
|
||||
# Stop all running User Scripts spawned by the User Scripts plugin
|
||||
#-----------------------------------------------------------------------------------------------
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "$SCRIPT_DIR/../common.sh"
|
||||
|
||||
# Load central config
|
||||
load_master_conf
|
||||
|
||||
# Parse CLI args (supports --dry-run)
|
||||
parse_args "$@"
|
||||
|
||||
# Functions
|
||||
|
||||
stop_user_scripts() {
|
||||
# Get PIDs of running user scripts
|
||||
local pids
|
||||
pids=$(/usr/bin/ps -eo pid,cmd | grep "/tmp/user.scripts" | grep -v grep | awk '{print $1}')
|
||||
|
||||
if [ -z "$pids" ]; then
|
||||
echo "No running user scripts found."
|
||||
return
|
||||
fi
|
||||
|
||||
for pid in $pids; do
|
||||
if [ "$DRY_RUN" = true ]; then
|
||||
echo "[DRY-RUN] Would kill user script with PID $pid"
|
||||
else
|
||||
echo "Killing user script with PID $pid"
|
||||
kill "$pid"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "All user scripts stopped."
|
||||
}
|
||||
|
||||
# MAIN
|
||||
echo "==== User Scripts Stop Script Started: $(date) ===="
|
||||
|
||||
stop_user_scripts
|
||||
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
#-----------------------------------------------------------------------------------------------
|
||||
# ZFS ARC & Memory Snapshot for Unraid
|
||||
#-----------------------------------------------------------------------------------------------
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "$SCRIPT_DIR/../common.sh"
|
||||
|
||||
# Load central config
|
||||
load_master_conf
|
||||
|
||||
# Parse CLI args (supports --dry-run)
|
||||
parse_args "$@"
|
||||
|
||||
# Functions
|
||||
show_zfs_arc() {
|
||||
echo "--- ARC / Metadata Stats ---"
|
||||
grep -iE '^(c|meta|arc_meta_used|demand_metadata_misses|mru_ghost_metadata|mfu_ghost_metadata)' /proc/spl/kstat/zfs/arcstats
|
||||
}
|
||||
|
||||
show_memory_status() {
|
||||
echo "--- Memory Status ---"
|
||||
free -h | awk 'NR==1 || /Mem:/'
|
||||
}
|
||||
|
||||
# MAIN
|
||||
echo "===== ZFS ARC & Memory Snapshot: $(date) ====="
|
||||
|
||||
if [ "$DRY_RUN" = true ]; then
|
||||
echo "[DRY-RUN] Would display ARC and memory stats"
|
||||
else
|
||||
echo ""
|
||||
show_zfs_arc
|
||||
echo ""
|
||||
show_memory_status
|
||||
fi
|
||||
|
||||
echo "=============================================="
|
||||
Reference in New Issue
Block a user