1#!/bin/sh
2#
3# $FreeBSD$
4#
5
6# PROVIDE: mountcritremote
7# REQUIRE: NETWORKING FILESYSTEMS ipsec netwait
8# KEYWORD: nojail
9
10. /etc/rc.subr
11
12name="mountcritremote"
13stop_cmd=":"
14start_cmd="mountcritremote_start"
15start_precmd="mountcritremote_precmd"
16
17# Mount NFS filesystems if present in /etc/fstab
18#
19# XXX When the vfsload() issues with nfsclient support and related sysctls
20# have been resolved, this block can be removed, and the condition that
21# skips nfs in the following block (for "other network filesystems") can
22# be removed.
23#
24mountcritremote_precmd()
25{
26	case "`mount -d -a -t nfs 2> /dev/null`" in
27	*mount_nfs*)
28		# Handle absent nfs client support
29		load_kld -m nfs nfscl || return 1
30		;;
31	esac
32	return 0
33}
34
35mountcritremote_start()
36{
37	# Mount nfs filesystems.
38	#
39	case "`/sbin/mount -d -a -t nfs`" in
40	'')
41		;;
42	*)
43		echo -n 'Mounting NFS file systems:'
44		mount -a -t nfs
45		echo '.'
46		;;
47	esac
48
49	# Mount other network filesystems if present in /etc/fstab.
50	case ${extra_netfs_types} in
51	[Nn][Oo])
52		;;
53	*)
54		netfs_types="${netfs_types} ${extra_netfs_types}"
55		;;
56	esac
57
58	for i in ${netfs_types}; do
59		fstype=${i%:*}
60		fsdecr=${i#*:}
61
62		[ "${fstype}" = "nfs" ] && continue
63
64		case "`mount -d -a -t ${fstype}`" in
65		*mount_${fstype}*)
66			echo -n "Mounting ${fsdecr} file systems:"
67			mount -a -t ${fstype}
68			echo '.'
69			;;
70		esac
71	done
72
73	# Cleanup /var again just in case it's a network mount.
74	/etc/rc.d/cleanvar quietreload
75	rm -f /var/run/clean_var /var/spool/lock/clean_var
76}
77
78load_rc_config $name
79run_rc_command "$1"
80