From b6a7606e1a3d97bd13641406f28438acf02a7320 Mon Sep 17 00:00:00 2001 From: Chris Frankland-Wright Date: Sun, 24 Aug 2025 13:06:07 +0100 Subject: [PATCH 1/4] feat: Add automated dependency installation for Rust, Chrony, NMTUI, and adjtimex Co-authored-by: aider (gemini/gemini-2.5-flash) --- setup.sh | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 65 insertions(+), 6 deletions(-) diff --git a/setup.sh b/setup.sh index b8d556f..f00d1fa 100644 --- a/setup.sh +++ b/setup.sh @@ -3,14 +3,73 @@ set -e echo "--- TimeTurner Setup ---" -# 1. Build the release binary -echo "📦 Building release binary with Cargo..." -if ! command -v cargo &> /dev/null -then - echo "❌ Cargo is not installed. Please install Rust and Cargo first." - echo "Visit https://rustup.rs/ for instructions." +# Determine package manager +PKG_MANAGER="" +if command -v apt &> /dev/null; then + PKG_MANAGER="apt" +elif command -v dnf &> /dev/null; then + PKG_MANAGER="dnf" +elif command -v pacman &> /dev/null; then + PKG_MANAGER="pacman" +else + echo "Error: No supported package manager (apt, dnf, pacman) found. Please install dependencies manually." exit 1 fi + +echo "Detected package manager: $PKG_MANAGER" + +# --- Install Rust/Cargo if not installed --- +if ! command -v cargo &> /dev/null; then + echo "Rust/Cargo not found. Installing Rustup..." + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + # Source cargo's env for the current shell session + # This is for the current script's execution path, typically rustup adds to .bashrc/.profile for future sessions. + # We need it now, but for non-interactive script, sourcing won't affect parent shell. + # However, cargo build below will rely on it being in PATH. rustup makes sure of this if it installs. + # For safety, ensure PATH is updated. + export PATH="$HOME/.cargo/bin:$PATH" + echo "Rust/Cargo installed successfully." +else + echo "Rust/Cargo is already installed." +fi + +# --- Install common build dependencies for Rust --- +echo "Installing common build dependencies..." +if [ "$PKG_MANAGER" == "apt" ]; then + sudo apt update + sudo apt install -y build-essential libudev-dev pkg-config +elif [ "$PKG_MANAGER" == "dnf" ]; then + sudo dnf install -y gcc make perl-devel libudev-devel pkg-config +elif [ "$PKG_MANAGER" == "pacman" ]; then + sudo pacman -Sy --noconfirm base-devel libudev pkg-config +fi +echo "Common build dependencies installed." + +# --- Remove NTPD and install Chrony, NMTUI, Adjtimex --- +echo "Removing NTPD (if installed) and installing Chrony, NMTUI, Adjtimex..." + +if [ "$PKG_MANAGER" == "apt" ]; then + sudo apt update + sudo apt remove -y ntp || true # Remove ntp if it exists, ignore if not + sudo apt install -y chrony nmtui adjtimex + sudo systemctl enable chrony --now +elif [ "$PKG_MANAGER" == "dnf" ]; then + sudo dnf remove -y ntp || true + sudo dnf install -y chrony NetworkManager-tui adjtimex + sudo systemctl enable chronyd --now +elif [ "$PKG_MANAGER" == "pacman" ]; then + sudo pacman -Sy --noconfirm ntp || true + sudo pacman -R --noconfirm ntp || true # Ensure ntp is removed + sudo pacman -Sy --noconfirm chrony networkmanager adjtimex + sudo systemctl enable chronyd --now + sudo systemctl enable NetworkManager --now # nmtui relies on NetworkManager +fi + +echo "NTPD removed (if present). Chrony, NMTUI, and Adjtimex installed and configured." + +# 1. Build the release binary +echo "📦 Building release binary with Cargo..." +# No need to check for cargo again, as it's handled above cargo build --release echo "✅ Build complete." From cd9ac5a141e209b41368f5795dc4a7d0c579f3ff Mon Sep 17 00:00:00 2001 From: Chris Frankland-Wright Date: Sun, 24 Aug 2025 13:07:08 +0100 Subject: [PATCH 2/4] feat: Add system package update to setup script Co-authored-by: aider (gemini/gemini-2.5-flash) --- setup.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/setup.sh b/setup.sh index f00d1fa..a630f02 100644 --- a/setup.sh +++ b/setup.sh @@ -18,6 +18,17 @@ fi echo "Detected package manager: $PKG_MANAGER" +# --- Update System Packages --- +echo "Updating system packages..." +if [ "$PKG_MANAGER" == "apt" ]; then + sudo apt update && sudo apt upgrade -y +elif [ "$PKG_MANAGER" == "dnf" ]; then + sudo dnf upgrade -y +elif [ "$PKG_MANAGER" == "pacman" ]; then + sudo pacman -Syu --noconfirm +fi +echo "System packages updated." + # --- Install Rust/Cargo if not installed --- if ! command -v cargo &> /dev/null; then echo "Rust/Cargo not found. Installing Rustup..." From 8362435e12c1c624d0275fe88128a95653c71fe5 Mon Sep 17 00:00:00 2001 From: Chris Frankland-Wright Date: Sun, 24 Aug 2025 13:16:19 +0100 Subject: [PATCH 3/4] feat: Implement custom Plymouth splash screen installation Co-authored-by: aider (gemini/gemini-2.5-flash) --- setup.sh | 44 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/setup.sh b/setup.sh index a630f02..ce1bf72 100644 --- a/setup.sh +++ b/setup.sh @@ -48,14 +48,52 @@ fi echo "Installing common build dependencies..." if [ "$PKG_MANAGER" == "apt" ]; then sudo apt update - sudo apt install -y build-essential libudev-dev pkg-config + sudo apt install -y build-essential libudev-dev pkg-config curl elif [ "$PKG_MANAGER" == "dnf" ]; then - sudo dnf install -y gcc make perl-devel libudev-devel pkg-config + sudo dnf install -y gcc make perl-devel libudev-devel pkg-config curl elif [ "$PKG_MANAGER" == "pacman" ]; then - sudo pacman -Sy --noconfirm base-devel libudev pkg-config + sudo pacman -Sy --noconfirm base-devel libudev pkg-config curl fi echo "Common build dependencies installed." +# --- Apply custom splash screen --- +if [[ "$(uname)" == "Linux" ]]; then + echo "🖼️ Applying custom splash screen..." + SPLASH_URL="https://raw.githubusercontent.com/cjfranko/NTP-Timeturner/refs/heads/main/splash.png" + PLYMOUTH_THEME_DIR="/usr/share/plymouth/themes/pix" + PLYMOUTH_IMAGE_PATH="${PLYMOUTH_THEME_DIR}/splash.png" + + sudo mkdir -p "${PLYMOUTH_THEME_DIR}" + echo "Downloading splash image from ${SPLASH_URL}..." + sudo curl -L "${SPLASH_URL}" -o "${PLYMOUTH_IMAGE_PATH}" + + if [ -f "${PLYMOUTH_IMAGE_PATH}" ]; then + echo "Splash image downloaded. Updating Plymouth configuration..." + # Set 'pix' as the default plymouth theme if not already. + # This is a common theme that expects splash.png. + sudo update-alternatives --install /usr/share/plymouth/themes/default.plymouth default.plymouth "${PLYMOUTH_THEME_DIR}/pix.plymouth" 100 || true + # Ensure the pix theme exists and is linked + if [ ! -f "${PLYMOUTH_THEME_DIR}/pix.plymouth" ]; then + echo "Creating dummy pix.plymouth for update-initramfs" + echo "[Plymouth Theme]" | sudo tee "${PLYMOUTH_THEME_DIR}/pix.plymouth" > /dev/null + echo "Name=Pi Splash" | sudo tee -a "${PLYMOUTH_THEME_DIR}/pix.plymouth" > /dev/null + echo "Description=TimeTurner Raspberry Pi Splash Screen" | sudo tee -a "${PLYMOUTH_THEME_DIR}/pix.plymouth" > /dev/null + echo "SpriteAnimation=/splash.png" | sudo tee -a "${PLYMOUTH_THEME_DIR}/pix.plymouth" > /dev/null + fi + + # Update the initial RAM filesystem to include the new splash screen + sudo update-initramfs -u + echo "✅ Custom splash screen applied. Reboot may be required to see changes." + else + echo "❌ Failed to download splash image from ${SPLASH_URL}." + fi +else + echo "⚠️ Skipping splash screen configuration on non-Linux OS." +fi + +# --- Remove NTPD and install Chrony, NMTUI, Adjtimex --- +echo "Removing NTPD (if installed) and installing Chrony, NMTUI, Adjtimex..." + # --- Remove NTPD and install Chrony, NMTUI, Adjtimex --- echo "Removing NTPD (if installed) and installing Chrony, NMTUI, Adjtimex..." From e2d48391eaf02a1301093c06bdc53ca3b2d6bf86 Mon Sep 17 00:00:00 2001 From: Chris Frankland-Wright Date: Tue, 26 Aug 2025 11:19:53 +0100 Subject: [PATCH 4/4] create localised hotspot --- setup.sh | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/setup.sh b/setup.sh index ce1bf72..eb1be25 100644 --- a/setup.sh +++ b/setup.sh @@ -116,6 +116,80 @@ fi echo "NTPD removed (if present). Chrony, NMTUI, and Adjtimex installed and configured." +# --- Install and configure WiFi hotspot and captive portal --- +echo "📡 Installing and configuring WiFi hotspot and captive portal..." + +if [ "$PKG_MANAGER" == "apt" ]; then + sudo apt install -y hostapd dnsmasq nodogsplash + sudo systemctl unmask hostapd + sudo systemctl enable hostapd + sudo systemctl enable nodogsplash +fi + +# Stop services to configure +sudo systemctl stop hostapd +sudo systemctl stop dnsmasq +sudo systemctl stop nodogsplash + +# Configure static IP for wlan0 +echo "Configuring static IP for wlan0..." +sudo sed -i '/^interface wlan0/d' /etc/dhcpcd.conf +sudo tee -a /etc/dhcpcd.conf > /dev/null < /dev/null < /dev/null < /dev/null <