Skip to content
JerryBianPublic

About

Run script in background via Web.

Resources

Stars

5 stars

Watchers

1 watching

Forks

Repository files navigation

Pika

master

A self-contained control deck for shell scripts, long-running apps, and the host underneath them.

Pika is a single ASP.NET Core application with a SQLite store and a mobile-first, terminal-inspired UI. It runs commands in the background, manages app lifecycle hooks, and streams live Linux host telemetry into the browser. No agents, no external database, no cloud.

Pika overview

Features

  • Background script runner — save reusable scripts or fire one-off temp scripts. Commands are queued to background workers, and stdout/stderr are batched into short SQLite transactions and pushed live over SignalR (no polling). The console supports raw output, wrapping, auto-scroll, copy, and a 1000-line buffer.
  • App units — register long-running services with init, start, stop, and state hooks, either inline or from a script path. Inspect state, start/stop a unit, and open its URL.
  • Live host telemetry — on Linux, a read-only /proc + /sys collector serves CPU, memory, network, disk, load, and temperature with an auto-refresh selector (Off / 3s / 5s / 10s / 30s / 60s) remembered per browser. A compact snapshot is written to SQLite every 5 minutes; every card has a 30-day history chart, and samples older than 60 days are removed automatically.
  • Operator console — desktop sidebar, mobile bottom dock, command palette (Ctrl/Cmd+K), live clock, script filtering, copy buttons, syntax highlighting, and a dark neon theme.
  • Single binary — SQLite + Dapper, cookie authentication, and no external runtime services on the server.
  • Mobile first — every page is designed at phone width first, with 320px through desktop layouts verified.
  • Bilingual UI — a 中文 / EN switch in the header and on the login screen. The first visit follows the browser's Accept-Language; the choice is remembered in a one-year HttpOnly cookie. Navigation, forms, status text, validation, charts, and JavaScript dialogs are localized while technical identifiers such as CPU, SQLite, SignalR, and shell commands stay readable.

Screenshots

Apps

Apps

Scripts

Scripts

Run history

Run history

Run output

Run output

Host status

Live telemetry is available on Linux. The page fetches the latest host snapshot immediately and then on the selected interval; the choice is stored in this browser. Use Off to pause and the refresh button for a one-shot update. History buttons on the CPU, memory, load, temperature, network, and disk cards open a 30-day chart backed by the persisted 5-minute samples. On other operating systems the page explains what is missing while the rest of Pika keeps working.

Host status

Every CPU, memory, load, temperature, network, and disk card exposes a HISTORY popup. It charts the last 30 days from the persisted 5-minute samples, with min/avg/max/latest summaries:

Metric history

Settings

Settings

Sign in

Sign in

Language

Pika ships with English and Simplified Chinese. On the first request it reads the browser's Accept-Language header (zh-* selects Chinese, everything else falls back to English). The compact 中文 / EN switch writes a one-year pika.lang cookie, so the choice survives reloads and logout; it works on the login screen as well because the language endpoints are anonymous.

Translations live in src/Resources/i18n/zh-Hans.json and are keyed by the English UI copy. Missing entries intentionally fall back to English, which keeps technical labels and future copy from turning into placeholder keys. Server-rendered text uses I18n.T(...); browser messages use t(...) / tFormat(...) with the small window.pikaI18n catalogue.

Chinese interface

Quick start

Download a release

Grab the binary for your platform from the release page and extract it.

Linux:

export DbLocation=/var/lib/pika
export ASPNETCORE_URLS=http://127.0.0.1:8080
export AdminUserName=operator
export AdminPassword='change-me'
./pika

Windows:

$env:DbLocation="C:\pika-data"
$env:ASPNETCORE_URLS="http://127.0.0.1:8080"
$env:AdminUserName="operator"
$env:AdminPassword="change-me"
.\pika.exe

Then open http://127.0.0.1:8080.

The built-in credentials are test / testtest when AdminUserName and AdminPassword are not set. Change them before exposing the app.

From source

Requires the .NET 10 SDK.

dotnet restore src/Pika.csproj
dotnet build src/Pika.csproj -c Release
DbLocation=/path/to/data ASPNETCORE_URLS=http://127.0.0.1:5000 \
  dotnet run --project src/Pika.csproj --no-launch-profile

The checked-in launch profile uses DbLocation=C:\temp and listens on port 5000. Use --no-launch-profile when you want to supply your own database path and URL.

Configuration

DbLocation is the only required setting. Pika creates the directory and pika.db on first start.

Setting Required Default Notes
DbLocation Yes — Directory containing the SQLite database.
AdminUserName No test Login user name.
AdminPassword No testtest Login password. Change it.
ASPNETCORE_URLS No Kestrel default Bind address, for example http://0.0.0.0:8080.
ASPNETCORE_ENVIRONMENT No Production Development enables developer error pages.
ForceRecreateDb No false Deletes the existing database on startup. Use with care.
Monitor:IntervalMs No 1000 Live metric sampling interval, clamped to 500–10000 ms.
Monitor:DiskIntervalMs No 5000 Disk inventory refresh interval, clamped to 1000–60000 ms.
Monitor:HistoryIntervalMinutes No 5 Persisted history sample interval, clamped to 1–1440 minutes.
Monitor:HistoryRetentionDays No 60 History retention window, clamped to 1–3650 days.
Monitor:HistoryCleanupHours No 6 Expired-history cleanup interval, clamped to 1–168 hours.

Use double underscores for nested settings in environment variables, for example Monitor__IntervalMs=2000.

Default shell settings and database retention are managed from the Settings page.

Run as a systemd service

[Unit]
Description=Pika control deck
After=network.target

[Service]
User=pika
Group=pika
WorkingDirectory=/opt/pika
Environment="DbLocation=/var/lib/pika"
Environment="ASPNETCORE_URLS=http://127.0.0.1:8080"
Environment="AdminUserName=operator"
Environment="AdminPassword=change-me"
ExecStart=/opt/pika/pika
Restart=on-failure
RestartSec=5s

[Install]
WantedBy=multi-user.target

Run Pika as a dedicated user and keep the data directory writable by that user. For a public deployment, put it behind a TLS-terminating reverse proxy.

Development

Build the app:

dotnet build src/Pika.csproj -c Release

There is no test project. CI restores and builds on Windows, macOS, and Linux.

Front-end sources:

  • src/wwwroot/src/style.scss — Bootstrap overrides and the Pika design system.
  • src/wwwroot/src/script.js — shared shell behavior (modals, command palette, copy, forms).
  • src/wwwroot/dist/style.css, src/wwwroot/style.min.css, src/wwwroot/script.min.js — committed build outputs.

Regenerate the front-end assets with:

npm install
npm run build

The asset pipeline requires Node.js/npm and PowerShell 7 (pwsh). npm run build wraps build.ps1, which also checks and upgrades npm dependencies (ncu -u). Review and revert any version bumps you did not intend before committing.

Project layout

Path Purpose
src/Program.cs DI composition, authentication, hosted services, hubs, static files.
src/Controllers/ One MVC controller per page area; ApiController is the JSON mutation surface.
src/Common/Command/ In-process background command queue and output batching.
src/Common/Monitor/ Linux /proc + /sys collector, in-memory sampler, history service, metric catalog, and DTOs.
src/Common/Store/ SQLite schema, Dapper queries, and settings.
src/Views/ Razor pages and the shared shell.
src/wwwroot/ Compiled CSS/JS, fonts, icons, and image assets.

Security

Pika is designed as a single-operator control panel for a trusted machine.

  • Change the default credentials.
  • Bind to 127.0.0.1 or put the app behind a reverse proxy with TLS.
  • Do not expose the app directly to an untrusted network.
  • The cookie is HttpOnly, SameSite=Lax, and valid for 30 days; there is no multi-user role model.
  • Unsafe requests are checked against the browser's origin and fetch metadata, and hub handshakes reject cross-origin callers.
  • If Pika runs behind a reverse proxy, preserve the original Host header (for example, proxy_set_header Host $host;) so origin checks and generated links see the public host.

License

GPLv3

About

Run script in background via Web.

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages