Maintenance

Keeping Morse-Pi up to date, managing packages, and controlling the system service.

Updating

Rust backend

Pulls the latest code, rebuilds the binary, and restarts the service:

curl -sSL https://raw.githubusercontent.com/Nerd-or-Geek/Morse-Pi/main/update-rust.sh | sudo bash

The updater will:

  1. Verify USB HID gadget configuration
  2. Pull the latest code (preserves settings.json, stats.json, words.json)
  3. Rebuild the Rust binary with cargo build --release
  4. Sync the latest Rust templates into /opt/morse-pi/morse-translator/templates
  5. Recreate the systemd service and restart

Python backend

Use the dedicated update script to pull the latest code while preserving your settings:

curl -sSL https://raw.githubusercontent.com/Nerd-or-Geek/Morse-Pi/main/update.sh | sudo bash

The update script:

  1. Verifies USB HID is configured correctly
  2. Pulls the latest code (HTML, Python, word lists, etc.)
  3. Preserves settings.json and stats.json
  4. Recreates the systemd service and restarts

Manual update

sudo git -C /opt/morse-pi pull
sudo systemctl restart morse-pi
ℹ Rust backend rebuild
If you're running the Rust backend, you'll need to rebuild and sync templates after pulling new code:
cd /opt/morse-pi/morse-translator-rust
cargo build --release --features gpio
sudo cp target/release/morse-pi /opt/morse-pi/morse-translator/morse-pi
sudo mkdir -p /opt/morse-pi/morse-translator/templates
sudo cp -r templates/. /opt/morse-pi/morse-translator/templates/
sudo systemctl restart morse-pi

Switching Backends

Python → Rust

Transition your existing Python installation to the Rust backend. Settings, stats, and word lists are preserved automatically:

curl -sSL https://raw.githubusercontent.com/Nerd-or-Geek/Morse-Pi/main/transition-rust.sh | sudo bash

The script installs the Rust toolchain, builds the binary, backs up your data, replaces the Python files, updates systemd, and starts the new service.

Rust → Python (revert)

To revert to the Python backend:

sudo systemctl stop morse-pi
cd /opt/morse-pi && git checkout -- morse-translator/
curl -sSL https://raw.githubusercontent.com/Nerd-or-Geek/Morse-Pi/main/install.sh | sudo bash

Package Management

To upgrade system and Python packages without changing application code:

curl -sSL https://raw.githubusercontent.com/Nerd-or-Geek/Morse-Pi/main/packages.sh | sudo bash

This upgrades flask, gpiozero, pigpio, and other dependencies to their latest versions, then restarts the service. It reports installed versions when complete.

Service Management

Main web app service

These commands work the same regardless of which backend (Python or Rust) is running:

sudo systemctl status  morse-pi    # check if running
sudo systemctl restart morse-pi    # restart
sudo systemctl stop    morse-pi    # stop
sudo journalctl -u morse-pi -f     # live logs
sudo journalctl -u morse-pi -n 50  # last 50 log lines
ℹ Which backend am I running?
Check the ExecStart line in the service file:
grep ExecStart /etc/systemd/system/morse-pi.service
If it ends in morse-pi (no extension), you're on Rust. If it runs python3 app.py, you're on Python.

USB HID service

sudo systemctl status  morse-pi-hid    # check HID gadget status
sudo systemctl restart morse-pi-hid    # reconfigure USB gadget

pigpio daemon

sudo systemctl status  pigpiod    # check GPIO daemon
sudo systemctl restart pigpiod    # restart GPIO daemon

Auto-Start on Boot

If you used the installer or updater, Morse-Pi automatically starts when the Pi boots. The systemd service:

Verify auto-start

# Should output "enabled"
sudo systemctl is-enabled morse-pi

# Check if running
sudo systemctl status morse-pi

Fix auto-start manually

sudo systemctl daemon-reload
sudo systemctl enable morse-pi
sudo systemctl start morse-pi