Update customizable_post_install.sh

This commit is contained in:
MacRimi
2025-08-18 15:08:25 +02:00
committed by GitHub
parent e18f20ce4c
commit 0fc414e5e9

View File

@@ -515,7 +515,7 @@ skip_apt_languages() {
configure_time_sync() { configure_time_sync_() {
msg_info2 "$(translate "Configuring system time settings...")" msg_info2 "$(translate "Configuring system time settings...")"
@@ -559,6 +559,42 @@ configure_time_sync() {
configure_time_sync() {
msg_info2 "$(translate "Configuring system time settings...")"
this_ip=$(dig +short myip.opendns.com @resolver1.opendns.com 2>/dev/null)
if [ -z "$this_ip" ]; then
msg_warn "$(translate "Failed to obtain public IP address - keeping current timezone settings")"
return 0
fi
timezone=$(curl -s --connect-timeout 10 "https://ipapi.co/${this_ip}/timezone" 2>/dev/null)
if [ -z "$timezone" ] || [ "$timezone" = "undefined" ]; then
msg_warn "$(translate "Failed to determine timezone from IP address - keeping current timezone settings")"
return 0
fi
msg_ok "$(translate "Found timezone $timezone for IP $this_ip")"
if timedatectl set-timezone "$timezone"; then
msg_ok "$(translate "Timezone set to $timezone")"
if timedatectl set-ntp true; then
msg_ok "$(translate "Time settings configured - Timezone:") $timezone"
register_tool "time_sync" true
systemctl restart postfix 2>/dev/null || true
else
msg_warn "$(translate "Failed to enable automatic time synchronization")"
fi
else
msg_warn "$(translate "Failed to set timezone - keeping current settings")"
fi
}
# ========================================================== # ==========================================================