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

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 mountnfs.sh || exit 1


. /lib/init/bootclean.sh

clean_all()
{
	command -v find >/dev/null 2>&1 || return 0
	log_begin_msg "Cleaning up temporary files..."
	ES=0
	clean_tmp || ES=1
	clean /run/lock "! -type d" || ES=1
	[ -d /run/shm ] && clean /run/shm "! -type d" || true
	log_end_msg $ES
	return $ES
}
rm -f /tmp/.clean /run/lock/.clean
if ! clean_all; then
	ewarn "mountnfs-bootclean: clean_all failed (continuing boot)"
fi
exit 0
