From 474e62d487d482d8cda3bc7b00a243cde4e6a320 Mon Sep 17 00:00:00 2001 From: Chris Frankland-Wright Date: Sat, 30 Aug 2025 23:02:48 +0100 Subject: [PATCH] created updater --- README.md | 19 +++++++++++++++++++ update.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 update.sh diff --git a/README.md b/README.md index 495c983..9102675 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,25 @@ The installation script automates the following steps: After installation is complete, the script will provide instructions to start the service manually or to run the application in its interactive terminal mode. +--- + +## 🔄 Updating + +If you installed TimeTurner by cloning the repository with `git`, you can use the `update.sh` script to easily update to the latest version. + +**Note**: This script will not work if you used the `curl` one-line command for installation, as that method does not create a Git repository. + +To run the update script, navigate to the `NTP-Timeturner-main` directory and run: +```bash +chmod +x update.sh && ./update.sh +``` + +The update script automates the following: +1. Pulls the latest code from the `main` branch on GitHub. +2. Rebuilds the application binary. +3. Copies the new binary to `/opt/timeturner/`. +4. Restarts the `timeturner` service to apply the changes. + --- ## 🕰️ Chrony NTP ```bash diff --git a/update.sh b/update.sh new file mode 100644 index 0000000..666471e --- /dev/null +++ b/update.sh @@ -0,0 +1,28 @@ +#!/bin/bash +set -e + +echo "--- TimeTurner Update Script ---" + +# 1. Fetch the latest changes from the git repository +echo "🔄 Pulling latest changes from GitHub..." +git pull origin main + +# 2. Rebuild the release binary +echo "📦 Building release binary with Cargo..." +cargo build --release + +# 3. Stop the currently running service to release the file lock +echo "🛑 Stopping TimeTurner service..." +sudo systemctl stop timeturner.service + +# 4. Copy the new binary to the installation directory +echo "🚀 Deploying new binary..." +sudo cp target/release/timeturner /opt/timeturner/timeturner + +# 5. Restart the service with the new binary +echo "✅ Restarting TimeTurner service..." +sudo systemctl restart timeturner.service + +echo "" +echo "Update complete. To check the status of the service, run:" +echo " systemctl status timeturner.service" \ No newline at end of file