4 |
- |
1 |
#!/bin/bash
|
|
|
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 |
### BEGIN INIT INFO
|
|
|
13 |
# Provides: $remote_fs
|
|
|
14 |
# Short-Description: Mount and unmount network filesystems.
|
|
|
15 |
# Description: Mount and unmount network filesystems.
|
|
|
16 |
### END INIT INFO
|
|
|
17 |
|
|
|
18 |
[ -f /etc/sysconfig/network ] || exit 0
|
|
|
19 |
. /etc/init.d/functions
|
|
|
20 |
. /etc/sysconfig/network
|
|
|
21 |
|
|
|
22 |
NFSFSTAB=$(LC_ALL=C awk '!/^#/ && $3 ~ /^nfs/ && $3 != "nfsd" && $4 !~ /noauto/ { print $2 }' /etc/fstab)
|
|
|
23 |
CIFSFSTAB=$(LC_ALL=C awk '!/^#/ && $3 == "cifs" && $4 !~ /noauto/ { print $2 }' /etc/fstab)
|
|
|
24 |
NCPFSTAB=$(LC_ALL=C awk '!/^#/ && $3 == "ncpfs" && $4 !~ /noauto/ { print $2 }' /etc/fstab)
|
|
|
25 |
NETDEVFSTAB=$(LC_ALL=C awk '!/^#/ && $4 ~/_netdev/ && $4 !~ /noauto/ { print $1 }' /etc/fstab)
|
|
|
26 |
|
|
|
27 |
NFSMTAB=$(LC_ALL=C awk '$3 ~ /^nfs/ && $3 != "nfsd" && $2 != "/" { print $2 }' /proc/mounts)
|
|
|
28 |
CIFSMTAB=$(LC_ALL=C awk '$3 == "cifs" { print $2 }' /proc/mounts)
|
|
|
29 |
NCPMTAB=$(LC_ALL=C awk '$3 == "ncpfs" { print $2 }' /proc/mounts)
|
|
|
30 |
NETDEVMTAB=$(LC_ALL=C awk '$4 ~ /_netdev/ && $2 != "/" { print $2 }' /etc/mtab)
|
|
|
31 |
|
|
|
32 |
# See how we were called.
|
|
|
33 |
case "$1" in
|
|
|
34 |
start)
|
|
|
35 |
[ ! -f /var/lock/subsys/network ] && ! nm-online -x >/dev/null 2>&1 && exit 0
|
|
|
36 |
[ "$EUID" != "0" ] && exit 4
|
|
|
37 |
[ -n "$NFSFSTAB" ] &&
|
|
|
38 |
{
|
|
|
39 |
[ ! -f /var/lock/subsys/rpcbind ] && service rpcbind start
|
|
|
40 |
echo $"NFS filesystems queued to be mounted"
|
|
|
41 |
}
|
|
|
42 |
[ -n "$CIFSFSTAB" ] && echo $"CIFS filesystems queued to be mounted"
|
|
|
43 |
[ -n "$NCPFSTAB" ] && echo $"NCP filesystems queued to be mounted"
|
|
|
44 |
[ -n "$NETDEVFSTAB" ] &&
|
|
|
45 |
{
|
|
|
46 |
if [ -f /etc/mdadm.conf ] && [ -x /sbin/mdadm ]; then
|
|
|
47 |
/sbin/mdadm -A -s
|
|
|
48 |
fi
|
|
|
49 |
if [ -f /etc/multipath.conf -a -x /sbin/multipath ]; then
|
|
|
50 |
modprobe dm-multipath >/dev/null 2>&1
|
|
|
51 |
/sbin/multipath -v 0
|
|
|
52 |
if [ -x /sbin/kpartx ]; then
|
|
|
53 |
/sbin/dmsetup ls --target multipath --exec "/sbin/kpartx -a -p p"
|
|
|
54 |
fi
|
|
|
55 |
fi
|
|
|
56 |
if [ -x /sbin/lvm ]; then
|
|
|
57 |
if /sbin/lvm vgscan > /dev/null 2>&1 ; then
|
|
|
58 |
action $"Setting up Logical Volume Management:" /sbin/lvm vgchange -a ay
|
|
|
59 |
fi
|
|
|
60 |
fi
|
|
|
61 |
|
|
|
62 |
if [ -f /etc/crypttab ]; then
|
|
|
63 |
init_crypto 1
|
|
|
64 |
fi
|
|
|
65 |
|
|
|
66 |
STRING=$"Checking network-attached filesystems"
|
|
|
67 |
|
|
|
68 |
echo $STRING
|
|
|
69 |
fsck -A -T -M -a -t opts=_netdev
|
|
|
70 |
rc=$?
|
|
|
71 |
|
|
|
72 |
if [ "$rc" -eq "0" ]; then
|
|
|
73 |
success "$STRING"
|
|
|
74 |
echo
|
|
|
75 |
elif [ "$rc" -eq "1" ]; then
|
|
|
76 |
passed "$STRING"
|
|
|
77 |
echo
|
|
|
78 |
fi
|
|
|
79 |
|
|
|
80 |
if [ "$rc" -gt 1 ]; then
|
|
|
81 |
if [ -x /bin/plymouth ] && /bin/plymouth --ping ; then
|
|
|
82 |
/bin/plymouth --hide-splash
|
|
|
83 |
fi
|
|
|
84 |
failure "$STRING"
|
|
|
85 |
tty >/dev/null 2>&1 || exit 1
|
|
|
86 |
echo
|
|
|
87 |
echo
|
|
|
88 |
echo $"*** An error occurred during the file system check."
|
|
|
89 |
echo $"*** Dropping you to a shell; the system will reboot"
|
|
|
90 |
echo $"*** when you leave the shell."
|
|
|
91 |
|
|
|
92 |
str=$"(Repair filesystem)"
|
|
|
93 |
PS1="$str \# # "; export PS1
|
|
|
94 |
[ "$SELINUX" = "1" ] && disable_selinux
|
|
|
95 |
sulogin
|
|
|
96 |
|
|
|
97 |
shutdown -r now
|
|
|
98 |
fi
|
|
|
99 |
}
|
|
|
100 |
touch /var/lock/subsys/netfs
|
|
|
101 |
# The 'no' applies to all listed filesystem types. See mount(8).
|
|
|
102 |
action $"Mounting filesystems: " mount -a -t nogfs2
|
|
|
103 |
;;
|
|
|
104 |
stop)
|
|
|
105 |
# Unmount loopback stuff first
|
|
|
106 |
[ "$EUID" != "0" ] && exit 4
|
|
|
107 |
__umount_loopback_loop
|
|
|
108 |
if [ -n "$NETDEVMTAB" ]; then
|
|
|
109 |
__umount_loop '$4 ~ /_netdev/ && $2 != "/" {print $2}' \
|
|
|
110 |
/etc/mtab \
|
|
|
111 |
$"Unmounting network block filesystems: " \
|
|
|
112 |
$"Unmounting network block filesystems (retry): "
|
|
|
113 |
fi
|
|
|
114 |
if [ -n "$NFSMTAB" ]; then
|
|
|
115 |
__umount_loop '$3 ~ /^nfs/ && $3 != "nfsd" && $2 != "/" {print $2}' \
|
|
|
116 |
/proc/mounts \
|
|
|
117 |
$"Unmounting NFS filesystems: " \
|
|
|
118 |
$"Unmounting NFS filesystems (retry): " \
|
|
|
119 |
"-f -l"
|
|
|
120 |
fi
|
|
|
121 |
[ -n "$CIFSMTAB" ] && action $"Unmounting CIFS filesystems: " umount -a -t cifs
|
|
|
122 |
[ -n "$NCPMTAB" ] && action $"Unmounting NCP filesystems: " umount -a -t ncp,ncpfs
|
|
|
123 |
rm -f /var/lock/subsys/netfs
|
|
|
124 |
;;
|
|
|
125 |
status)
|
|
|
126 |
if [ -f /proc/mounts ] ; then
|
|
|
127 |
[ -n "$NFSFSTAB" ] && {
|
|
|
128 |
echo $"Configured NFS mountpoints: "
|
|
|
129 |
for fs in $NFSFSTAB; do echo $fs ; done
|
|
|
130 |
}
|
|
|
131 |
[ -n "$CIFSFSTAB" ] && {
|
|
|
132 |
echo $"Configured CIFS mountpoints: "
|
|
|
133 |
for fs in $CIFSFSTAB; do echo $fs ; done
|
|
|
134 |
}
|
|
|
135 |
[ -n "$NCPFSTAB" ] && {
|
|
|
136 |
echo $"Configured NCP mountpoints: "
|
|
|
137 |
for fs in $NCPFSTAB; do echo $fs ; done
|
|
|
138 |
}
|
|
|
139 |
[ -n "$NETDEVFSTAB" ] && {
|
|
|
140 |
echo $"Configured network block devices: "
|
|
|
141 |
for fs in $NETDEVFSTAB; do echo $fs ; done
|
|
|
142 |
}
|
|
|
143 |
[ -n "$NFSMTAB" ] && {
|
|
|
144 |
echo $"Active NFS mountpoints: "
|
|
|
145 |
for fs in $NFSMTAB; do echo $fs ; done
|
|
|
146 |
}
|
|
|
147 |
[ -n "$CIFSMTAB" ] && {
|
|
|
148 |
echo $"Active CIFS mountpoints: "
|
|
|
149 |
for fs in $CIFSMTAB; do echo $fs ; done
|
|
|
150 |
}
|
|
|
151 |
[ -n "$NCPMTAB" ] && {
|
|
|
152 |
echo $"Active NCP mountpoints: "
|
|
|
153 |
for fs in $NCPMTAB; do echo $fs ; done
|
|
|
154 |
}
|
|
|
155 |
[ -n "$NETDEVMTAB" ] && {
|
|
|
156 |
echo $"Active network block devices: "
|
|
|
157 |
for fs in $NETDEVMTAB; do echo $fs ; done
|
|
|
158 |
}
|
|
|
159 |
else
|
|
|
160 |
echo $"/proc filesystem unavailable"
|
|
|
161 |
fi
|
|
|
162 |
[ -r /var/lock/subsys/netfs ] || exit 3
|
|
|
163 |
;;
|
|
|
164 |
restart)
|
|
|
165 |
$0 stop
|
|
|
166 |
$0 start
|
|
|
167 |
exit $?
|
|
|
168 |
;;
|
|
|
169 |
reload)
|
|
|
170 |
$0 start
|
|
|
171 |
exit $?
|
|
|
172 |
;;
|
|
|
173 |
*)
|
|
|
174 |
echo $"Usage: $0 {start|stop|restart|reload|status}"
|
|
|
175 |
exit 2
|
|
|
176 |
esac
|
|
|
177 |
|
|
|
178 |
exit 0
|