#!/bin/sh
#
# $NetBSD: mountall,v 1.15 2021/03/09 12:42:46 sborrill Exp $
#

# REQUIRE: mountcritremote named ypbind
# PROVIDE: mountall

$_rc_subr_loaded . /etc/rc.subr

name="mountall"
start_cmd="mountall_start"
stop_cmd="mountall_stop"

mountall_start()
{
	echo 'Mounting all file systems...'

	# Mount ZFS filesystems first because fstab
	# may try and null mount paths on ZFS.
	if checkyesno zfs; then
		zfs mount -a
		zfs share -a
	fi

	# Mount file systems noted in fstab.
	mount -a
}

mountall_stop()
{
	echo 'Unmounting all file systems...'
	# Unmount file systems noted in fstab.
	umount -a

	# Unmount ZFS file systems.
	if checkyesno zfs; then
		zfs unshare -a
		zfs unmount -a
	fi
}

load_rc_config $name
load_rc_config_var zfs zfs
run_rc_command "$1"
