/[baselayout]/trunk/init.d/netmount
Gentoo

Contents of /trunk/init.d/netmount

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2831 - (show annotations) (download)
Wed Aug 15 14:49:41 2007 UTC (11 years, 1 month ago) by uberlord
File size: 1982 byte(s)
    `config /etc/fstab' can now be used in depend() functions to show that
    the deptree should be regenerated if /etc/fstab has changed.
1 #!/sbin/runscript
2 # Copyright 1999-2007 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4
5 description="Mounts network shares according to /etc/fstab."
6
7 have_nfs() {
8 local IFS=\n x=
9 set -- $(fstabinfo --fstype nfs,nfs4)
10 for x in "$@" ; do
11 ! fstabinfo --opts "${x}" | grep -q noauto && return 0
12 done
13 return 1
14 }
15
16 depend() {
17 local myneed= myuse= pmap="portmap" nfsmounts= x
18 [ -x /etc/init.d/rpcbind ] && pmap="rpcbind"
19
20 # Only have Portmap as a dependency if there is a nfs mount in fstab that
21 # is set to mount at boot
22 if have_nfs ; then
23 myneed="${myneed} ${pmap}"
24 else
25 myuse="${myuse} ${pmap}"
26 fi
27
28 config /etc/fstab
29 need net ${myneed}
30 use afc-client amd autofs dns nfs nfsmount ${myuse}
31 }
32
33 start() {
34 local myneed= myuse= pmap="portmap" nfsmounts=
35 [ -x /etc/init.d/rpcbind ] && pmap="rpcbind"
36
37 local x= fs=
38 for x in ${RC_NET_FS_LIST} ; do
39 case "${x}" in
40 nfs|nfs4)
41 # If the nfsmount script took care of the nfs filesystems,
42 # then there's no point in trying them twice
43 service_started nfsmount && continue
44
45 # Only try to mount NFS filesystems if portmap was started.
46 # This is to fix "hang" problems for new users who do not
47 # add portmap to the default runlevel.
48 if have_nfs && ! service_started "${pmap}" ; then
49 continue
50 fi
51 ;;
52 esac
53 fs="${fs}${fs:+,}${x}"
54 done
55
56 ebegin "Mounting network filesystems"
57 mount -at ${fs}
58 ewend $? "Could not mount all network filesystems!"
59 return 0
60 }
61
62 stop() {
63 local x= fs=
64 for x in ${RC_NET_FS_LIST} ; do
65 fs="${fs}${fs:+,}${x}"
66 done
67
68 ebegin "Unmounting network filesystems"
69 umount -at ${fs}
70 local retval=$?
71 eend ${retval} "Failed to simply unmount filesystems"
72
73 if [ ${retval} -ne 0 ] ; then
74 . "${RC_LIBDIR}/sh/rc-mount.sh"
75 eindent
76 fs=
77 for x in ${RC_NET_FS_LIST} ; do
78 fs="${fs:+|}${x}"
79 done
80 do_unmount "umount" "" "" "^(${fs})$"
81 retval=$?
82 eoutdent
83 fi
84
85 return ${retval}
86 }
87
88 # vim: set ts=4 :

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20