fix: prevent sudo cache expiry during install and add timezone fallback
Two issues caused the timezone step to fail on first run: 1. Sudo credential cache (default 15 min) can expire during the long apt install step before configure_timezone runs. Added `sudo -v` immediately after the install confirmation prompt to prime the cache as late as possible, just before the first long-running step. 2. `sudo timedatectl set-timezone` can fail with "Access denied" if polkit/D-Bus is not yet fully ready in the install environment. Added a direct fallback (ln -sf localtime + tee /etc/timezone) that bypasses D-Bus entirely. https://claude.ai/code/session_01M3tiofbGfmTddeMcXr8nXr
This commit is contained in:
@@ -796,7 +796,14 @@ configure_timezone() {
|
|||||||
|
|
||||||
if [[ -n "$new_tz" ]]; then
|
if [[ -n "$new_tz" ]]; then
|
||||||
if timedatectl list-timezones | grep -q "^${new_tz}$"; then
|
if timedatectl list-timezones | grep -q "^${new_tz}$"; then
|
||||||
sudo timedatectl set-timezone "$new_tz" && log_success "Timezone updated to $new_tz"
|
if sudo timedatectl set-timezone "$new_tz"; then
|
||||||
|
log_success "Timezone updated to $new_tz"
|
||||||
|
else
|
||||||
|
# Fallback: set timezone directly without D-Bus
|
||||||
|
sudo ln -sf "/usr/share/zoneinfo/$new_tz" /etc/localtime
|
||||||
|
echo "$new_tz" | sudo tee /etc/timezone > /dev/null
|
||||||
|
log_success "Timezone updated to $new_tz (direct)"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
log_error "Invalid timezone: $new_tz"
|
log_error "Invalid timezone: $new_tz"
|
||||||
fi
|
fi
|
||||||
@@ -3909,6 +3916,9 @@ first_time_install() {
|
|||||||
read -r -p "Proceed with installation? (y/n): " proceed
|
read -r -p "Proceed with installation? (y/n): " proceed
|
||||||
[[ ! "$proceed" =~ ^[Yy]$ ]] && exit 0
|
[[ ! "$proceed" =~ ^[Yy]$ ]] && exit 0
|
||||||
|
|
||||||
|
# Cache sudo credentials upfront so they don't expire mid-install
|
||||||
|
sudo -v
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "[1/27] Installing packages..."
|
echo "[1/27] Installing packages..."
|
||||||
sudo apt update
|
sudo apt update
|
||||||
|
|||||||
Reference in New Issue
Block a user