You've already forked chrony-ubuntu
initial commit
This commit is contained in:
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025 Allan Christensen
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
142
README.md
Normal file
142
README.md
Normal file
@@ -0,0 +1,142 @@
|
||||
# Chrony for Ubuntu 24.04 Server
|
||||
[](#)
|
||||
[](#)
|
||||
[](#)
|
||||
[](#)
|
||||
[](./LICENSE)
|
||||
|
||||
Install Chrony on Ubuntu 24.04 server.
|
||||
|
||||
This isn't a demo - This installer is intended for real servers.
|
||||
If you want ntpd nostalgia, this is NOT your script.
|
||||
|
||||
---
|
||||
|
||||
## Why this installer exists
|
||||
|
||||
Ubuntu 24.04 retired `ntpd`, `ntpdate`, and `systemd-timesyncd` as primary time sync mechanisms.
|
||||
Chrony is now the only supported, sane, and future-proof NTP client.
|
||||
|
||||
This installer:
|
||||
- Follows Canonical’s current direction
|
||||
- Avoids deprecated packages and aliases
|
||||
- Gives you deterministic, predictable time sync
|
||||
|
||||
---
|
||||
|
||||
## What this installer does
|
||||
|
||||
✔ Installs Chrony (Ubuntu default)
|
||||
✔ Enables and starts the Chrony service
|
||||
✔ Configures pool.ntp.org servers explicitly
|
||||
✔ Forces an initial clock sync (`makestep`)
|
||||
✔ Leaves legacy NTP components untouched (because they shouldn’t exist)
|
||||
|
||||
---
|
||||
|
||||
## What this installer does NOT do
|
||||
|
||||
It won’t stop you from running the script without reading the documentation like there’s no tomorrow. Skip the README, and whatever happens next is your headache, not a bug report.
|
||||
|
||||
---
|
||||
|
||||
## 1. Prepare the system
|
||||
|
||||
```
|
||||
sudo apt update -y
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 2. Download
|
||||
|
||||
```
|
||||
git clone https://git.x-files.dk/server/chrony-ubuntu.git
|
||||
```
|
||||
|
||||
```
|
||||
cd chrony-ubuntu
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. Install
|
||||
|
||||
```
|
||||
sudo ./chrony-install
|
||||
```
|
||||
|
||||
This configures the machine to use reliable upstream time servers and enables sync automatically.
|
||||
|
||||
---
|
||||
|
||||
## 4. Verify Synchronization
|
||||
|
||||
```
|
||||
chronyc sources -v
|
||||
```
|
||||
|
||||
If the peers list is present and updating — you're synced and good to go.
|
||||
|
||||
---
|
||||
|
||||
## Post-Install
|
||||
|
||||
Nothing else required — time sync is automatic.
|
||||
|
||||
---
|
||||
|
||||
## Client vs Server mode (important)
|
||||
|
||||
This installer always installs **Chrony**, which on Ubuntu 24.04 replaces both:
|
||||
- legacy `ntp-client`
|
||||
- legacy `ntpd` server setups
|
||||
|
||||
### Default behavior (Client only)
|
||||
|
||||
Out of the box, Chrony runs in **client-only mode**:
|
||||
- Syncs time from upstream servers
|
||||
- Does **not** serve time to other machines
|
||||
- Does **not** listen on UDP/123
|
||||
|
||||
This is the functional equivalent of an old “NTP client” setup.
|
||||
|
||||
### Optional: Serve time to other machines (LAN / offline networks)
|
||||
|
||||
If this machine should also act as a **local NTP server**, only **two lines** are required in `/etc/chrony/chrony.conf`:
|
||||
|
||||
```
|
||||
allow 192.168.0.0/24
|
||||
local stratum 10
|
||||
```
|
||||
|
||||
What these lines do:
|
||||
- `allow` — permits NTP clients from the specified network
|
||||
- `local stratum 10` — provides a safe fallback clock if upstream sources disappear
|
||||
|
||||
Restart Chrony:
|
||||
|
||||
```
|
||||
systemctl restart chrony
|
||||
```
|
||||
|
||||
If a firewall is enabled:
|
||||
|
||||
```
|
||||
ufw allow from 192.168.0.0/24 to any port 123 proto udp
|
||||
```
|
||||
|
||||
Chrony will now act as **both client and server**, fully replacing the Ubuntu 22.04 NTP server pattern.
|
||||
|
||||
---
|
||||
|
||||
### More Information
|
||||
|
||||
More guides and documentation can be found on [wiki.x-files.dk](https://wiki.x-files.dk)
|
||||
|
||||
---
|
||||
|
||||
### License
|
||||
Licensed under the [MIT License](./LICENSE).
|
||||
|
||||
---
|
||||
74
chrony-install
Executable file
74
chrony-install
Executable file
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Author : Allan Christensen
|
||||
# First Created : 18122025 (DD-MM-YYYY)
|
||||
# Description : Installs Chrony on Ubuntu 24.04
|
||||
# License : MIT License (see LICENSE file for details)
|
||||
|
||||
#
|
||||
# Are we root
|
||||
#
|
||||
if [[ $(id -u) -ne 0 ]]; then echo "" && echo "Must be root or use sudo" && echo "" ; exit ; fi
|
||||
|
||||
#
|
||||
# Pre-create Chrony log directory (avoids dpkg-statoverride warning)
|
||||
#
|
||||
install -d -o chrony -g chrony -m 0750 /var/log/chrony
|
||||
|
||||
#
|
||||
# Install Chrony
|
||||
#
|
||||
apt install -y chrony
|
||||
|
||||
#
|
||||
# Enable and start Chrony
|
||||
#
|
||||
systemctl enable chrony --now
|
||||
|
||||
#
|
||||
# Chrony configuration file
|
||||
#
|
||||
conf_file="/etc/chrony/chrony.conf"
|
||||
backup_file="${conf_file}.bak"
|
||||
|
||||
#
|
||||
# Backup existing config
|
||||
#
|
||||
cp "$conf_file" "$backup_file"
|
||||
|
||||
#
|
||||
# Define NTP servers
|
||||
#
|
||||
chrony_servers="pool 0.pool.ntp.org iburst
|
||||
pool 1.pool.ntp.org iburst
|
||||
pool 2.pool.ntp.org iburst
|
||||
pool 3.pool.ntp.org iburst"
|
||||
|
||||
#
|
||||
# Comment out existing pool lines
|
||||
#
|
||||
sed -i '/^pool / s/^/# /' "$conf_file"
|
||||
|
||||
#
|
||||
# Append our servers
|
||||
#
|
||||
printf "\n# Custom NTP servers\n%s\n" "$chrony_servers" >> "$conf_file"
|
||||
|
||||
#
|
||||
# Restart Chrony
|
||||
#
|
||||
systemctl restart chrony
|
||||
|
||||
#
|
||||
# Force immediate time sync
|
||||
#
|
||||
chronyc makestep
|
||||
|
||||
#
|
||||
# All done
|
||||
#
|
||||
printf "\nAll Done...\n"
|
||||
|
||||
#
|
||||
# End of script
|
||||
#
|
||||
4
last-tested
Normal file
4
last-tested
Normal file
@@ -0,0 +1,4 @@
|
||||
------------------------------------
|
||||
Last tested: 18-12-2025 (DD-MM-YYYY)
|
||||
Environment: Ubuntu Server 24.04 LTS
|
||||
------------------------------------
|
||||
Reference in New Issue
Block a user