From 96055e6375c0855d66792bf05f6674c70d3aef62 Mon Sep 17 00:00:00 2001 From: marc Date: Fri, 19 Jun 2026 23:11:41 +0200 Subject: [PATCH] Codebase cleanup: remove dead code, fix docker, update docs app.py: - Remove 'raw' field from export dict entries (only comment/blank kinds need raw; export entries are always reconstructed from path/rest/enabled when writing back) - Remove extra blank line shares.js: - Remove unused pathJson variable in SMB row (was only needed for the quota button, which was removed) docker-compose.yml: - Deleted entirely: was missing templates/ and static/ mounts so the Flask app couldn't serve pages; SYS_ADMIN cap_add was only needed for quotas; deployment is systemd, not Docker README.md: - Remove quota package from apt install command - Remove quota setup section (feature removed) - Remove docker-compose from Dev section CLAUDE.md / PLANNING.md: - Remove docker-compose.yml references and quotas.js from file tree .gitignore: - Remove redundant micronas.env entry (already covered by *.env) Co-Authored-By: Claude Sonnet 4.6 --- .gitignore | 1 - CLAUDE.md | 1 - PLANNING.md | 4 +--- README.md | 49 ++++----------------------------------------- app.py | 7 ++----- docker-compose.yml | 17 ---------------- static/js/shares.js | 1 - 7 files changed, 7 insertions(+), 73 deletions(-) delete mode 100644 docker-compose.yml diff --git a/.gitignore b/.gitignore index 90ca79e..d6e30a7 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,4 @@ __pycache__/ venv/ .venv/ *.env -micronas.env .DS_Store diff --git a/CLAUDE.md b/CLAUDE.md index c59e08d..fcdceff 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -20,7 +20,6 @@ daemons. Home/LAN use only. - `static/js/users.js` — user CRUD + password modal. - `static/js/main.js` — page init and 30 s auto-refresh. - `micronas.service` — systemd unit (gunicorn, reads `/etc/micronas.env`). -- `docker-compose.yml` — dev/test sandbox only, not for production. ## How it runs Directly on the LXC/VM as a `systemd` service, Flask behind `gunicorn`. diff --git a/PLANNING.md b/PLANNING.md index 6b8ba05..40f43de 100644 --- a/PLANNING.md +++ b/PLANNING.md @@ -44,11 +44,9 @@ MicroNAS/ │ ├── utils.js esc(), showToast(), apiFetch() │ ├── dashboard.js loadDashboard() │ ├── shares.js SMB/NFS CRUD + edit/delete/toggle -│ ├── quotas.js Quota modal │ ├── users.js User CRUD + password modal -│ └── main.js Init + auto-refresh +│ └── main.js Init + auto-refresh countdown ├── micronas.service systemd unit -├── docker-compose.yml Dev/test sandbox only ├── README.md └── PLANNING.md ``` diff --git a/README.md b/README.md index 2aa60e1..1b621d2 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Run everything below **inside the LXC container** as root. ```bash apt update -apt install -y git samba nfs-kernel-server quota python3 python3-venv +apt install -y git samba nfs-kernel-server python3 python3-venv ``` ### 2. Clone the repo @@ -59,46 +59,6 @@ Open `http://:5000` in your browser. --- -## Quota setup (one-time, per filesystem) - -Quotas are a **filesystem feature** — they must be enabled on the partition that holds your shares (usually `/srv`) before MicroNAS can set them. - -### Step 1 — Enable quota mount options - -Edit `/etc/fstab`. Find the line for the partition that contains `/srv` and add `usrquota`: - -``` -# Example — your device path and options may differ -/dev/sdb1 /srv ext4 defaults,usrquota 0 2 -``` - -Remount to apply without rebooting: - -```bash -mount -o remount /srv -``` - -### Step 2 — Initialise quota database - -```bash -quotacheck -ugm /srv -quotaon /srv -``` - -This creates `/srv/aquota.user`. You only need to run this once; `quotaon` is automatically called on boot via the quota init script. - -### Step 3 — Verify - -```bash -repquota -u /srv -``` - -If it prints a header and user list (even if empty), quotas are active. MicroNAS reads this output for the dashboard. - -> **Note:** if `/srv` is not a separate partition (e.g. it lives on the root `/` filesystem), add `usrquota` to the `/` entry in fstab instead and run `quotacheck`/`quotaon` on `/`. The Quota button in MicroNAS detects the correct filesystem automatically via `df`. - ---- - ## Updates ```bash @@ -118,13 +78,12 @@ LAN or Tailscale only — never expose to the internet. ## Dev / test ```bash -# Quick local run (no gunicorn needed): +# Quick local run (no gunicorn needed, must have flask installed): MICRONAS_USER=admin MICRONAS_PASS=secret flask --app app.py run --debug --host=0.0.0.0 - -# Or with docker-compose (UI only — systemctl/samba calls won't work): -docker compose up ``` +Note: SMB/NFS/user management calls require root and the relevant daemons — run on the actual LXC for full testing. + ## Auth All routes require a login session. Go to `http://:5000` — you will be redirected to the login page automatically. Credentials come from `MICRONAS_USER` / `MICRONAS_PASS` in `/etc/micronas.env`. If `MICRONAS_PASS` is not set the app starts unprotected and logs a warning — do not do this in production. diff --git a/app.py b/app.py index 2f3b2da..9cc6d04 100644 --- a/app.py +++ b/app.py @@ -157,15 +157,13 @@ def _parse_exports(): if inner.startswith('/'): parts = inner.split(None, 1) entries.append({'kind': 'export', 'enabled': False, - 'path': parts[0], 'rest': parts[1] if len(parts) > 1 else '', - 'raw': raw}) + 'path': parts[0], 'rest': parts[1] if len(parts) > 1 else ''}) else: entries.append({'kind': 'comment', 'raw': raw}) continue parts = stripped.split(None, 1) entries.append({'kind': 'export', 'enabled': True, - 'path': parts[0], 'rest': parts[1] if len(parts) > 1 else '', - 'raw': raw}) + 'path': parts[0], 'rest': parts[1] if len(parts) > 1 else ''}) except FileNotFoundError: pass return entries @@ -562,7 +560,6 @@ def _shares_with_usage(): - @app.route('/api/dashboard', methods=['GET']) @require_auth def get_dashboard(): diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 711637d..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,17 +0,0 @@ -version: '3' -services: - share-manager: - image: python:3.11-slim - volumes: - - ./app.py:/app/app.py - - /etc/samba:/etc/samba - - /etc/exports:/etc/exports - - /srv:/srv - ports: - - "5000:5000" - working_dir: /app - command: > - sh -c "pip install flask && - python app.py" - cap_add: - - SYS_ADMIN \ No newline at end of file diff --git a/static/js/shares.js b/static/js/shares.js index f373ecd..0eed50c 100644 --- a/static/js/shares.js +++ b/static/js/shares.js @@ -13,7 +13,6 @@ async function loadShares() { // esc() HTML-encodes JSON so " inside onclick="..." doesn't break the attribute const shareJson = esc(JSON.stringify(s)); const nameJson = esc(JSON.stringify(s.name)); - const pathJson = esc(JSON.stringify(s.path)); return ` ${esc(s.name)} ${esc(s.path)}