NetBSD/etc/rc.d/mountall

49 lines
936 B
Bash
Executable File

#!/bin/sh
#
# $NetBSD: mountall,v 1.10 2018/06/08 14:44:21 sevan 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...'
if [ -f /etc/zfs/zpool.cache ]; then
# Get ZFS module loaded (and thereby, zvols created).
zfs list > /dev/null 2>&1
# Mount file systems noted in fstab.
mount -a
# Mount ZFS file systems.
zfs mount -a
else
# Mount file systems noted in fstab.
mount -a
fi
}
mountall_stop()
{
echo 'Unmounting all file systems...'
if [ -f /etc/zfs/zpool.cache ]; then
# Unmount ZFS file systems.
zfs unmount -a
# Unmount file systems noted in fstab.
umount -a
# Unload ZFS module, so disk devices are closed.
modunload zfs
else
# Otherwise, just deal with fstab.
umount -a
fi
}
load_rc_config $name
run_rc_command "$1"