Skip to content
Projets

À propos

Your personal gadget quartermaster. Create custom commands, trigger them with a tap from your phone, and watch your machine spring into action. Runs on anything — Raspberry Pi, laptop, server, the fridge (if it runs Linux). Because Batman had Alfred, but you have Lucius. (Batmobile not included.)

Développement web et applicatif

Comment ces chiffres sont mesurés

What you can do

  • 📱 Mobile-First & High Accessibility — huge thumb-friendly action cards with automatic icons and color themes for instant visual recognition
  • 📲 PWA Ready — installable directly on your phone's home screen as a native-like app (no browser bars) with static-asset caching
  • ⚡ Real-time execution (WebSockets) — stream command output line-by-line as it happens, with a 50 KB bounded memory buffer and automatic non-JS fallback (POST /run)
  • 📖 Execution History & Logs — dedicated /logs page keeping the last 50 executions (Web UI, WebSocket, and REST API) in a chmod 600 local history.json

Progression mesurée des étoiles

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
+2

Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.

README.md

Original

⚡ Lucius

Your shell commands, one tap away.

Lucius is a self-hosted web dashboard that lets you run your custom shell commands on any Linux machine — directly from your phone, browser, or Amazfit smartwatch. No SSH. No terminal. Just tap.

CI License: MIT Ko-fi Python FastAPI Zepp OS Linux


📱 Dashboard ⚙️ Command Management

🤔 Why Lucius?

You have a Raspberry Pi, a home server, or a VPS. You need to restart a service, check memory, or run a script. Currently you:

  1. Open a terminal
  2. SSH into the machine
  3. Type the command

With Lucius, you open your phone, tap a button, done. It's designed to be the simplest possible tool for this job — nothing more, nothing less.

Not a replacement for Cockpit or Webmin. Those are powerful full-panel tools. Lucius is for the 20% of tasks you do 80% of the time, with a UI that feels native on mobile.


✨ Features

  • 📱 Mobile-First & High Accessibility — huge thumb-friendly action cards with automatic icons and color themes for instant visual recognition
  • 📲 PWA Ready — installable directly on your phone's home screen as a native-like app (no browser bars) with static-asset caching
  • ⚡ Real-time execution (WebSockets) — stream command output line-by-line as it happens, with a 50 KB bounded memory buffer and automatic non-JS fallback (POST /run)
  • 📖 Execution History & Logs — dedicated /logs page keeping the last 50 executions (Web UI, WebSocket, and REST API) in a chmod 600 local history.json
  • 🛡️ Secure by design — mandatory PIN / dedicated API token auth, brute-force lockout, CSRF & WebSocket origin validation, and strict shell=False command whitelist
  • ⚠️ Safety controls — per-command confirmation prompt (on both web and smartwatch) and enable/disable toggle
  • 🔌 Lightweight REST API — two minimal JSON endpoints (GET /api/commands, POST /api/run/{command}) for external triggers, webhooks, Home Assistant, Shortcuts, and scripts
  • ⌚ Optional Smartwatch Companion (zepp-app/) — native Zepp OS 4.x app for Amazfit watches (Square & Round, tested on Amazfit Bip 6) to launch commands right from your wrist over LAN HTTP/HTTPS, with zero extra dependencies on the server
  • ⚙️ Web-based management — add, edit, enable/disable, delete, and reorder commands from /manage, with syntax validation before saving
  • ↕️ Custom command ordering — reorder commands via drag-and-drop or Up/Down arrows (order automatically syncs to both dashboard and REST API / watch)
  • 🖥️ Custom server name — label each machine so you always know what you're controlling
  • 🎨 Dark / Light mode — toggle manually from the Manage page or let it follow your system preference
  • 🌍 Universal Linux support — Ubuntu, Debian, Raspberry Pi OS, Fedora, Arch, and any systemd-based distro
  • 🔄 One-command safe updates — built-in update.sh backs up and restores your configuration and permissions automatically

🚀 Installation

Run this single command on your Linux machine:

curl -sSL https://raw.githubusercontent.com/ar3ac/lucius/main/install.sh | sudo bash

The script will automatically:

  1. Install Python, python3-venv, git, and curl (apt, dnf, or pacman)
  2. Clone Lucius into /opt/lucius and initialize default commands from commands.example.json
  3. Set up .venv and install Python dependencies from requirements.txt
  4. Prompt you for a non-empty access PIN and save it to /opt/lucius/.env with 600 permissions
  5. Register and start lucius.service via systemd (runs on boot on port 8000)

Then open http://<your-server-ip>:8000 from any device on your network.

Tip: Run the installer using sudo from a regular user account (rather than directly as root) so the lucius.service process runs under that unprivileged user.


⚙️ Configuration (.env)

Lucius loads its configuration from .env in the installation directory (/opt/lucius/.env). See .env.example for a ready-to-copy template.

Variable Required Default Description
LUCIUS_PIN Yes — PIN or password required to sign in to the web UI. Lucius refuses to start if unset or empty. Also acts as fallback for REST API auth when LUCIUS_API_TOKEN is unset.
LUCIUS_API_TOKEN No (falls back to LUCIUS_PIN) Dedicated secret token for REST API clients (GET /api/commands, POST /api/run/{command}). When set, API endpoints accept only this token (and no longer accept LUCIUS_PIN).
LUCIUS_ENABLE_DOCS No false Set to true to enable FastAPI Swagger UI (/docs), ReDoc (/redoc), and /openapi.json. Keep false outside local development.

After modifying /opt/lucius/.env, always verify permissions and restart the service:

sudo chmod 600 /opt/lucius/.env
sudo systemctl restart lucius

📲 How to Install on your Phone (PWA)

Since Lucius is often used on local networks without HTTPS, browsers might hide the automatic "Install App" prompt. Here is how you can still add it to your home screen with the custom logo:

🍏 iOS (iPhone / iPad)

  1. Open Safari and navigate to your Lucius dashboard (e.g., http://192.168.1.100:8000).
  2. Tap the Share button (the square with an upward arrow at the bottom).
  3. Scroll down and tap "Add to Home Screen".
  4. Tap Add. Lucius will now behave like a native app!

🤖 Android (Chrome)

  1. Open Chrome and navigate to your Lucius dashboard.
  2. Tap the 3-dot menu in the top right corner.
  3. Select "Add to Home screen".
  4. (Optional for Power Users): To unlock the native install banner over LAN HTTP, open chrome://flags, search for "Insecure origins treated as secure", enable it, add your server's URL, and relaunch Chrome.

💡 Use Cases

What you want to do Example command
Reboot the server sudo reboot
Restart a service sudo systemctl restart nginx
Check available memory free -h
See system uptime uptime -p
Pull latest code bash -c 'cd /var/www/myapp && git pull'
Clear system cache bash -c 'sudo sync && sudo sysctl -w vm.drop_caches=3'
Suspend remote machine ssh user@desktop systemctl suspend

Note on shell operators (&&, |, ;, cd): Because Lucius executes commands with shell=False (shlex.split) to prevent shell injection, compound commands or shell built-ins like cd must be wrapped explicitly in bash -c '...' (as shown above). Command names can contain letters, numbers, and underscores (a-z, A-Z, 0-9, _).


🔌 Lightweight REST API (Zepp OS & External Integrations)

To keep Lucius simple while enabling headless clients — starting with the Zepp OS smartwatch companion app, as well as webhooks, Home Assistant, Apple Shortcuts, or custom scripts — Lucius exposes two minimal JSON endpoints alongside the web UI:

  • GET /api/commands — returns server_name and the ordered list of enabled whitelisted commands (name, confirm only — raw shell commands are never exposed by the API).
  • POST /api/run/{command} — executes an enabled whitelisted command (shell=False, 60s timeout), records it in /logs, and returns { "ok", "command", "exit_code", "output" } (last 2,000 characters of combined stdout/stderr).

Creating a Dedicated API Token

By default, the REST API accepts your LUCIUS_PIN so you can test right away. For regular use with smartwatches, Home Assistant, or scripts, creating a dedicated LUCIUS_API_TOKEN is strongly recommended so you can rotate API credentials without changing your web PIN:

  1. Generate a strong random token on your server:
    openssl rand -hex 32
    # or, using Python:
    python3 -c "import secrets; print(secrets.token_urlsafe(32))"
    
  2. Add it to /opt/lucius/.env:
    nano /opt/lucius/.env
    
    Your .env file should look like:
    LUCIUS_PIN="your-web-pin"
    LUCIUS_API_TOKEN="paste-your-generated-token-here"
    
  3. Lock down permissions and restart Lucius:
    sudo chmod 600 /opt/lucius/.env
    sudo systemctl restart lucius
    

Once LUCIUS_API_TOKEN is defined in .env, the REST API accepts only LUCIUS_API_TOKEN (and no longer accepts LUCIUS_PIN as an API token). LUCIUS_PIN continues to protect the web dashboard login.

Usage Examples

Pass your token using either Authorization: Bearer <token> or X-Lucius-Token: <token>:

# List enabled commands
curl -H "Authorization: Bearer YOUR_API_TOKEN" \
  http://<your-server-ip>:8000/api/commands

Example response (200 OK):

{
  "server_name": "Raspberry Pi 4",
  "commands": [
    { "name": "uptime", "confirm": false },
    { "name": "reboot", "confirm": true }
  ]
}
# Trigger a whitelisted command
curl -X POST -H "Authorization: Bearer YOUR_API_TOKEN" \
  http://<your-server-ip>:8000/api/run/uptime

Example response (200 OK):

{
  "ok": true,
  "command": "uptime",
  "exit_code": 0,
  "output": "up 3 days, 4 hours, 12 minutes"
}

API Status Codes

Status Meaning
200 Request succeeded (for /api/run, check "ok" and "exit_code" for command exit status)
401 Missing or invalid token
403 Command is disabled (or cross-origin cookie request blocked)
404 Command not found in whitelist
429 Brute-force lockout active (5 failed attempts → wait 60 seconds)
500 Executable not found or internal execution error
504 Command timed out after 60 seconds

⌚ Watch Companion (Zepp OS 4.x — Optional)

Want to trigger your server commands without even pulling out your phone?

Lucius ships with an optional, 100% isolated Zepp OS 4.x companion app inside zepp-app/ — zero Node/JS dependencies are ever installed on your Linux server.

  • Adaptive UI for both Square (e.g. Amazfit Bip 6, Active) and Round (e.g. Amazfit Balance, T-Rex 3, Active 2) Zepp OS 4.x watches
  • Dynamic command sync + local cache: automatically reflects the exact enabled commands and custom order from your Lucius dashboard
  • Native confirmation modal: commands flagged with confirm: true ask for confirmation on the wrist before running
  • Compact output & haptic feedback: vibrates when finished and displays exit code + output tail
  • LAN HTTP/HTTPS ready & i18n (en-US / it-IT)

👉 See zepp-app/README.md for the 2-minute sideload guide via Zepp Developer Mode.


🔄 Updating

sudo /opt/lucius/update.sh

Automatically stops the service, backs up commands.json and settings.json, pulls the latest main, updates Python dependencies, restores your config and file permissions (chmod 600 on .env and history.json), and restarts lucius.service.

🗑️ Uninstalling

sudo /opt/lucius/uninstall.sh

Cleanly removes the systemd service, /opt/lucius, and all traces. Zero leftovers.


🔒 Security

Lucius is designed for trusted LAN use (or access over a VPN like Tailscale/WireGuard). It is not recommended to expose it directly to the public internet over plain HTTP.

  • PIN & API Token authentication: Protected by a mandatory LUCIUS_PIN (and optional LUCIUS_API_TOKEN) stored in .env with 600 file permissions, verified in constant time (hmac.compare_digest), with automatic 60-second per-IP brute-force lockout after 5 failed attempts (trusting X-Forwarded-For / X-Real-IP only from a local reverse proxy on 127.0.0.1 / ::1)
  • Hardened web sessions & CSRF/WebSocket protection: Per-device random HttpOnly, SameSite=Lax cookies (with Secure enabled automatically over HTTPS / X-Forwarded-Proto: https), server-side session revocation on POST /logout, Origin validation on state-changing requests and WebSocket handshakes, and HTTP security headers (X-Frame-Options: DENY, X-Content-Type-Options: nosniff, Referrer-Policy: no-referrer)
  • Strict command whitelist: The backend executes only enabled commands explicitly saved in commands.json using shell=False — arbitrary shell injection is impossible by design
  • Minimal attack surface: FastAPI /docs, /redoc, and /openapi.json are disabled by default, raw shell commands are never returned by /api/commands, and the PWA Service Worker caches only static assets (never authenticated pages, logs, or API responses)
  • Directory Permissions: Lucius needs write access to its folder to save commands.json, settings.json, and history.json. If you install manually, ensure the service user owns /opt/lucius (sudo chown -R $USER:$USER /opt/lucius) and keep .env readable only by that user (chmod 600 /opt/lucius/.env).

Using sudo commands? Add a NOPASSWD rule in /etc/sudoers (via sudo visudo) for the specific commands you need, otherwise Lucius will timeout waiting for a password prompt:

your_user ALL=(ALL) NOPASSWD: /bin/systemctl restart nginx

Want HTTPS? Put Lucius behind a reverse proxy like Caddy or Nginx with a Let's Encrypt certificate. Lucius automatically enables Secure cookies when X-Forwarded-Proto: https is present:

Caddy example (recommended — automatic HTTPS + WebSockets)
lucius.yourdomain.com {
    reverse_proxy 127.0.0.1:8000
}
Nginx example (with WebSocket upgrade for live logs)
server {
    listen 443 ssl http2;
    server_name lucius.yourdomain.com;

    # ssl_certificate / ssl_certificate_key managed by Certbot

    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

Found a security vulnerability? Please report it privately via SECURITY.md.


📁 Project Structure

lucius/
├── main.py                 # FastAPI backend — auth, routing, WebSockets & REST API
├── templates/              # Jinja2 HTML templates
│   ├── base.html
│   ├── index.html          # Dashboard
│   ├── logs.html           # Execution history
│   ├── manage.html         # Command management UI
│   └── login.html
├── static/
│   ├── style.css           # Full design system (light + dark mode)
│   ├── manifest.json       # PWA manifest
│   └── sw.js               # Static-assets Service Worker
├── tests/
│   └── test_app.py         # Security, auth, WebSocket & REST API test suite
├── zepp-app/               # Optional Zepp OS 4.x smartwatch companion (Square & Round)
├── .env.example            # Example environment configuration
├── commands.example.json   # Starter commands copied on first install
├── lucius.service          # systemd service template
├── install.sh              # Universal installer
├── update.sh               # Safe updater (preserves your config & permissions)
├── uninstall.sh            # Clean uninstaller
├── requirements.txt        # Minimal Python dependencies
└── SECURITY.md             # Vulnerability reporting policy

☕ Support

If you find Lucius useful and want to support its development, feel free to buy me a coffee!

Support on Ko-fi


🤝 Contributing

Pull requests are welcome! See CONTRIBUTING.md for development setup instructions, and please open an issue first for major changes.


📄 License

Distributed under the MIT License. See LICENSE for more information.


🙏 Credits & Acknowledgments

Lucius is built on the shoulders of these fantastic open-source projects:


Made with ☕ and Python by Luca Marrazzo (@ar3ac)

Explorer des projets similaires

Chargement…