5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
8 #
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
13 #
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 #
20 # CDDL HEADER END
21 #
22
23 #
24 # Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
25 # Copyright 2015 Nexenta Systems, Inc. All rights reserved.
26 # Copyright 2016 Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
27 #
28
29 # Start/stop processes required for server NFS
30
31 . /lib/svc/share/smf_include.sh
32 . /lib/svc/share/ipf_include.sh
33 zone=`smf_zonename`
34
35 #
36 # Handling a corner case here. If we were in offline state due to an
37 # unsatisfied dependency, the ipf_method process wouldn't have generated
38 # the ipfilter configuration. When we transition to online because the
39 # dependency is satisfied, the start method will have to generate the
40 # ipfilter configuration. To avoid all possible deadlock scenarios,
41 # we restart ipfilter which will regenerate the ipfilter configuration
42 # for the entire system.
43 #
44 # The ipf_method process signals that it didn't generate ipf rules by
45 # removing the service's ipf file. Thus we only restart network/ipfilter
46 # when the file is missing.
49 {
50 ipfile=`fmri_to_file $SMF_FMRI $IPF_SUFFIX`
51 ip6file=`fmri_to_file $SMF_FMRI $IPF6_SUFFIX`
52 [ -f "$ipfile" -a -f "$ip6file" ] && return 0
53
54 #
55 # Nothing to do if:
56 # - ipfilter isn't online
57 # - global policy is 'custom'
58 # - service's policy is 'use_global'
59 #
60 service_check_state $IPF_FMRI $SMF_ONLINE || return 0
61 [ "`get_global_def_policy`" = "custom" ] && return 0
62 [ "`get_policy $SMF_FMRI`" = "use_global" ] && return 0
63
64 svcadm restart $IPF_FMRI
65 }
66
67 case "$1" in
68 'start')
69 # The NFS server is not supported in a local zone
70 if smf_is_nonglobalzone; then
71 /usr/sbin/svcadm disable -t svc:/network/nfs/server
72 echo "The NFS server is not supported in a local zone"
73 sleep 5 &
74 exit $SMF_EXIT_OK
75 fi
76
77 # Share all file systems enabled for sharing. sharemgr understands
78 # regular shares and ZFS shares and will handle both. Technically,
79 # the shares would have been started long before getting here since
80 # nfsd has a dependency on them.
81
82 # restart stopped shares from the repository
83 /usr/sbin/sharemgr start -P nfs -a
84
85 # Options for nfsd are now set in SMF
86
87 /usr/lib/nfs/mountd
88 rc=$?
89 if [ $rc != 0 ]; then
90 /usr/sbin/svcadm mark -t maintenance svc:/network/nfs/server
91 echo "$0: mountd failed with $rc"
92 sleep 5 &
93 exit $SMF_EXIT_ERR_FATAL
94 fi
95
96 /usr/lib/nfs/nfsd
|
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
8 #
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
13 #
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 #
20 # CDDL HEADER END
21 #
22
23 #
24 # Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
25 # Copyright 2016 Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
26 # Copyright 2018 Nexenta Systems, Inc. All rights reserved.
27 #
28
29 # Start/stop processes required for server NFS
30
31 . /lib/svc/share/smf_include.sh
32 . /lib/svc/share/ipf_include.sh
33 zone=`smf_zonename`
34
35 #
36 # Handling a corner case here. If we were in offline state due to an
37 # unsatisfied dependency, the ipf_method process wouldn't have generated
38 # the ipfilter configuration. When we transition to online because the
39 # dependency is satisfied, the start method will have to generate the
40 # ipfilter configuration. To avoid all possible deadlock scenarios,
41 # we restart ipfilter which will regenerate the ipfilter configuration
42 # for the entire system.
43 #
44 # The ipf_method process signals that it didn't generate ipf rules by
45 # removing the service's ipf file. Thus we only restart network/ipfilter
46 # when the file is missing.
49 {
50 ipfile=`fmri_to_file $SMF_FMRI $IPF_SUFFIX`
51 ip6file=`fmri_to_file $SMF_FMRI $IPF6_SUFFIX`
52 [ -f "$ipfile" -a -f "$ip6file" ] && return 0
53
54 #
55 # Nothing to do if:
56 # - ipfilter isn't online
57 # - global policy is 'custom'
58 # - service's policy is 'use_global'
59 #
60 service_check_state $IPF_FMRI $SMF_ONLINE || return 0
61 [ "`get_global_def_policy`" = "custom" ] && return 0
62 [ "`get_policy $SMF_FMRI`" = "use_global" ] && return 0
63
64 svcadm restart $IPF_FMRI
65 }
66
67 case "$1" in
68 'start')
69 # Share all file systems enabled for sharing. sharemgr understands
70 # regular shares and ZFS shares and will handle both. Technically,
71 # the shares would have been started long before getting here since
72 # nfsd has a dependency on them.
73
74 # restart stopped shares from the repository
75 /usr/sbin/sharemgr start -P nfs -a
76
77 # Options for nfsd are now set in SMF
78
79 /usr/lib/nfs/mountd
80 rc=$?
81 if [ $rc != 0 ]; then
82 /usr/sbin/svcadm mark -t maintenance svc:/network/nfs/server
83 echo "$0: mountd failed with $rc"
84 sleep 5 &
85 exit $SMF_EXIT_ERR_FATAL
86 fi
87
88 /usr/lib/nfs/nfsd
|