Skip to content

GeorgeElliott/pi-server-remote-rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pi-server-remote-rust

A lightweight web dashboard that runs on a Raspberry Pi, allowing you to trigger configurable shell commands and monitor status checks from a browser. Built with Rust and Axum, designed to use as little memory and CPU as possible.

Why?

I got into self-hosting and turned my old PC into a Linux server. Had a Raspberry Pi 1 Model A sitting in my loft for 12 years, so I thought I'd actually use it for something. I wanted a way to wake up the server, run commands on it, and shut it down without having to sit at a keyboard.

I had originally written this in python but it was using about a 20% of the available 512mb of RAM, so I thought I would try writing it in rust so that it uses as little memory and CPU as possible. This decreased RAM consumption to around 5%.

My Pi is always on and connected to my home network over WiFi. It's also connected to the server directly via Ethernet. This dashboard lets me:

  • Send a Wake-on-LAN packet over the Ethernet interface to power the server on
  • SSH into the server to run commands remotely (start/stop Docker containers, shut down, etc.)
  • Monitor status to see if the server is online
  • Quick-link to other services on my network (router, media server, etc.)

Screenshots

Controls Links
Controls Links

PWA Support

This project includes a manifest.json and sw.js (service worker) in the static files so I can run the dashboard as a Progressive Web App (PWA) on my phone. I had create a certificate and add it to my phone it was more work than I hoped but feels a bit nicer when I use it.

Features

  • Run configurable shell commands from a web UI (e.g. wake-on-LAN, SSH, reboot)
  • Poll status targets on a configurable interval (e.g. check if a server is online)
  • Quick-link list to other local services
  • All configuration via a single config.yaml file
  • Serves on port 7878

Project Structure

├── app/                    # Rust web application
│   ├── Cargo.toml
│   ├── src/
│   ├── templates/
│   ├── static/
│   ├── config.yaml.example
│   └── config.yaml         (git-ignored, your local config)
├── images/                 # Screenshots
├── server-remote-rust.service.example
├── LICENSE
└── README.md

Requirements

  • Rust toolchain (stable)
  • cross for cross-compilation
  • Docker (required by cross)

Building

The Raspberry Pi 1 is far too slow to compile Rust. Cross-compile on a more powerful machine using cross and copy the binary over.

Install cross if you haven't already:

cargo install cross

Add the target (only needed once):

rustup target add arm-unknown-linux-gnueabihf

Build a release binary from the app/ directory:

cd app
cross build --release --target arm-unknown-linux-gnueabihf

The compiled binary will be at:

app/target/arm-unknown-linux-gnueabihf/release/server-remote-rust

Installation on the Pi

  1. Create a directory on the Pi and copy the required files:

    ssh user@your-pi "sudo mkdir -p /opt/server-remote-rust"
    
    scp app/target/arm-unknown-linux-gnueabihf/release/server-remote-rust user@your-pi:/opt/server-remote-rust/
    scp -r app/templates/ user@your-pi:/opt/server-remote-rust/
    scp -r app/static/ user@your-pi:/opt/server-remote-rust/
    scp app/config.yaml user@your-pi:/opt/server-remote-rust/
  2. Make the binary executable:

    ssh user@your-pi "chmod +x /opt/server-remote-rust/server-remote-rust"
  3. Set up the systemd service:

    Copy and edit the example service file:

    scp server-remote-rust.service.example user@your-pi:/tmp/server-remote-rust.service

    On the Pi, edit the service file to set your User and Group, then install it:

    sudo cp /tmp/server-remote-rust.service /etc/systemd/system/server-remote-rust.service
    sudo systemctl daemon-reload
    sudo systemctl enable server-remote-rust
    sudo systemctl start server-remote-rust
  4. Access the dashboard:

    Open http://your-pi-ip:7878 in a browser.

Configuration

Copy config.yaml.example to config.yaml and edit to suit your setup:

commands:
  - id: wake_server
    title: Wake Server
    shell: "ether-wake -i eth0 d8:cb:8a:3b:92:91"

  - id: reboot_pi
    title: Reboot Pi
    shell: "sudo reboot"

status:
  - id: server_status
    name: "Server Status"
    shell: "ping -c 1 -W 2 192.168.1.100"

links:
  - name: Router Dashboard
    url: "http://192.168.1.1"
  • commands — buttons that execute a shell command when clicked
  • status — polled periodically to show online/offline indicators
  • links — quick-link tiles to other local services

API

Method Endpoint Description
GET / Serves the dashboard UI
POST /api/run/:id Executes a command by ID
GET /api/status/:id Polls a status check by ID

License

MIT License

About

Simple website that allows you to specify bash commands to run. The idea is that it uses as little resources as possible. This will be running on my Raspberry pi 1 which I bought back in 2014.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors