xref: /freebsd/libexec/rc/rc.d/mountcritremote (revision e0649a35a670c4b625d1de289b3886d9b3c9654f)
1#!/bin/sh
2#
3#
4
5# PROVIDE: mountcritremote
6# REQUIRE: NETWORKING FILESYSTEMS ipsec netwait nfscbd
7# KEYWORD: nojail
8
9. /etc/rc.subr
10
11name="mountcritremote"
12desc="Mount critical remote filesystems"
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	local mounted_remote_filesystem=false
38
39	# Mount nfs filesystems.
40	#
41	case "`/sbin/mount -d -a -t nfs`" in
42	'')
43		;;
44	*)
45		mounted_remote_filesystem=true
46		echo -n 'Mounting NFS filesystems:'
47		mount -a -t nfs
48		echo '.'
49		;;
50	esac
51
52	# Mount other network filesystems if present in /etc/fstab.
53	case ${extra_netfs_types} in
54	[Nn][Oo])
55		;;
56	*)
57		netfs_types="${netfs_types} ${extra_netfs_types}"
58		;;
59	esac
60
61	for i in ${netfs_types}; do
62		fstype=${i%:*}
63		fsdecr=${i#*:}
64
65		[ "${fstype}" = "nfs" ] && continue
66
67		case "`mount -d -a -t ${fstype}`" in
68		*mount_${fstype}*)
69			mounted_remote_filesystem=true
70			echo -n "Mounting ${fsdecr} filesystems:"
71			mount -a -t ${fstype}
72			echo '.'
73			;;
74		esac
75	done
76
77	if $mounted_remote_filesystem; then
78		# Cleanup /var again just in case it's a network mount.
79		/etc/rc.d/cleanvar quietreload
80		rm -f /var/run/clean_var /var/spool/lock/clean_var
81
82		# Regenerate the ldconfig hints in case there are additional
83		# library paths on remote file systems
84		/etc/rc.d/ldconfig quietstart
85	fi
86}
87
88load_rc_config $name
89
90# mounting shall not be performed in a svcj
91mountcritremote_svcj="NO"
92
93run_rc_command "$1"
94