xref: /dragonfly/etc/rc.d/mountcritremote (revision 2d8a3be7)
1#!/bin/sh
2#
3# $NetBSD: mountcritremote,v 1.7 2002/04/29 12:29:53 lukem Exp $
4# $FreeBSD: src/etc/rc.d/mountcritremote,v 1.6 2003/06/01 01:43:37 gordon Exp $
5# $DragonFly: src/etc/rc.d/mountcritremote,v 1.1 2003/07/24 06:35:37 dillon Exp $
6#
7
8# PROVIDE: mountcritremote
9# REQUIRE: NETWORKING root mountcritlocal
10# KEYWORD: DragonFly FreeBSD NetBSD
11
12. /etc/rc.subr
13
14name="mountcritremote"
15stop_cmd=":"
16
17case ${OSTYPE} in
18	DragonFly)
19	start_cmd="mountcritremote_start"
20        start_precmd="mountcritremote_precmd"
21        ;;
22	FreeBSD)
23	start_cmd="mountcritremote_start"
24	start_precmd="mountcritremote_precmd"
25	;;
26NetBSD)
27	start_cmd="mountcritremote_start"
28	;;
29esac
30
31# Mount NFS filesystems if present in /etc/fstab
32#
33# XXX When the vfsload() issues with nfsclient support and related sysctls
34# have been resolved, this block can be removed, and the condition that
35# skips nfs in the following block (for "other network filesystems") can
36# be removed.
37#
38mountcritremote_precmd()
39{
40	case "`mount -d -a -t nfs 2> /dev/null`" in
41	*mount_nfs*)
42		# Handle absent nfs client support
43		if ! sysctl vfs.nfs >/dev/null 2>&1; then
44			kldload nfsclient || warn 'nfs mount ' \
45			    'requested, but no nfs client in kernel' \
46			return 1
47		fi
48		;;
49	esac
50	return 0
51}
52
53mountcritremote_start()
54{
55	case ${OSTYPE} in
56	DragonFly)
57		# Mount nfs filesystems.
58                #
59                echo -n 'Mounting NFS file systems:'
60                mount -a -t nfs
61                echo '.'
62                # Mount other network filesystems if present in /etc/fstab.
63                case ${extra_netfs_types} in
64                [Nn][Oo])
65                        ;;
66                *)
67                        netfs_types="${netfs_types} ${extra_netfs_types}"
68                        ;;
69                esac
70                for i in ${netfs_types}; do
71                        fstype=${i%:*}
72                        fsdecr=${i#*:}
73                        [ "${fstype}" = "nfs" ] && continue
74                        case "`mount -d -a -t ${fstype}`" in
75                        *mount_${fstype}*)
76                                echo -n "Mounting ${fsdecr} file systems:"
77                                mount -a -t ${fstype}
78                                echo '.'
79                                ;;
80                        esac
81                done
82
83		# Cleanup /var again just in case it's a network mount.
84                /etc/rc.d/cleanvar reload
85                rm -f /var/run/clean_var /var/spool/lock/clean_var
86                ;;
87
88
89	FreeBSD)
90		# Mount nfs filesystems.
91		#
92		echo -n 'Mounting NFS file systems:'
93		mount -a -t nfs
94		echo '.'
95
96		# Mount other network filesystems if present in /etc/fstab.
97		case ${extra_netfs_types} in
98		[Nn][Oo])
99			;;
100		*)
101			netfs_types="${netfs_types} ${extra_netfs_types}"
102			;;
103		esac
104
105		for i in ${netfs_types}; do
106			fstype=${i%:*}
107			fsdecr=${i#*:}
108
109			[ "${fstype}" = "nfs" ] && continue
110
111			case "`mount -d -a -t ${fstype}`" in
112			*mount_${fstype}*)
113				echo -n "Mounting ${fsdecr} file systems:"
114				mount -a -t ${fstype}
115				echo '.'
116				;;
117			esac
118		done
119
120		# Cleanup /var again just in case it's a network mount.
121		/etc/rc.d/cleanvar reload
122		rm -f /var/run/clean_var /var/spool/lock/clean_var
123		;;
124	NetBSD)
125		#	Mount critical filesystems that may be `remote'.
126		#	(as specified in $critical_filesystems_remote)
127		#	This usually includes /usr.
128		#
129		mount_critical_filesystems remote
130		;;
131	esac
132}
133
134load_rc_config $name
135run_rc_command "$1"
136