* Added tabs instead of spaces for readability and consistency with NetBSD
[dragonfly.git] / etc / rc.d / mountcritremote
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.2 2003/11/19 10:32:45 eirikn Exp $
6 #
7
8 # PROVIDE: mountcritremote
9 # REQUIRE: NETWORKING root mountcritlocal
10 # KEYWORD: DragonFly FreeBSD NetBSD
11
12 . /etc/rc.subr
13
14 name="mountcritremote"
15 stop_cmd=":"
16
17 case ${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         ;;
26 NetBSD)
27         start_cmd="mountcritremote_start"
28         ;;
29 esac
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 #
38 mountcritremote_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
53 mountcritremote_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         FreeBSD)
88                 # Mount nfs filesystems.
89                 #
90                 echo -n 'Mounting NFS file systems:'
91                 mount -a -t nfs
92                 echo '.'
93
94                 # Mount other network filesystems if present in /etc/fstab.
95                 case ${extra_netfs_types} in
96                 [Nn][Oo])
97                         ;;
98                 *)
99                         netfs_types="${netfs_types} ${extra_netfs_types}"
100                         ;;
101                 esac
102
103                 for i in ${netfs_types}; do
104                         fstype=${i%:*}
105                         fsdecr=${i#*:}
106
107                         [ "${fstype}" = "nfs" ] && continue
108
109                         case "`mount -d -a -t ${fstype}`" in
110                         *mount_${fstype}*)
111                                 echo -n "Mounting ${fsdecr} file systems:"
112                                 mount -a -t ${fstype}
113                                 echo '.'
114                                 ;;
115                         esac
116                 done
117
118                 # Cleanup /var again just in case it's a network mount.
119                 /etc/rc.d/cleanvar reload
120                 rm -f /var/run/clean_var /var/spool/lock/clean_var
121                 ;;
122         NetBSD)
123                 #       Mount critical filesystems that may be `remote'.
124                 #       (as specified in $critical_filesystems_remote)
125                 #       This usually includes /usr.
126                 #
127                 mount_critical_filesystems remote
128                 ;;
129         esac
130 }
131
132 load_rc_config $name
133 run_rc_command "$1"