Skip to main content

Package: drumee-schemas

Directory: schemas/ Debian package: drumee-schemas Current version: 2.7.2 Helper source: git@github.com:drumee/setup-schemas/var/lib/drumee/setup-schemas/

Purpose

Bootstraps the Drumee database layer. The post-install script (bin/install) restores a MariaDB snapshot from seeds, creates system accounts (nobody, guest, system, admin), provisions the initial hubs and media filesystem, generates the RSA key pair, and sends a welcome email with the admin password-reset link.

Flow at a glance

setup-schemas is the stateful half of provisioning (its counterpart, setup-infra, generates config files). A thin bash orchestrator (bin/install) does the physical DB restore, then hands off to a Node domain layer (populate.js + lib/) that stands up the first organization:

bin/install (bash, root)
└─ mariabackup --copy-back (restore seeds.tgz → live datadir)
└─ node populate.js (Node)
├─ lib/organization.js → sys_conf/domain/vhost/organisation/settings + nobody/guest/system/admin
├─ lib/drumate.js → create users & hubs (drumate_create / desk_create_hub procs)
├─ lib/mfs.js → import wallpapers + tutorials over HTTP (calls currently disabled)
└─ lib/schema.js → low-level entity (hub/drumate DB) provisioner (entity_create + template SQL)
└─ bin/acknowledge.js (welcome email) + apply pending patches

Domain layer (lib/)

ModuleResponsibility
organization.jspopulate() seeds the yp system rows; createNobody/Guest/SystemUser/Admin() build the fixed accounts; remove() tears an org down.
drumate.jscreate() a user (via the drumate_create proc) and createHub() (via desk_create_hub). updateEntries() remaps a freshly-created entity's id to a pre-allocated uid across six tables (entity, drumate, hub, vhost, privilege, disk_usage) and moves its home_dir — the trickiest step.
mfs.jsImports remote content (importContent/importFile/importTutorial) into MFS by downloading over HTTP, then mfs_create_node + copy into __storage__/.
schema.jsLow-level entity provisioner: entity_create → load per-type template SQL → create the MFS/media root, with rollback on failure (the pool/factory path).

Source Repos

RepoBranchDestination
setup-schemasmain/var/lib/drumee/setup-schemas/
schemaspreview/var/lib/drumee/schemas/

Build Prerequisites

Seeds archive required. The build looks for a seeds archive in this order:

  1. schemas/var/tmp/drumee/seeds.tgz — pre-existing archive in the repo
  2. $SEEDS_DIR/ directory (default: $HOME/docker/data/seeds/) — packed from a live MariaDB instance

If neither exists, the build exits. Seeds are a mariabackup snapshot of the base Drumee database needed to bootstrap a fresh instance.

schemas/seeds/ is gitignored — it contains large MariaDB binary files (aria_log, ibdata1) unsuitable for version control.

Creating seeds.tgz from a live instance

SEEDS_DIR=/path/to/mariabackup/snapshot schemas/build.sh

schemas/Dockerfile

Provides a containerised build environment for producing seeds without a local MariaDB installation. Uses mariabackup to snapshot and prepare the database.

Build

schemas/build.sh

schemas/build.sh takes no flags — version and email come from schemas/debian/changelog. Set SEEDS_DIR to point at the mariabackup snapshot used to create the seeds archive (see Build Prerequisites). Invoking the script with rebuild in its path forces the existing seeds.tgz to be regenerated.

Installed Paths

/var/lib/drumee/
├── setup-schemas/ # bin/install, populate.js, lib/ (domain layer), asset/welcome.html
└── schemas/ # schema source (preview branch)
/var/tmp/drumee/
└── seeds.tgz # mariabackup snapshot archive

Dependencies

binutils, nodejs, mariadb-server, mariadb-client

Post-Install: bin/install

Runs as root. Two-phase execution:

Phase 1 — Database restore (bash)

  1. Sources /etc/drumee/drumee.sh for environment variables.
  2. Stops MariaDB.
  3. Manages the DB directory ($DRUMEE_DB_DIR, default /srv/db):
    • Archives any existing run/ to orig/<date>/ (rollback point).
    • Creates a fresh run/ directory.
  4. Extracts seeds from /var/tmp/drumee/seeds.tgz.
  5. Restores via mariabackup --copy-back into $DRUMEE_DB_DIR/run/.
  6. Sets ownership (mysql:mysql) and permissions (750 dirs, rw files).
  7. Starts MariaDB.
  8. Creates the system Unix-socket user:
    CREATE OR REPLACE USER '$DRUMEE_SYSTEM_USER'@'localhost' IDENTIFIED VIA unix_socket;
    GRANT ALL PRIVILEGES ON *.* TO '$DRUMEE_SYSTEM_USER'@'localhost';
  9. Sets global collation to utf8mb4_general_ci if supported.

Phase 2 — Schema and account initialisation (node populate.js)

  1. DB connectivity check — creates and drops a temporary test database.

  2. App user — reads /etc/drumee/credential/db.json; creates drumee-app MariaDB user with that password (generates a random password and writes the file if absent).

  3. Mail user — creates mailserver MariaDB user from /etc/drumee/credential/postfix.json if present.

  4. org.populate() — writes core rows to the yp database:

    • sys_conf — system-wide settings (guest_id, nobody_id, public_id, domain, mfs_root, etc.)
    • domain — domain record
    • vhost — virtual hosts (ns1, ns2, jit, www, smtp, _acme-challenge, _domainkey)
    • organisation — organisation record
    • settings — defaults (wallpaper, cache_control, default_privilege)
    • dmz_user — guest DMZ record
    • mailserver.domains and mailserver.aliases (+ the butler mailbox if email.json is present)
  5. System accounts created:

    AccountUID sourcePrivilegeNotes
    nobodyID_NOBODY (fixed)1Anonymous placeholder
    guestget_sysconf('guest_id')1Unauthenticated visitor
    system@<domain>generatedDOM_OWNERCreates media hub + portal hub
    admin@<domain>generatedDOM_OWNERCreates shareboxes, sets quota, generates reset token
  6. Hubs created:

    HubvhostStatus
    Media hub<uniqueid>.<domain>system — stores wallpapers and tutorials
    Portal hubprimary domainsystem — public entry point
    Admin internal shareboxprivate
    Admin external sharebox (DMZ)for guest sharing
  7. Media importcurrently disabled. The wallpaper and tutorial import is commented out in populate.js, together with the withTimeout wrapper that used to bound it, so a fresh install ships with neither.

    The code is still there, and lib/mfs.js retains importContent() / importTutorial() (wallpapers from content.drumee.com/Wallpapers, tutorials from https://drumee.com/-/svc/yp.tutorials). It was disabled because it is cosmetic and reaches the network mid-install: on a slow or air-gapped host it could hang or fail the step that precedes the RSA key generation, which must run. Re-enabling it means restoring both the calls and their timeout guard.

  8. RSA key pair — generates and writes to /etc/drumee/credential/crypto/public.pem and private.pem.

  9. Welcome page — renders asset/welcome.html with the password-reset link to <data_dir>/tmp/welcome.html.

Phase 3 — Post-populate

  • Sends a welcome email to $ADMIN_EMAIL via bin/acknowledge.js (contains the password-reset link).
  • Applies any pending schema patches from /var/lib/drumee/patches/patch-from-manifest if the file exists.

Configuration Sources

SourceUsed for
/etc/drumee/drumee.shRuntime paths and env vars
/etc/drumee/credential/db.jsonMariaDB app user credentials
/etc/drumee/credential/postfix.jsonMail server DB user credentials
/etc/drumee/credential/email.jsonOutbound email auth
/etc/drumee/credential/crypto/RSA key pair (generated on first install)
$DRUMEE_DB_DIRMariaDB data directory (default /srv/db)
$ADMIN_EMAILRecipient for welcome/reset email

Database Structure

yp — Central system database shared across all entities. Contains sys_conf, domain, vhost, entity, drumate, hub, organisation, settings, privilege, disk_usage, tutorial, and mailserver tables.

Per-entity databases — One database per user and hub, created by the entity_create stored procedure. Contains mfs_* tables, permission, media, and activity tables.

Install Log

/var/log/drumee/seeds.log — records the mariabackup --copy-back output and timestamp.