]> git.pld-linux.org Git - projects/rc-scripts.git/blame - rc.d/init.d/netfs
Don't mount fs inside of vserver guest.
[projects/rc-scripts.git] / rc.d / init.d / netfs
CommitLineData
8911a87a
AM
1#!/bin/sh
2#
3# netfs Mount network filesystems.
4#
5# Authors: Bill Nottingham <notting@redhat.com>
6# AJ Lewis <alewis@redhat.com>
7# Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
8#
9# chkconfig: 345 25 75
10# description: Mounts and unmounts all Network File System (NFS), \
11# CIFS (Lan Manager/Windows), and NCP (NetWare) mount points.
12
13[ -f /etc/sysconfig/network ] || exit 0
b92a94f3
AM
14. /etc/rc.d/init.d/functions
15. /etc/rc.d/init.d/cryptsetup
8911a87a
AM
16. /etc/sysconfig/network
17
8ed3c2f6
AM
18if is_yes "$VSERVER"; then
19 exit 0
20fi
21
26b0394a
AM
22# nfs uses own script for that
23if [ ! -f /etc/rc.d/init.d/nfsfs ]; then
24 NFSFSTAB=$(LC_ALL=C awk '!/^#/ && $3 ~ /^nfs/ && $3 != "nfsd" && $4 !~ /noauto/ { print $2 }' /etc/fstab)
25 NFSMTAB=$(LC_ALL=C awk '$3 ~ /^nfs/ && $3 != "nfsd" && $2 != "/" { print $2 }' /proc/mounts)
26fi
27
8911a87a
AM
28CIFSFSTAB=$(LC_ALL=C awk '!/^#/ && $3 == "cifs" && $4 !~ /noauto/ { print $2 }' /etc/fstab)
29NCPFSTAB=$(LC_ALL=C awk '!/^#/ && $3 == "ncpfs" && $4 !~ /noauto/ { print $2 }' /etc/fstab)
30NETDEVFSTAB=$(LC_ALL=C awk '!/^#/ && $4 ~/_netdev/ && $4 !~ /noauto/ { print $1 }' /etc/fstab)
31
32NFSMTAB=$(LC_ALL=C awk '$3 ~ /^nfs/ && $3 != "nfsd" && $2 != "/" { print $2 }' /proc/mounts)
33CIFSMTAB=$(LC_ALL=C awk '$3 == "cifs" { print $2 }' /proc/mounts)
34NCPMTAB=$(LC_ALL=C awk '$3 == "ncpfs" { print $2 }' /proc/mounts)
35NETDEVMTAB=$(LC_ALL=C awk '$4 ~ /_netdev/ && $2 != "/" { print $2 }' /etc/mtab)
36
c1ebcbf5 37start() {
3aeae4b7
ER
38 if [ ! -f /var/lock/subsys/network ]; then
39 return
40 fi
41 if [ "$(id -u)" != "0" ]; then
42 RETVAL=4
43 return
44 fi
45
46 [ -n "$NFSFSTAB" ] && {
47 [ ! -f /var/lock/subsys/rpcbind ] && service rpcbind start
48 run_cmd "Mounting NFS filesystems" mount -a -t nfs,nfs4
49 }
50
51 [ -n "$CIFSFSTAB" ] && run_cmd "Mounting CIFS filesystems" mount -a -t cifs
52 [ -n "$NCPFSTAB" ] && run_cmd "Mounting NCP filesystems" mount -a -t ncpfs
53
54 [ -n "$NETDEVFSTAB" ] && {
55 if [ -f /etc/mdadm.conf ]; then
56 mdadm -A -s
57 fi
58
59 if [ -f /etc/multipath.conf ] && [ -x /sbin/multipath ]; then
60 modprobe dm-multipath >/dev/null 2>&1
61 /sbin/multipath -v 0
62 if [ -x /sbin/kpartx ]; then
63 /sbin/dmsetup ls --target multipath --exec "/sbin/kpartx -a -p p"
64 fi
65 fi
66
67 if [ -x /sbin/lvm ]; then
68 if /sbin/lvm vgscan > /dev/null 2>&1 ; then
69 run_cmd "Setting up Logical Volume Management" /sbin/lvm vgchange -a y
70 fi
8911a87a 71 fi
3aeae4b7
ER
72
73 if [ -f /etc/crypttab ]; then
74 init_crypto 1
8911a87a 75 fi
3aeae4b7
ER
76
77 show "Checking network-attached filesystems"; started
78 initlog -c "fsck -A -T -R -a -t opts=_netdev"
79 rc=$?
8911a87a 80
3aeae4b7
ER
81 if [ "$rc" -gt 1 ]; then
82 echo
83 echo
84 nls "*** An error occurred during the file system check."
85 nls "*** Dropping you to a shell; the system will reboot"
86 nls "*** when you leave the shell."
87
88 PS1="$(nls '(Repair filesystem)# ')"; export PS1
89 [ "$SELINUX" = "1" ] && disable_selinux
90 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
91 /sbin/sulogin
92 else
93 /bin/sh
94 fi
95 shutdown -r now
8911a87a 96 fi
3aeae4b7
ER
97 }
98
0f929461 99 run_cmd "Mounting other filesystems" mount -a -t nonfs,nfs4,cifs,ncpfs,gfs
3aeae4b7
ER
100
101 touch /var/lock/subsys/netfs
c1ebcbf5
ER
102}
103
104stop() {
3aeae4b7
ER
105 # Unmount loopback stuff first
106 if [ "$(id -u)" != "0" ]; then
107 RETVAL=4
108 return
109 fi
110
8911a87a 111 __umount_loopback_loop
3aeae4b7 112 if [ -n "$NETDEVMTAB" ]; then
8911a87a
AM
113 __umount_loop '$4 ~ /_netdev/ && $2 != "/" {print $2}' \
114 /etc/mtab \
0f929461
AM
115 "$(nls "Unmounting network block filesystems")" \
116 "$(nls "Unmounting network block filesystems (retry)")"
8911a87a 117 fi
3aeae4b7 118 if [ -n "$NFSMTAB" ]; then
8911a87a
AM
119 __umount_loop '$3 ~ /^nfs/ && $3 != "nfsd" && $2 != "/" {print $2}' \
120 /proc/mounts \
0f929461
AM
121 "$(nls "Unmounting NFS filesystems")" \
122 "$(nls "Unmounting NFS filesystems (retry)")" \
8911a87a
AM
123 "-f -l"
124 fi
0f929461
AM
125 [ -n "$CIFSMTAB" ] && run_cmd "Unmounting CIFS filesystems" umount -a -t cifs
126 [ -n "$NCPMTAB" ] && run_cmd "Unmounting NCP filesystems" umount -a -t ncp,ncpfs
8911a87a 127 rm -f /var/lock/subsys/netfs
c1ebcbf5
ER
128}
129
130status() {
3aeae4b7
ER
131 [ -r /var/lock/subsys/netfs ] || RETVAL=3
132
133 if [ ! -f /proc/mounts ]; then
8911a87a 134 nls "/proc filesystem unavailable"
3aeae4b7 135 return
8911a87a 136 fi
c1ebcbf5 137
3aeae4b7
ER
138 [ -n "$NFSFSTAB" ] && {
139 nls "Configured NFS mountpoints: "
140 for fs in $NFSFSTAB; do echo $fs; done
141 }
142 [ -n "$CIFSFSTAB" ] && {
143 nls "Configured CIFS mountpoints: "
144 for fs in $CIFSFSTAB; do echo $fs; done
145 }
146 [ -n "$NCPFSTAB" ] && {
147 nls "Configured NCP mountpoints: "
148 for fs in $NCPFSTAB; do echo $fs; done
149 }
150 [ -n "$NETDEVFSTAB" ] && {
151 nls "Configured network block devices: "
152 for fs in $NETDEVFSTAB; do echo $fs; done
153 }
154 [ -n "$NFSMTAB" ] && {
155 nls "Active NFS mountpoints: "
156 for fs in $NFSMTAB; do echo $fs; done
157 }
158 [ -n "$CIFSMTAB" ] && {
159 nls "Active CIFS mountpoints: "
160 for fs in $CIFSMTAB; do echo $fs; done
161 }
162 [ -n "$NCPMTAB" ] && {
163 nls "Active NCP mountpoints: "
164 for fs in $NCPMTAB; do echo $fs; done
165 }
166 [ -n "$NETDEVMTAB" ] && {
167 nls "Active network block devices: "
168 for fs in $NETDEVMTAB; do echo $fs; done
169 }
c1ebcbf5
ER
170}
171
172RETVAL=0
173# See how we were called.
174case "$1" in
175 start)
176 start
177 ;;
178 stop)
179 stop
180 ;;
181 status)
182 status
8911a87a
AM
183 ;;
184 restart)
c1ebcbf5
ER
185 stop
186 start
8911a87a
AM
187 ;;
188 reload)
c1ebcbf5 189 start
8911a87a
AM
190 ;;
191 *)
b92a94f3 192 msg_usage "$0 {start|stop|restart|reload|status}"
3aeae4b7 193 exit 3
8911a87a
AM
194esac
195
c1ebcbf5 196exit $RETVAL
This page took 0.431855 seconds and 4 git commands to generate.