Add upgrade script for pyMC Repeater: automate updates, service management, and error handling

This commit is contained in:
Lloyd
2025-10-27 22:35:15 +00:00
parent 3bb2dca587
commit 6f2aeddc2e
2 changed files with 154 additions and 0 deletions

View File

@@ -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.

88
upgrade.sh Normal file
View File

@@ -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 "----------------------------------"