SiYuan Note - Homelab Operator Runbook

Homelab Deployment Info

  • Public Web UI: https://yuan.loca.zone
  • Local Proxy Target: 127.0.0.1:8400
  • Access Auth Code: less1234 (Stored in /home/loca/yuan/creds.md)
  • API Authentication: Must include header Authorization: Token less1234

Docker Deployment (Homelab Configuration)

Run the container using the following configuration to bind the local port and configure the homelab credentials:

docker run -d \
  -v /home/loca/yuan/workspace:/siyuan/workspace \
  -p 8400:6806 \
  -e PUID=1000 -e PGID=1000 \
  b3log/siyuan \
  serve \
  --workspace=/siyuan/workspace/ \
  --accessAuthCode=less1234

Docker Compose Configuration

version: "3.9"
services:
  siyuan:
    image: b3log/siyuan
    command: ['serve', '--workspace=/siyuan/workspace/', '--accessAuthCode=less1234']
    ports:
      - 8400:6806
    volumes:
      - /home/loca/yuan/workspace:/siyuan/workspace
    restart: unless-stopped
    environment:
      - TZ=America/New_York
      - PUID=1000
      - PGID=1000

Note: Ensure host permissions are configured correctly via chown -R 1000:1000 /home/loca/yuan/workspace before startup.


API Reference Quickstart

All API requests must target https://yuan.loca.zone or local http://127.0.0.1:8400 and pass the auth token.

Authentication Header

Authorization: Token less1234

Common API Operations

1. SQL Query

  • Endpoint: POST /api/query/sql
  • Headers: Authorization: Token less1234
  • Payload:
    {
      "stmt": "SELECT * FROM blocks WHERE content LIKE '%homelab%' LIMIT 10"
    }

2. Get Block Content

  • Endpoint: POST /api/block/getBlockKramdown
  • Headers: Authorization: Token less1234
  • Payload:
    {
      "id": "block-id-here"
    }

3. Create Document

  • Endpoint: POST /api/filetree/createDocWithMd
  • Headers: Authorization: Token less1234
  • Payload:
    {
      "notebook": "notebook-id",
      "path": "/homelab-runbook",
      "markdown": "# Homelab Runbook\nContent goes here."
    }

Command-line Interface

Execute commands directly inside the kernel binary on the host machine.

Quick Commands

# List all notebooks
siyuan notebook list -w /home/loca/yuan/workspace
 
# Full-text search with JSON output
siyuan search "homelab" -w /home/loca/yuan/workspace -f json
 
# Export a document as Markdown
siyuan export md --id <block-id> -w /home/loca/yuan/workspace

Data Structure & Storage

Data is persisted in the local workspace directory (/home/loca/yuan/workspace):

  • assets/: Inserted files and attachments.
  • templates/: Snippets used for quick document creation.
  • plugins/: Installed custom add-ons.
  • data/: Notebook directories containing .sy JSON files mapping to document nodes.

Note: Do not sync the workspace directory using active file-system synchronization software (like Syncthing or Dropbox) while the kernel is running, as this risks database corruption.