Files
VoidUniveralFormat/installer/linux/register_binfmt.sh
T
faumaray bba5c8a39a initial commit
Signed-off-by: Aleksey Selihov <faumaray@gmail.com>
2026-05-22 02:40:32 +03:00

39 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Register the .vlc binfmt_misc entry for an already-installed voidloader.
# Use this after a source build instead of running the full installer.
# Requires root (or write access to /proc/sys/fs/binfmt_misc/register).
#
# Usage: sudo ./register_binfmt.sh [/path/to/voidloader]
set -euo pipefail
VOIDLOADER="${1:-/usr/local/bin/voidloader}"
BINFMT_PROC="/proc/sys/fs/binfmt_misc"
BINFMT_ENTRY_NAME="vlc"
if [[ ! -x "$VOIDLOADER" ]]; then
echo "error: voidloader not found or not executable: $VOIDLOADER" >&2
echo " Build it first (cmake --build build) or pass its path as an argument." >&2
exit 1
fi
if [[ ! -d "$BINFMT_PROC" ]]; then
echo "error: ${BINFMT_PROC} not found — is binfmt_misc mounted?" >&2
echo " Try: sudo mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc" >&2
exit 1
fi
# Remove stale entry (ignore if not registered).
if [[ -f "${BINFMT_PROC}/${BINFMT_ENTRY_NAME}" ]]; then
echo "Removing stale binfmt_misc entry '${BINFMT_ENTRY_NAME}'"
echo -1 > "${BINFMT_PROC}/${BINFMT_ENTRY_NAME}"
fi
# Register: magic is V=0x56 L=0x4C C=0x43 \0=0x00.
printf ':vlc:M:0:VLC\x00::%s:\n' "$VOIDLOADER" > "${BINFMT_PROC}/register"
echo "Registered: .vlc files → ${VOIDLOADER}"
echo " Note: this registration is lost on reboot."
echo " For persistence: copy installer/linux/binfmt.d/vlc.conf to /etc/binfmt.d/"
echo " and run: sudo systemctl restart systemd-binfmt"