Fix: Double arithmetic syntax error in generate_comparison_report (line 2073)

This commit is contained in:
Developer
2026-04-23 21:16:33 -04:00
parent 8af1ca881b
commit ca7ec62e02
12 changed files with 121 additions and 70 deletions
+31 -30
View File
@@ -1,4 +1,5 @@
#!/bin/bash
set -eo pipefail
################################################################################
# Disk Space Analyzer (WinDirStat for Linux)
@@ -17,6 +18,7 @@
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
source "$SCRIPT_DIR/lib/common-functions.sh"
source "$SCRIPT_DIR/lib/system-detect.sh"
source "$SCRIPT_DIR/lib/reference-db.sh"
# Require root
if [ "$EUID" -ne 0 ]; then
@@ -24,6 +26,9 @@ if [ "$EUID" -ne 0 ]; then
exit 1
fi
# Ensure cache is fresh (only rebuilds if > 1 hour old)
db_ensure_fresh 2>/dev/null || true
# Temp file for results
TEMP_DIR="/tmp/disk-analysis-$$"
mkdir -p "$TEMP_DIR"
@@ -619,55 +624,51 @@ analyze_wordpress() {
print_banner "WordPress Storage Analysis"
echo ""
# Find WordPress installations
# Find WordPress installations from cache (instant lookup, no filesystem scan)
show_progress "Finding WordPress installations"
local wp_paths=()
local wp_count=0
local wp_data=""
# Common locations
if [ -d "/home" ]; then
while IFS= read -r wp_config; do
wp_dir=$(dirname "$wp_config")
wp_paths+=("$wp_dir")
done < <(find /home -name "wp-config.php" -type f 2>/dev/null)
# Get WordPress data from cache
if command -v db_get_all_wordpress &>/dev/null; then
wp_data=$(db_get_all_wordpress 2>/dev/null || true)
fi
if [ -d "/var/www" ]; then
while IFS= read -r wp_config; do
wp_dir=$(dirname "$wp_config")
wp_paths+=("$wp_dir")
done < <(find /var/www -name "wp-config.php" -type f 2>/dev/null)
# Count WP installations
if [ -n "$wp_data" ]; then
wp_count=$(echo "$wp_data" | grep -c "^WP|" || echo 0)
fi
if [ ${#wp_paths[@]} -eq 0 ]; then
if [ "$wp_count" -eq 0 ]; then
echo -e "\r${DIM}No WordPress installations found${NC} "
echo ""
press_enter
return
fi
echo -e "\r${GREEN}${NC} Found ${#wp_paths[@]} WordPress installations "
echo -e "\r${GREEN}${NC} Found ${wp_count} WordPress installations "
echo ""
echo -e "${BOLD}WordPress Space Usage:${NC}"
echo "───────────────────────────────────────────────────────────────"
for wp_dir in "${wp_paths[@]}"; do
# Get domain/user from path
domain=$(echo "$wp_dir" | awk -F'/' '{for(i=1;i<=NF;i++) if($i~/public_html|httpdocs|www/) print $(i-1)}' | tail -1)
# Process cached WordPress data
while IFS='|' read -r type domain path db_name db_user version plugins themes; do
if [ "$type" = "WP" ] && [ -d "$path" ]; then
# Calculate sizes
total_size=$(du -sh "$path" 2>/dev/null | awk '{print $1}')
uploads_size=$(du -sh "$path/wp-content/uploads" 2>/dev/null | awk '{print $1}')
plugins_size=$(du -sh "$path/wp-content/plugins" 2>/dev/null | awk '{print $1}')
cache_size=$(du -sh "$path/wp-content/cache" 2>/dev/null | awk '{print $1}')
# Calculate sizes
total_size=$(du -sh "$wp_dir" 2>/dev/null | awk '{print $1}')
uploads_size=$(du -sh "$wp_dir/wp-content/uploads" 2>/dev/null | awk '{print $1}')
plugins_size=$(du -sh "$wp_dir/wp-content/plugins" 2>/dev/null | awk '{print $1}')
cache_size=$(du -sh "$wp_dir/wp-content/cache" 2>/dev/null | awk '{print $1}')
echo -e "${BOLD}$domain${NC} ($total_size)"
echo -e " Uploads: ${CYAN}${uploads_size:-0}${NC}"
echo -e " Plugins: ${CYAN}${plugins_size:-0}${NC}"
echo -e " Cache: ${CYAN}${cache_size:-0}${NC}"
echo ""
done
echo -e "${BOLD}$domain${NC} ($total_size)"
echo -e " Uploads: ${CYAN}${uploads_size:-0}${NC}"
echo -e " Plugins: ${CYAN}${plugins_size:-0}${NC}"
echo -e " Cache: ${CYAN}${cache_size:-0}${NC}"
echo ""
fi
done <<< "$wp_data"
echo -e "${BOLD}Cleanup Suggestions:${NC}"
echo " • Delete old revisions: wp post delete \$(wp post list --post_type=revision --format=ids)"