Compare commits

..

2 Commits

Author SHA1 Message Date
justin
000a7a2701 Fix Error check and error message style 2026-01-29 10:21:41 +01:00
justin
8c4f1ce531 Make check_container_storage() POSIX compliant 2026-01-29 10:21:41 +01:00

View File

@ -3086,21 +3086,29 @@ check_container_resources() {
# ------------------------------------------------------------------------------
# check_container_storage()
#
# - Checks /boot partition usage
# - Checks root (/) partition usage
# - Warns if usage >80% and asks user confirmation before proceeding
# ------------------------------------------------------------------------------
check_container_storage() {
total_size=$(df /boot --output=size | tail -n 1)
local used_size=$(df /boot --output=used | tail -n 1)
usage=$((100 * used_size / total_size))
if ((usage > 80)); then
echo -e "${INFO}${HOLD} ${YWB}Warning: Storage is dangerously low (${usage}%).${CL}"
echo -ne "Continue anyway? <y/N> "
read -r prompt
if [[ ! ${prompt,,} =~ ^(y|yes)$ ]]; then
echo -e "${CROSS}${HOLD}${YWB}Exiting based on user input.${CL}"
usage=$(df / -P | awk 'NR==2 {print $5}' | tr -d '%')
if [ -z "$usage" ] || [ "$usage" -lt 0 ]; then
echo -e "${CROSS}${HOLD}${RD}Error: Failed to check disk usage.${CL}"
exit 1
fi
if [ "$usage" -gt 80 ]; then
echo -e "${INFO}${HOLD}${YWB}Warning: Storage is dangerously low (${usage}%).${CL}"
printf "Continue anyway? <y/N> "
read -r prompt
case "$prompt" in
[yY][eE][sS] | [yY]) ;;
*)
echo -e "${CROSS}${HOLD}${YWB}Exiting based on user input.${CL}"
exit 1
;;
esac
fi
}