mirror of
https://github.com/cjfranko/NTP-Timeturner.git
synced 2025-11-08 18:32:02 +00:00
updated setup.sh file
This commit is contained in:
parent
3f99488ea0
commit
24c09fa233
2 changed files with 22 additions and 20 deletions
35
README.md
35
README.md
|
|
@ -50,36 +50,37 @@ When running as a background daemon, TimeTurner provides a web interface for mon
|
||||||
|
|
||||||
## 🚀 Installation
|
## 🚀 Installation
|
||||||
|
|
||||||
The `setup.sh` script is provided to compile and install the TimeTurner application and its systemd service on a Debian-based system like Raspberry Pi OS.
|
The `setup.sh` script compiles and installs the TimeTurner application. You can run it by cloning the repository with `git` or by using the `curl` command below for a git-free installation.
|
||||||
|
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
|
||||||
- **Rust and Cargo**: The script requires the Rust programming language toolchain. If you don't have it, install it from [rustup.rs](https://rustup.rs/).
|
- **Internet Connection**: To download dependencies.
|
||||||
|
- **Curl and Unzip**: The script requires `curl` to download files and `unzip` for the git-free method. The setup script will attempt to install these if they are missing.
|
||||||
|
|
||||||
### Running the Installer
|
### Running the Installer (Recommended)
|
||||||
|
|
||||||
1. First, clone the repository:
|
This command downloads the latest version, unpacks it, and runs the setup script. Paste it into your Raspberry Pi terminal:
|
||||||
```bash
|
|
||||||
git clone https://github.com/cjfranko/NTP-Timeturner.git
|
```bash
|
||||||
cd NTP-Timeturner
|
curl -L https://github.com/cjfranko/NTP-Timeturner/archive/refs/heads/main.zip -o NTP-Timeturner.zip && \
|
||||||
```
|
unzip NTP-Timeturner.zip && \
|
||||||
2. Make the script executable and run it. The script will use `sudo` for commands that require root privileges, so it may ask for your password.
|
cd NTP-Timeturner-main && \
|
||||||
```bash
|
chmod +x setup.sh && \
|
||||||
chmod +x setup.sh
|
./setup.sh
|
||||||
./setup.sh
|
```
|
||||||
```
|
|
||||||
|
|
||||||
### What the Script Does
|
### What the Script Does
|
||||||
|
|
||||||
The installation script automates the following steps:
|
The installation script automates the following steps:
|
||||||
|
|
||||||
1. **Compiles the Binary**: Runs `cargo build --release` to create an optimised executable.
|
1. **Installs Dependencies**: Installs `git`, `curl`, `unzip`, and necessary build tools.
|
||||||
2. **Creates Directories**: Creates `/opt/timeturner` to store the application files.
|
2. **Compiles the Binary**: Runs `cargo build --release` to create an optimised executable.
|
||||||
3. **Installs Files**:
|
3. **Creates Directories**: Creates `/opt/timeturner` to store the application files.
|
||||||
|
4. **Installs Files**:
|
||||||
- The compiled binary is copied to `/opt/timeturner/timeturner`.
|
- The compiled binary is copied to `/opt/timeturner/timeturner`.
|
||||||
- The web interface assets from the `static/` directory are copied to `/opt/timeturner/static`.
|
- The web interface assets from the `static/` directory are copied to `/opt/timeturner/static`.
|
||||||
- A symbolic link is created from `/usr/local/bin/timeturner` to the binary, allowing it to be run from any location.
|
- A symbolic link is created from `/usr/local/bin/timeturner` to the binary, allowing it to be run from any location.
|
||||||
4. **Sets up Systemd Service**:
|
5. **Sets up Systemd Service**:
|
||||||
- Copies the `timeturner.service` file to `/etc/systemd/system/`.
|
- Copies the `timeturner.service` file to `/etc/systemd/system/`.
|
||||||
- Enables the service to start automatically on system boot.
|
- Enables the service to start automatically on system boot.
|
||||||
|
|
||||||
|
|
|
||||||
7
setup.sh
7
setup.sh
|
|
@ -21,7 +21,8 @@ echo "Detected package manager: $PKG_MANAGER"
|
||||||
# --- Update System Packages ---
|
# --- Update System Packages ---
|
||||||
echo "Updating system packages..."
|
echo "Updating system packages..."
|
||||||
if [ "$PKG_MANAGER" == "apt" ]; then
|
if [ "$PKG_MANAGER" == "apt" ]; then
|
||||||
sudo apt update && sudo apt upgrade -y
|
sudo apt update
|
||||||
|
sudo DEBIAN_FRONTEND=noninteractive apt upgrade -y -o Dpkg::Options::="--force-confold"
|
||||||
elif [ "$PKG_MANAGER" == "dnf" ]; then
|
elif [ "$PKG_MANAGER" == "dnf" ]; then
|
||||||
sudo dnf upgrade -y
|
sudo dnf upgrade -y
|
||||||
elif [ "$PKG_MANAGER" == "pacman" ]; then
|
elif [ "$PKG_MANAGER" == "pacman" ]; then
|
||||||
|
|
@ -100,10 +101,10 @@ echo "Removing NTPD (if installed) and installing Chrony, NMTUI, Adjtimex..."
|
||||||
if [ "$PKG_MANAGER" == "apt" ]; then
|
if [ "$PKG_MANAGER" == "apt" ]; then
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt remove -y ntp || true # Remove ntp if it exists, ignore if not
|
sudo apt remove -y ntp || true # Remove ntp if it exists, ignore if not
|
||||||
sudo apt install -y chrony nmtui adjtimex
|
sudo apt install -y chrony network-manager adjtimex
|
||||||
sudo systemctl enable chrony --now
|
sudo systemctl enable chrony --now
|
||||||
elif [ "$PKG_MANAGER" == "dnf" ]; then
|
elif [ "$PKG_MANAGER" == "dnf" ]; then
|
||||||
sudo dnf remove -y ntp || true
|
sudo dnf remove -y ntp
|
||||||
sudo dnf install -y chrony NetworkManager-tui adjtimex
|
sudo dnf install -y chrony NetworkManager-tui adjtimex
|
||||||
sudo systemctl enable chronyd --now
|
sudo systemctl enable chronyd --now
|
||||||
elif [ "$PKG_MANAGER" == "pacman" ]; then
|
elif [ "$PKG_MANAGER" == "pacman" ]; then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue