summaryrefslogtreecommitdiffstats
path: root/etc/rc.d/mountcritremote
blob: 0561317681e8190fb378d484f579266f3111f4de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/sh
#
# $NetBSD: mountcritremote,v 1.7 2002/04/29 12:29:53 lukem Exp $
# $FreeBSD$
#

# PROVIDE: mountcritremote
# REQUIRE: NETWORKING root mountcritlocal
# KEYWORD: FreeBSD NetBSD

. /etc/rc.subr

name="mountcritremote"
stop_cmd=":"

case ${OSTYPE} in
	FreeBSD)
	start_cmd="mountcritremote_start"
	start_precmd="mountcritremote_precmd"
	;;
NetBSD)
	start_cmd="mountcritremote_start"
	;;
esac

# Mount NFS filesystems if present in /etc/fstab
#
# XXX When the vfsload() issues with nfsclient support and related sysctls
# have been resolved, this block can be removed, and the condition that
# skips nfs in the following block (for "other network filesystems") can
# be removed.
#
mountcritremote_precmd()
{
	case "`mount -d -a -t nfs 2> /dev/null`" in
	*mount_nfs*)
		# Handle absent nfs client support
		if ! sysctl vfs.nfs >/dev/null 2>&1; then
			kldload nfsclient || warn 'nfs mount ' \
			    'requested, but no nfs client in kernel' \
			return 1
		fi
		;;
	esac
	return 0
}

mountcritremote_start()
{
	case ${OSTYPE} in
	FreeBSD)
		# Mount nfs filesystems.
		#
		echo -n 'Mounting NFS file systems:'
		mount -a -t nfs
		echo '.'

		# Mount other network filesystems if present in /etc/fstab.
		for i in ${networkfs_types}; do
			fstype=${i%:*}
			fsdecr=${i#*:}

			[ "${fstype}" = "nfs" ] && continue

			case "`mount -d -a -t ${fstype}`" in
			*mount_${fstype}*)
				echo -n "Mounting ${fsdecr} file systems:"
				mount -a -t ${fstype}
				echo '.'
				;;
			esac
		done

		# Cleanup /var again just in case it's a network mount.
		/etc/rc.d/cleanvar reload
		rm -f /var/run/clean_var /var/spool/lock/clean_var
		;;
	NetBSD)
		#	Mount critical filesystems that may be `remote'.
		#	(as specified in $critical_filesystems_remote)
		#	This usually includes /usr.
		#
		mount_critical_filesystems remote
		;;
	esac
}

load_rc_config $name
run_rc_command "$1"
OpenPOWER on IntegriCloud