xref: /freebsd/libexec/rc/rc.d/mountcritlocal (revision abd3c20a030cbbf97c0188db3d2543da7fa296b2)
10696600cSBjoern A. Zeeb#!/bin/sh
20696600cSBjoern A. Zeeb#
30696600cSBjoern A. Zeeb#
40696600cSBjoern A. Zeeb
50696600cSBjoern A. Zeeb# PROVIDE: mountcritlocal
6f1602affSCy Schubert# REQUIRE: root hostid_save mdconfig
70696600cSBjoern A. Zeeb# KEYWORD: nojail shutdown
80696600cSBjoern A. Zeeb
90696600cSBjoern A. Zeeb. /etc/rc.subr
100696600cSBjoern A. Zeeb
110696600cSBjoern A. Zeebname="mountcritlocal"
120696600cSBjoern A. Zeebdesc="Mount critical local filesystems"
130696600cSBjoern A. Zeebstart_cmd="mountcritlocal_start"
140696600cSBjoern A. Zeebstop_cmd=sync
150696600cSBjoern A. Zeeb
160696600cSBjoern A. Zeebmountcritlocal_start()
170696600cSBjoern A. Zeeb{
180696600cSBjoern A. Zeeb	local err holders waited
190696600cSBjoern A. Zeeb
200696600cSBjoern A. Zeeb	# Set up the list of network filesystem types for which mounting
210696600cSBjoern A. Zeeb	# should be delayed until after network initialization.
220696600cSBjoern A. Zeeb	case ${extra_netfs_types} in
230696600cSBjoern A. Zeeb	[Nn][Oo])
240696600cSBjoern A. Zeeb		;;
250696600cSBjoern A. Zeeb	*)
260696600cSBjoern A. Zeeb		netfs_types="${netfs_types} ${extra_netfs_types}"
270696600cSBjoern A. Zeeb		;;
280696600cSBjoern A. Zeeb	esac
290696600cSBjoern A. Zeeb
30b6e33f0cSCy Schubert	while read a b vfstype rest; do
31*abd3c20aSCy Schubert		if [ "$vfstype" = "zfs" -a "${a#\#}" = "$a" ]; then
32b6e33f0cSCy Schubert			# zpool is needed for legacy ZFS
33b6e33f0cSCy Schubert			echo 'Importing zpools for legacy ZFS'
34b6e33f0cSCy Schubert			/etc/rc.d/zpool start
35b6e33f0cSCy Schubert			break
36b6e33f0cSCy Schubert		fi
37b6e33f0cSCy Schubert	done < /etc/fstab
38b6e33f0cSCy Schubert
390696600cSBjoern A. Zeeb	# Mount everything except nfs filesystems.
40325ebf37SJose Luis Duran	startmsg -n 'Mounting local filesystems:'
410696600cSBjoern A. Zeeb	mount_excludes='no'
420696600cSBjoern A. Zeeb	for i in ${netfs_types}; do
430696600cSBjoern A. Zeeb		fstype=${i%:*}
440696600cSBjoern A. Zeeb		mount_excludes="${mount_excludes}${fstype},"
450696600cSBjoern A. Zeeb	done
460696600cSBjoern A. Zeeb	mount_excludes=${mount_excludes%,}
470696600cSBjoern A. Zeeb
480696600cSBjoern A. Zeeb	mount -a -t ${mount_excludes}
490696600cSBjoern A. Zeeb	err=$?
500696600cSBjoern A. Zeeb	if [ ${err} -ne 0 ]; then
510696600cSBjoern A. Zeeb		echo 'Mounting /etc/fstab filesystems failed,' \
520696600cSBjoern A. Zeeb		    'will retry after root mount hold release'
530696600cSBjoern A. Zeeb		root_hold_wait
540696600cSBjoern A. Zeeb		mount -a -t ${mount_excludes}
550696600cSBjoern A. Zeeb		err=$?
560696600cSBjoern A. Zeeb	fi
570696600cSBjoern A. Zeeb
58325ebf37SJose Luis Duran	startmsg '.'
590696600cSBjoern A. Zeeb
600696600cSBjoern A. Zeeb	case ${err} in
610696600cSBjoern A. Zeeb	0)
620696600cSBjoern A. Zeeb		;;
630696600cSBjoern A. Zeeb	*)
640696600cSBjoern A. Zeeb		echo 'Mounting /etc/fstab filesystems failed,' \
650696600cSBjoern A. Zeeb		    'startup aborted'
660696600cSBjoern A. Zeeb		stop_boot true
670696600cSBjoern A. Zeeb		;;
680696600cSBjoern A. Zeeb	esac
690696600cSBjoern A. Zeeb}
700696600cSBjoern A. Zeeb
710696600cSBjoern A. Zeebload_rc_config $name
72f99f0ee1SAlexander Leidinger
73f99f0ee1SAlexander Leidinger# mounting shall not be performed in a svcj
74f99f0ee1SAlexander Leidingermountcritlocal_svcj="NO"
75f99f0ee1SAlexander Leidinger
760696600cSBjoern A. Zeebrun_rc_command "$1"
77