#!/bin/sh
#Copyright: 2026 Aitor <aitor@genuen.org>
#License: CC0-1.0
#Comment: oneshot; invoke with: sv once mount-configfs

exec 2>&1

ebegin() { [ "${VERBOSE:-}" = no ] || echo "$@"; }
eend() { r=${1:-0}; shift || true; [ "$r" -eq 0 ] || [ "${VERBOSE:-}" = no ] || echo "$*" >&2; return "$r"; }
einfo() { [ "${VERBOSE:-}" = no ] || echo "$@"; }
ewarn() { echo "$@" >&2; }
eerror() { echo "$@" >&2; }

/usr/lib/runit-services/stage1/sv once kmod || exit 1
/usr/lib/runit-services/stage1/sv once mountkernfs.sh || exit 1

mountpoint='/sys/kernel/config'
test -d "${mountpoint}" || exit 0
! findmnt "${mountpoint}" >/dev/null || exit 0
mount none -t configfs "${mountpoint}"
exit $?
