mirror of
https://github.com/acedanger/shell.git
synced 2025-12-06 00:00:13 -08:00
Refactor variable assignments and improve script readability in validate-plex-backups.sh and validate-plex-recovery.sh
- Changed inline variable assignments to separate declaration and assignment for clarity. - Updated condition checks and log messages for better readability and consistency. - Added a backup of validate-plex-recovery.sh for safety. - Introduced a new script run-docker-tests.sh for testing setup in Docker containers. - Enhanced ssh-login.sh to improve condition checks and logging functionality.
This commit is contained in:
@@ -60,8 +60,6 @@ NC='\033[0m' # No Color
|
||||
|
||||
# Configuration
|
||||
PLEX_DB_DIR="/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases"
|
||||
PLEX_USER="plex"
|
||||
PLEX_GROUP="plex"
|
||||
BACKUP_TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
|
||||
RECOVERY_LOG="/home/acedanger/shell/plex/logs/icu-recovery-${BACKUP_TIMESTAMP}.log"
|
||||
|
||||
@@ -72,7 +70,8 @@ mkdir -p "$(dirname "$RECOVERY_LOG")"
|
||||
log_message() {
|
||||
local level="$1"
|
||||
local message="$2"
|
||||
local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
|
||||
local timestamp
|
||||
timestamp=$(date '+%Y-%m-%d %H:%M:%S')
|
||||
echo "[$timestamp] [$level] $message" | tee -a "$RECOVERY_LOG"
|
||||
}
|
||||
|
||||
@@ -115,7 +114,8 @@ verify_database_basic() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
local file_size=$(stat -c%s "$db_file" 2>/dev/null || stat -f%z "$db_file" 2>/dev/null)
|
||||
local file_size
|
||||
file_size=$(stat -c%s "$db_file" 2>/dev/null || stat -f%z "$db_file" 2>/dev/null)
|
||||
if [[ $file_size -lt 1024 ]]; then
|
||||
print_status "$RED" "$db_name: File is too small ($file_size bytes)"
|
||||
return 1
|
||||
@@ -132,7 +132,8 @@ verify_database_basic() {
|
||||
print_status "$GREEN" "$db_name: Basic SQLite operations successful"
|
||||
|
||||
# Count tables
|
||||
local table_count=$(sqlite3 "$db_file" "SELECT COUNT(*) FROM sqlite_master WHERE type='table';" 2>/dev/null || echo "0")
|
||||
local table_count
|
||||
table_count=$(sqlite3 "$db_file" "SELECT COUNT(*) FROM sqlite_master WHERE type='table';" 2>/dev/null || echo "0")
|
||||
print_status "$GREEN" "$db_name: Contains $table_count tables"
|
||||
|
||||
return 0
|
||||
@@ -262,12 +263,14 @@ check_database_sizes() {
|
||||
local blobs_db="${PLEX_DB_DIR}/com.plexapp.plugins.library.blobs.db"
|
||||
|
||||
if [[ -f "$main_db" ]]; then
|
||||
local main_size=$(du -h "$main_db" | cut -f1)
|
||||
local main_size
|
||||
main_size=$(du -h "$main_db" | cut -f1)
|
||||
print_status "$GREEN" "Main database size: $main_size"
|
||||
fi
|
||||
|
||||
if [[ -f "$blobs_db" ]]; then
|
||||
local blobs_size=$(du -h "$blobs_db" | cut -f1)
|
||||
local blobs_size
|
||||
blobs_size=$(du -h "$blobs_db" | cut -f1)
|
||||
print_status "$GREEN" "Blobs database size: $blobs_size"
|
||||
fi
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user