mirror of
https://github.com/buildplan/du_setup.git
synced 2025-12-17 09:45:26 +00:00
remove any unnecessary code
This commit is contained in:
parent
d3bb2dca38
commit
ff72d42b14
54
du_setup.sh
54
du_setup.sh
@ -2560,11 +2560,6 @@ validate_timezone() {
|
|||||||
[[ -e "/usr/share/zoneinfo/$tz" ]]
|
[[ -e "/usr/share/zoneinfo/$tz" ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
validate_swap_size() {
|
|
||||||
local size_upper="${1^^}" # Convert to uppercase for case-insensitivity
|
|
||||||
[[ "$size_upper" =~ ^[0-9]+[MG]$ && "${size_upper%[MG]}" -ge 1 ]]
|
|
||||||
}
|
|
||||||
|
|
||||||
validate_ufw_port() {
|
validate_ufw_port() {
|
||||||
local port="$1"
|
local port="$1"
|
||||||
# Matches port (e.g., 8080) or port/protocol (e.g., 8080/tcp, 123/udp)
|
# Matches port (e.g., 8080) or port/protocol (e.g., 8080/tcp, 123/udp)
|
||||||
@ -2615,17 +2610,25 @@ validate_ip_or_cidr() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
convert_to_bytes() {
|
# Convert size (e.g., 2G) to MB for validation/dd
|
||||||
local size_upper="${1^^}" # Convert to uppercase for case-insensitivity
|
convert_to_mb() {
|
||||||
local unit="${size_upper: -1}"
|
local input="${1:-}"
|
||||||
local value="${size_upper%[MG]}"
|
local size="${input^^}"
|
||||||
if [[ "$unit" == "G" ]]; then
|
size="${size// /}"
|
||||||
echo $((value * 1024 * 1024 * 1024))
|
local num="${size%[MG]}"
|
||||||
elif [[ "$unit" == "M" ]]; then
|
local unit="${size: -1}"
|
||||||
echo $((value * 1024 * 1024))
|
if ! [[ "$num" =~ ^[0-9]+$ ]]; then
|
||||||
else
|
print_error "Invalid swap size format: '$input'. Expected format: 2G, 512M." >&2
|
||||||
echo 0
|
return 1
|
||||||
fi
|
fi
|
||||||
|
case "$unit" in
|
||||||
|
G) echo "$((num * 1024))" ;;
|
||||||
|
M) echo "$num" ;;
|
||||||
|
*)
|
||||||
|
print_error "Unknown or missing unit in swap size: '$input'. Use 'M' or 'G'." >&2
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- script update check ---
|
# --- script update check ---
|
||||||
@ -5109,27 +5112,6 @@ EOF
|
|||||||
log "Swap configuration completed."
|
log "Swap configuration completed."
|
||||||
}
|
}
|
||||||
|
|
||||||
# Helper: Convert size (e.g., 2G) to MB for validation/dd
|
|
||||||
convert_to_mb() {
|
|
||||||
local input="${1:-}"
|
|
||||||
local size="${input^^}"
|
|
||||||
size="${size// /}"
|
|
||||||
local num="${size%[MG]}"
|
|
||||||
local unit="${size: -1}"
|
|
||||||
if ! [[ "$num" =~ ^[0-9]+$ ]]; then
|
|
||||||
print_error "Invalid swap size format: '$input'. Expected format: 2G, 512M." >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
case "$unit" in
|
|
||||||
G) echo "$((num * 1024))" ;;
|
|
||||||
M) echo "$num" ;;
|
|
||||||
*)
|
|
||||||
print_error "Unknown or missing unit in swap size: '$input'. Use 'M' or 'G'." >&2
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
configure_time_sync() {
|
configure_time_sync() {
|
||||||
print_section "Time Synchronization"
|
print_section "Time Synchronization"
|
||||||
print_info "Ensuring chrony is active..."
|
print_info "Ensuring chrony is active..."
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user