TimeZone Date Time for Debian and Ubuntu.

🛠️ System Maintenance & Timezone Setup Script

A production-ready, interactive Bash script for Debian 10–13 and Ubuntu 18–24 that automates system updates, timezone configuration, and NTP time synchronization — all wrapped in a clean, colorized terminal interface with full logging and error handling.


✨ Features


📋 Requirements

Requirement Notes
Bash 4.0+ Pre-installed on all target distros
systemd Required (all target distros use it)
apt Debian/Ubuntu package manager
sudo or root For system-level changes

Missing dependencies (lsb-release, pv, systemd-timesyncd) are automatically installed by the script.


🚀 Usage

🚀 One-Line Download & Execute :
apt update && apt install -y curl && clear && \
curl -s https://docs.greenhome.stream/attachments/72 -o /tmp/timezone-setup.sh && \
bash /tmp/timezone-setup.sh

OR

1. Download and make executable
chmod +x system-maintenance.sh
2. Run as root or with sudo
# As root
./system-maintenance.sh

# As a sudo-capable user
sudo ./system-maintenance.sh

🔄 What the Script Does (Step by Step)

Step 1 — Privilege Check

Detects if running as root. If not, verifies sudo access before proceeding.

Step 2 — OS Detection

Reads /etc/os-release or uses lsb_release to identify the distro and version. Exits with a clear error message if the OS is unsupported.

Step 3 — Dependency Check

Silently refreshes the apt cache and installs any missing required packages (lsb-release, pv, systemd-timesyncd).

Step 4 — System Update (optional, prompted)

Step 5 — Timezone Configuration (optional, prompted)

Step 6 — NTP Synchronization (optional, prompted)

Step 7 — Final Summary

Prints a formatted table with:


📁 Log File

All actions are recorded in: /var/log/system-maintenance.log If the script lacks write permission to /var/log/, it falls back to: /tmp/system-maintenance.log

Log entries include timestamps and status for every operation performed.


🌍 Supported Timezones (Built-in Menu)

# Timezone Offset
1 Europe/Athens (default) UTC+2/+3
2 Europe/London UTC+0/+1
3 Europe/Berlin UTC+1/+2
4 Europe/Paris UTC+1/+2
5 America/New_York UTC-5/-4
6 America/Chicago UTC-6/-5
7 America/Denver UTC-7/-6
8 America/Los_Angeles UTC-8/-7
9 UTC UTC+0
0 Custom Manual input

🐧 Compatibility Matrix

OS Versions Tested
Debian 10 (Buster), 11 (Bullseye), 12 (Bookworm), 13 (Trixie)
Ubuntu 18.04, 20.04, 22.04, 24.04
Other Any non-Debian/Ubuntu ❌ Exits gracefully

⚠️ Notes



Revision #8
Created 2026-04-18 19:04:21 EEST by Green
Updated 2026-04-18 21:02:55 EEST by Green