Fix 22 critical runtime errors from 'local' keyword used outside functions

Removed 'local' keyword from script-level variable declarations in:
- website-error-analyzer.sh (8 instances)
- wordpress-cron-manager.sh (3 instances)
- live-attack-monitor.sh (3 instances)
- live-attack-monitor-v2.sh (3 instances)
- acronis-uninstall.sh (3 instances)
- malware-scanner.sh (1 instance)
- acronis-troubleshoot.sh (1 instance)
- diagnostic-report.sh (1 instance)

The 'local' keyword can only be used inside bash functions.
Using it at script-level causes immediate runtime errors.
This commit is contained in:
cschantz
2025-12-30 18:38:59 -05:00
parent b3d31e838e
commit 77f91462e1
8 changed files with 396 additions and 159 deletions
+1 -1
View File
@@ -356,7 +356,7 @@ else
# Show recommendations
if [ ${#RECOMMENDATIONS[@]} -gt 0 ]; then
echo -e "${CYAN}${BOLD}Recommendations:${NC}"
local rec_num=1
rec_num=1
for rec in "${RECOMMENDATIONS[@]}"; do
echo -e " ${CYAN}${rec_num}.${NC} $rec"
((rec_num++))
+3 -3
View File
@@ -179,7 +179,7 @@ if [ "$remove_data" = "yes" ]; then
for dir in "${DATA_DIRS[@]}"; do
if [ -d "$dir" ]; then
local size=$(du -sh "$dir" 2>/dev/null | awk '{print $1}')
size=$(du -sh "$dir" 2>/dev/null | awk '{print $1}')
echo " Removing: $dir (${size})"
rm -rf "$dir" 2>/dev/null
fi
@@ -202,7 +202,7 @@ echo -e "${GREEN}${BOLD}✓ Uninstallation Complete${NC}"
echo ""
# Check if anything remains
local remaining=0
remaining=0
if systemctl list-unit-files | grep -q "acronis"; then
echo -e "${YELLOW}⚠ Some service files may still be present${NC}"
@@ -230,7 +230,7 @@ if [ "$remove_data" = "no" ]; then
echo ""
echo "Backup data and logs were kept as requested:"
if [ -d "/var/lib/Acronis" ]; then
local data_size=$(du -sh /var/lib/Acronis 2>/dev/null | awk '{print $1}')
data_size=$(du -sh /var/lib/Acronis 2>/dev/null | awk '{print $1}')
echo " Location: /var/lib/Acronis"
echo " Size: $data_size"
echo ""