From 6f2aeddc2eb3a42852d071822d52bb4c66fd52df Mon Sep 17 00:00:00 2001 From: Lloyd Date: Mon, 27 Oct 2025 22:35:15 +0000 Subject: [PATCH] Add upgrade script for pyMC Repeater: automate updates, service management, and error handling --- README.md | 66 ++++++++++++++++++++++++++++++++++++++++ upgrade.sh | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 154 insertions(+) create mode 100644 upgrade.sh diff --git a/README.md b/README.md index 2a5ceee..ce879a7 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,47 @@ My hope is that **pyMC_repeater** serves as a solid, approachable foundation tha The repeater daemon runs continuously as a background process, forwarding LoRa packets using `pymc_core`'s Dispatcher and packet routing. +Supported Hardware (Out of the Box) + +The following hardware is currently supported out-of-the-box: + +Waveshare LoRaWAN/GNSS HAT + + Hardware: Waveshare SX1262 LoRa HAT + Platform: Raspberry Pi (or compatible single-board computer) + Frequency: 868MHz (EU) or 915MHz (US) + TX Power: Up to 22dBm + SPI Bus: SPI0 + GPIO Pins: CS=21, Reset=18, Busy=20, IRQ=16 + +HackerGadgets uConsole + + Hardware: uConsole RTL-SDR/LoRa/GPS/RTC/USB Hub + Platform: Clockwork uConsole (Raspberry Pi CM4/CM5) + Frequency: 433/915MHz (configurable) + TX Power: Up to 22dBm + SPI Bus: SPI1 + GPIO Pins: CS=-1, Reset=25, Busy=24, IRQ=26 + Additional Setup: Requires SPI1 overlay and GPS/RTC configuration (see uConsole setup guide) + +Frequency Labs meshadv-mini + + Hardware: FrequencyLabs meshadv-mini Hat + Platform: Raspberry Pi (or compatible single-board computer) + Frequency: 868MHz (EU) or 915MHz (US) + TX Power: Up to 22dBm + SPI Bus: SPI0 + GPIO Pins: CS=8, Reset=24, Busy=20, IRQ=16 + +Frequency Labs meshadv + + Hardware: FrequencyLabs meshadv-mini Hat + Platform: Raspberry Pi (or compatible single-board computer) + Frequency: 868MHz (EU) or 915MHz (US) + TX Power: Up to 22dBm + SPI Bus: SPI0 + GPIO Pins: CS=21, Reset=18, Busy=20, IRQ=16, TXEN=13, RXEN=12 + ... ## Screenshots @@ -84,7 +125,28 @@ To reconfigure radio and hardware settings after installation, run: ```bash sudo bash setup-radio-config.sh /etc/pymc_repeater sudo systemctl restart pymc-repeater + ``` +## Upgrading + +To upgrade an existing installation to the latest version: + +```bash +# Navigate to your pyMC_Repeater directory +cd pyMC_Repeater + +# Run the upgrade script +sudo ./upgrade.sh +``` + +The upgrade script will: +- Pull the latest code from the main branch +- Update all application files +- Upgrade Python dependencies if needed +- Restart the service automatically +- Preserve your existing configuration + + ## Uninstallation @@ -162,3 +224,7 @@ Pre-commit hooks will automatically: ## License This project is licensed under the MIT License - see the LICENSE file for details. + + + + diff --git a/upgrade.sh b/upgrade.sh new file mode 100644 index 0000000..cd01ef8 --- /dev/null +++ b/upgrade.sh @@ -0,0 +1,88 @@ +#!/bin/bash +# Simple upgrade script for pyMC Repeater + +set -e + +INSTALL_DIR="/opt/pymc_repeater" +SERVICE_USER="repeater" + +echo "=== pyMC Repeater Upgrade ===" + +# Check if running as root +if [ "$EUID" -ne 0 ]; then + echo "Error: This script must be run as root" + exit 1 +fi + +# Check if pyMC Repeater is installed +if [ ! -d "$INSTALL_DIR" ]; then + echo "Error: pyMC Repeater is not installed in $INSTALL_DIR" + echo "Please run deploy.sh to install first." + exit 1 +fi + +# Check if we're in a git repository +if [ ! -d ".git" ]; then + echo "Error: This script must be run from the pyMC Repeater git repository root" + exit 1 +fi + +# Check service status +SERVICE_WAS_RUNNING=false +if systemctl is-active --quiet pymc-repeater; then + SERVICE_WAS_RUNNING=true + echo "Stopping pyMC Repeater service..." + systemctl stop pymc-repeater +fi + +# Pull latest changes +echo "Pulling latest code from main branch..." +git fetch origin +git checkout main +git pull origin main + +# Copy updated files +echo "Installing updated files..." +cp -r repeater "$INSTALL_DIR/" +cp pyproject.toml "$INSTALL_DIR/" +cp README.md "$INSTALL_DIR/" +cp setup-radio-config.sh "$INSTALL_DIR/" +cp radio-settings.json "$INSTALL_DIR/" + +# Update systemd service if changed +if [ -f "pymc-repeater.service" ]; then + cp pymc-repeater.service /etc/systemd/system/ + systemctl daemon-reload +fi + +# Update Python package and dependencies +echo "Updating Python package and dependencies..." +cd "$INSTALL_DIR" +pip install --break-system-packages --upgrade --force-reinstall -e . + +# Set permissions +chown -R "$SERVICE_USER:$SERVICE_USER" "$INSTALL_DIR" + +# Restart service if it was running +if [ "$SERVICE_WAS_RUNNING" = true ]; then + echo "Starting pyMC Repeater service..." + systemctl start pymc-repeater + sleep 2 + + if systemctl is-active --quiet pymc-repeater; then + echo "✓ Service restarted successfully" + else + echo "✗ Service failed to start - check logs:" + journalctl -u pymc-repeater --no-pager -n 10 + exit 1 + fi +fi + +echo "" +echo "=== Upgrade Complete ===" +echo "Updated to: $(git rev-parse --short HEAD)" +echo "" +echo "Check status: systemctl status pymc-repeater" +echo "View logs: journalctl -u pymc-repeater -f" +echo "Dashboard: http://$(hostname -I | awk '{print $1}'):8000" +echo "----------------------------------" \ No newline at end of file