diff --git a/Justfile b/Justfile index 70e856b4..6d8227a0 100644 --- a/Justfile +++ b/Justfile @@ -13,3 +13,18 @@ bundle: # Build only the Navidrome sidecar binary. sidecar: ./desktop/scripts/build.sh --skip-tauri + +# Remove Navidrome's persistent state (database, cache, backups) for a clean +# first-run. Your music files are NOT touched. Quit the app first. +clean-state: + #!/usr/bin/env bash + set -euo pipefail + case "$(uname -s)" in + Darwin) dir="$HOME/Library/Application Support/com.quintodrome.desktop" ;; + Linux) dir="${XDG_DATA_HOME:-$HOME/.local/share}/com.quintodrome.desktop" ;; + MINGW*|MSYS*|CYGWIN*) dir="${APPDATA:-$HOME/AppData/Roaming}/com.quintodrome.desktop" ;; + *) echo "unsupported OS" >&2; exit 1 ;; + esac + echo "Removing: $dir" + rm -rf "$dir" + echo "Done. Next launch starts fresh (first-run setup)." diff --git a/desktop/README.md b/desktop/README.md index 49613f60..0d3f7ca5 100644 --- a/desktop/README.md +++ b/desktop/README.md @@ -15,6 +15,11 @@ On launch the app: 4. On exit, sends `SIGTERM` to the spawned server so it shuts down gracefully (falls back to a hard kill after 3s). +On a **fresh install** (no existing Navidrome data) the app also auto-creates +the initial admin user (`admin` / `admin`) behind the scenes, so you skip +Navidrome's "create an admin user" first-run screen. Change the password in +Navidrome settings afterwards; override it via `QUINTODROME_ADMIN_PASSWORD`. + ## How to launch From the repo root: @@ -105,6 +110,7 @@ Environment variables override the defaults: | `QUINTODROME_HOST` | `127.0.0.1` | Address the webview connects to | | `QUINTODROME_PORT` | `4533` | Port for the Navidrome server | | `QUINTODROME_MUSIC_FOLDER` | OS music dir (e.g. `~/Music`) | Where your music lives | +| `QUINTODROME_ADMIN_PASSWORD` | `admin` | Password for the auto-created admin user (fresh installs only) | | `QUINTODROME_PUBLIC_URL` | `http://quintodrome` | Friendly origin shown in the address bar | The data folder (DB, cache) is always the OS app-data directory diff --git a/desktop/src-tauri/src/server.rs b/desktop/src-tauri/src/server.rs index 93ae8241..bdbf8646 100644 --- a/desktop/src-tauri/src/server.rs +++ b/desktop/src-tauri/src/server.rs @@ -104,9 +104,19 @@ fn spawn(handle: &AppHandle, navidrome: &Navidrome) -> Result<(), ServerError> { music_folder, ]; + // Auto-provision the first admin user on a fresh install. Navidrome only + // honors this during initial setup (when no users/data exist), so an + // existing installation is left untouched. + let admin_password = + std::env::var("QUINTODROME_ADMIN_PASSWORD").unwrap_or_else(|_| "admin".to_string()); + let (mut rx, child) = handle .shell() .sidecar("navidrome")? + .env( + "ND_DEVAUTOCREATEADMINPASSWORD", + admin_password.as_str(), + ) .args(args) .spawn()?;