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/)
| Module | Responsibility |
|---|---|
organization.js | populate() seeds the yp system rows; createNobody/Guest/SystemUser/Admin() build the fixed accounts; remove() tears an org down. |
drumate.js | create() 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.js | Imports remote content (importContent/importFile/importTutorial) into MFS by downloading over HTTP, then mfs_create_node + copy into __storage__/. |
schema.js | Low-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
| Repo | Branch | Destination |
|---|---|---|
setup-schemas | main | /var/lib/drumee/setup-schemas/ |
schemas | preview | /var/lib/drumee/schemas/ |
Build Prerequisites
Seeds archive required. The build looks for a seeds archive in this order:
schemas/var/tmp/drumee/seeds.tgz— pre-existing archive in the repo$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)
- Sources
/etc/drumee/drumee.shfor environment variables. - Stops MariaDB.
- Manages the DB directory (
$DRUMEE_DB_DIR, default/srv/db):- Archives any existing
run/toorig/<date>/(rollback point). - Creates a fresh
run/directory.
- Archives any existing
- Extracts seeds from
/var/tmp/drumee/seeds.tgz. - Restores via
mariabackup --copy-backinto$DRUMEE_DB_DIR/run/. - Sets ownership (
mysql:mysql) and permissions (750dirs,rwfiles). - Starts MariaDB.
- 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'; - Sets global collation to
utf8mb4_general_ciif supported.
Phase 2 — Schema and account initialisation (node populate.js)
-
DB connectivity check — creates and drops a temporary test database.
-
App user — reads
/etc/drumee/credential/db.json; createsdrumee-appMariaDB user with that password (generates a random password and writes the file if absent). -
Mail user — creates
mailserverMariaDB user from/etc/drumee/credential/postfix.jsonif present. -
org.populate() — writes core rows to the
ypdatabase:sys_conf— system-wide settings (guest_id, nobody_id, public_id, domain, mfs_root, etc.)domain— domain recordvhost— virtual hosts (ns1, ns2, jit, www, smtp,_acme-challenge,_domainkey)organisation— organisation recordsettings— defaults (wallpaper, cache_control, default_privilege)dmz_user— guest DMZ recordmailserver.domainsandmailserver.aliases(+ thebutlermailbox ifemail.jsonis present)
-
System accounts created:
Account UID source Privilege Notes nobodyID_NOBODY(fixed)1 Anonymous placeholder guestget_sysconf('guest_id')1 Unauthenticated visitor system@<domain>generated DOM_OWNER Creates media hub + portal hub admin@<domain>generated DOM_OWNER Creates shareboxes, sets quota, generates reset token -
Hubs created:
Hub vhost Status Media hub <uniqueid>.<domain>system — stores wallpapers and tutorials Portal hub primary domain system — public entry point Admin internal sharebox private — Admin external sharebox (DMZ) — for guest sharing -
Media import — currently disabled. The wallpaper and tutorial import is commented out in
populate.js, together with thewithTimeoutwrapper that used to bound it, so a fresh install ships with neither.The code is still there, and
lib/mfs.jsretainsimportContent()/importTutorial()(wallpapers fromcontent.drumee.com/Wallpapers, tutorials fromhttps://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. -
RSA key pair — generates and writes to
/etc/drumee/credential/crypto/public.pemandprivate.pem. -
Welcome page — renders
asset/welcome.htmlwith the password-reset link to<data_dir>/tmp/welcome.html.
Phase 3 — Post-populate
- Sends a welcome email to
$ADMIN_EMAILviabin/acknowledge.js(contains the password-reset link). - Applies any pending schema patches from
/var/lib/drumee/patches/patch-from-manifestif the file exists.
Configuration Sources
| Source | Used for |
|---|---|
/etc/drumee/drumee.sh | Runtime paths and env vars |
/etc/drumee/credential/db.json | MariaDB app user credentials |
/etc/drumee/credential/postfix.json | Mail server DB user credentials |
/etc/drumee/credential/email.json | Outbound email auth |
/etc/drumee/credential/crypto/ | RSA key pair (generated on first install) |
$DRUMEE_DB_DIR | MariaDB data directory (default /srv/db) |
$ADMIN_EMAIL | Recipient 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.