Fix local variable usage in acronis-agent-status.sh

Fixed error where 'local' keyword was used outside of a function in
the storage status section. Changed to regular variable declarations
and added null check for use_percent to prevent integer expression errors.
This commit is contained in:
cschantz
2025-11-06 16:35:38 -05:00
parent 25b70aabcb
commit 1bb21afbd3
+4 -4
View File
@@ -182,16 +182,16 @@ echo ""
# Check disk space for backups # Check disk space for backups
echo -e "${BOLD}Storage Status:${NC}" echo -e "${BOLD}Storage Status:${NC}"
if [ -d "/var/lib/Acronis" ]; then if [ -d "/var/lib/Acronis" ]; then
local backup_dir_size=$(du -sh /var/lib/Acronis 2>/dev/null | awk '{print $1}') backup_dir_size=$(du -sh /var/lib/Acronis 2>/dev/null | awk '{print $1}')
echo -e " Acronis data: ${backup_dir_size}" echo -e " Acronis data: ${backup_dir_size}"
# Check free space # Check free space
local free_space=$(df -h /var/lib/Acronis | tail -1 | awk '{print $4}') free_space=$(df -h /var/lib/Acronis | tail -1 | awk '{print $4}')
local use_percent=$(df -h /var/lib/Acronis | tail -1 | awk '{print $5}' | tr -d '%') use_percent=$(df -h /var/lib/Acronis | tail -1 | awk '{print $5}' | tr -d '%')
echo -e " Free space: ${free_space}" echo -e " Free space: ${free_space}"
if [ "$use_percent" -gt 90 ]; then if [ -n "$use_percent" ] && [ "$use_percent" -gt 90 ] 2>/dev/null; then
echo -e " ${RED}⚠ Warning: Disk usage at ${use_percent}%${NC}" echo -e " ${RED}⚠ Warning: Disk usage at ${use_percent}%${NC}"
fi fi
fi fi