Compare commits
2 Commits
a5096a5b62
...
000a7a2701
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
000a7a2701 | ||
|
|
8c4f1ce531 |
@ -363,7 +363,7 @@ validate_hostname() {
|
||||
|
||||
# Split by dots and validate each label
|
||||
local IFS='.'
|
||||
read -ra labels <<< "$hostname"
|
||||
read -ra labels <<<"$hostname"
|
||||
for label in "${labels[@]}"; do
|
||||
# Each label: 1-63 chars, alphanumeric, hyphens allowed (not at start/end)
|
||||
if [[ -z "$label" ]] || [[ ${#label} -gt 63 ]]; then
|
||||
@ -467,7 +467,7 @@ validate_ipv6_address() {
|
||||
# Check that no segment exceeds 4 hex chars
|
||||
local IFS=':'
|
||||
local -a segments
|
||||
read -ra segments <<< "$addr"
|
||||
read -ra segments <<<"$addr"
|
||||
for seg in "${segments[@]}"; do
|
||||
if [[ ${#seg} -gt 4 ]]; then
|
||||
return 1
|
||||
@ -517,14 +517,14 @@ validate_gateway_in_subnet() {
|
||||
|
||||
# Convert IPs to integers
|
||||
local IFS='.'
|
||||
read -r i1 i2 i3 i4 <<< "$ip"
|
||||
read -r g1 g2 g3 g4 <<< "$gateway"
|
||||
read -r i1 i2 i3 i4 <<<"$ip"
|
||||
read -r g1 g2 g3 g4 <<<"$gateway"
|
||||
|
||||
local ip_int=$(( (i1 << 24) + (i2 << 16) + (i3 << 8) + i4 ))
|
||||
local gw_int=$(( (g1 << 24) + (g2 << 16) + (g3 << 8) + g4 ))
|
||||
local ip_int=$(((i1 << 24) + (i2 << 16) + (i3 << 8) + i4))
|
||||
local gw_int=$(((g1 << 24) + (g2 << 16) + (g3 << 8) + g4))
|
||||
|
||||
# Check if both are in same network
|
||||
if (( (ip_int & mask) != (gw_int & mask) )); then
|
||||
if (((ip_int & mask) != (gw_int & mask))); then
|
||||
return 1
|
||||
fi
|
||||
|
||||
@ -1152,7 +1152,7 @@ load_vars_file() {
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
var_fuse|var_tun|var_gpu|var_ssh|var_verbose|var_protection)
|
||||
var_fuse | var_tun | var_gpu | var_ssh | var_verbose | var_protection)
|
||||
if [[ "$var_val" != "yes" && "$var_val" != "no" ]]; then
|
||||
msg_warn "Invalid boolean '$var_val' for $var_key in $file (must be yes/no), ignoring"
|
||||
continue
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user