Skip to content

Storage: SD cards, USB sticks and servers ​

The music library and the recordings live on the speaker's own card (fileadmin) unless the owner chooses another place under Settings → Storage:

  • SD cards and USB sticks, plugged into the speaker directly or through a card reader;
  • folders on a server (a NAS over SMB, SFTP, WebDAV, FTP or S3), which an administrator adds in the backend under Boombox → Storages.

On the speaker's own card the music folder and the recordings folder have to be below music/ or recordings/: the web server hands out nothing from those two to anyone who is not logged in, while everything else under fileadmin is public, as on any TYPO3 site. A card, stick or server takes any folder: nothing on them is public.

Each one then shows up as a choice under Music → Music folder and Settings → Recording, and as a tab of its own in a playlist's Add songs…, to pick its songs without moving the music folder. The page is the owner's alone: the TV's account neither sees it nor reaches its API.

Cards and sticks ​

  1. Plug the card in. It shows up under SD cards and USB sticks with its label, format and size, as Not included.
  2. Press Include. The speaker mounts it and keeps doing so whenever the card is plugged in again, also after a restart.
  3. Choose it as the Storage of the music folder or the recordings folder. The folder is created if it is missing.

Before pulling a card out, press Eject: the speaker finishes writing and unmounts it. It stays unmounted until it is plugged in again. A card pulled out without ejecting is unmounted all the same, but a song being written at that moment may be lost.

Forget… stops using the card; what is on it stays on it. A card that holds the music folder or the recordings folder cannot be forgotten: move the folder first.

Only FAT32 and exFAT are mounted, the formats cards and sticks come in. A card in another format (ext4, NTFS) is listed but cannot be included: format it as exFAT on a computer. The speaker's own system disk is never offered.

Servers: NAS, SMB, SFTP, WebDAV, FTP, S3 ​

A folder on a server is not mounted. An administrator adds the server as a storage in the TYPO3 backend, under Boombox → Storages, and the web app reads and writes it directly through Flysystem (EXT:storages):

  • SMB for Windows, Samba, and most NAS;
  • SFTP, WebDAV (Nextcloud, ownCloud), FTP;
  • S3 and services that speak it (MinIO, Backblaze B2, Wasabi).

The storage is saved only once its server answers. Its password goes to config/system/file-storage-secrets.json, never into the storages file or onto a page.

A storage on a server then shows up as a choice under Music → Music folder like a card. Songs from it play in the page directly. In a playlist the speaker plays its own copy, from the playback cache (var/boombox-cache, 2 GB). Backups can be copied to a server too (Backup).

Music libraries ​

Music libraries on the same page lists the folders songs are picked from: each has a name, a storage (the speaker's own card, a card or stick, a server) and a folder there. Add library… adds one; on the speaker's own card its folder has to be below music/ or recordings/, and a folder that is missing is made. Each library shows in Your music (choose it under Library) and as a tab of its own in a playlist's Add songs….

One library takes the uploads, marked Uploads go here: its folder is the music folder (Music → Music folder changes it). Use for uploads moves them to another; the library they go to cannot be removed. Removing a library leaves its songs where they are, and playlists keep them.

The agent keeps the list (library.libraries in its state, the upload library's id in library.uploads); the web app checks each folder against its storages before the agent saves it. A song is the library's when it lies in any library's folder: that is told from the folders' settings, without asking a server. A speaker set up before gets the element below its cards with the next release (an upgrade wizard).

RouteDoes
GET library/librariesThe libraries, {id, name, folder, uploads}.
POST library/libraries/add {name, folder}Add one.
POST library/libraries/update {id, name?, folder?}Change one.
POST library/libraries/remove {id}Remove one (not the upload library).
POST library/libraries/uploads {id}Uploads go there; its folder becomes the music folder.
GET library?library=<id>Browse it, as GET library browses the music folder.

How it works ​

The agent finds cards with lsblk and follows them with udevadm monitor. It cannot mount anything itself, because its sandbox does not allow it, so it asks systemd with systemd-mount:

  • Mount point: each card goes to /media/boombox/card-<filesystem UUID>.
  • Ownership: everything is mounted for the web server's user (www-data), with nothing on it allowed to run (noexec, nosuid, nodev).
  • Pulled out: systemd ties a card's mount to the device, so a card pulled out is unmounted.

A mount point with nothing mounted on it is removed at once, so nothing can write into it and onto the speaker's own card instead. If one is found holding files, the agent leaves it and logs a warning.

The web app turns each included card into a TYPO3 storage in config/system/file-storages.yaml. MountedStorages keeps them in step:

  • Driver: each is a Local storage on the mount point. The last part of its base path, <id>, tells which card it is.
  • Visibility: not public, since it is outside the web root.
  • Online: only while it is mounted.
  • Removed: from the file when the card is forgotten. Its identifier is not given to another storage while files still name it.
  • When it runs: on every list of storages and after every action on the page.
  • Where the file is: the release links it to shared/config/system/, where the web user may replace it (StorageFile); the release's own config/system/ stays root's.

Playlists play from below /media/boombox as from fileadmin.

RouteDoes
GET storageThe cards, with the storages made to match.
POST storage/cards/include {uuid, name?}Include a card and mount it.
POST storage/cards/eject {uuid}Unmount it until it is plugged in again.
POST storage/cards/forget {uuid}Stop using it (refused while a folder is on it).

install.sh --system installs exfatprogs, dosfstools and smbclient (for SMB storages), creates /media/boombox, and lets the web server, the import and the agent write there.

In development ​

The simulated speaker's cards come and go on request:

bash
ddev boombox-sim card_insert '{"uuid":"1A2B-3C4D","label":"PARTY"}'
ddev boombox-sim card_insert '{"label":"backup","fstype":"ext4"}'   # listed, not supported
ddev boombox-sim card_remove '{"uuid":"1A2B-3C4D"}'

What is written to a simulated card is kept in var/boombox-sim/media-backing/ while the card is out.

The servers of .ddev/docker-compose.storages.yaml (Samba, SFTP, WebDAV, FTP, S3) can be added as storages in the backend; ddev storages-check tries each one.