]> git.pld-linux.org Git - projects/rc-scripts.git/blame - rc.d/init.d/netfs
- better umount on stop
[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
14. /etc/init.d/functions
15. /etc/sysconfig/network
16
26b0394a
AM
17# nfs uses own script for that
18if [ ! -f /etc/rc.d/init.d/nfsfs ]; then
19 NFSFSTAB=$(LC_ALL=C awk '!/^#/ && $3 ~ /^nfs/ && $3 != "nfsd" && $4 !~ /noauto/ { print $2 }' /etc/fstab)
20 NFSMTAB=$(LC_ALL=C awk '$3 ~ /^nfs/ && $3 != "nfsd" && $2 != "/" { print $2 }' /proc/mounts)
21fi
22
8911a87a
AM
23CIFSFSTAB=$(LC_ALL=C awk '!/^#/ && $3 == "cifs" && $4 !~ /noauto/ { print $2 }' /etc/fstab)
24NCPFSTAB=$(LC_ALL=C awk '!/^#/ && $3 == "ncpfs" && $4 !~ /noauto/ { print $2 }' /etc/fstab)
25NETDEVFSTAB=$(LC_ALL=C awk '!/^#/ && $4 ~/_netdev/ && $4 !~ /noauto/ { print $1 }' /etc/fstab)
26
27NFSMTAB=$(LC_ALL=C awk '$3 ~ /^nfs/ && $3 != "nfsd" && $2 != "/" { print $2 }' /proc/mounts)
28CIFSMTAB=$(LC_ALL=C awk '$3 == "cifs" { print $2 }' /proc/mounts)
29NCPMTAB=$(LC_ALL=C awk '$3 == "ncpfs" { print $2 }' /proc/mounts)
30NETDEVMTAB=$(LC_ALL=C awk '$4 ~ /_netdev/ && $2 != "/" { print $2 }' /etc/mtab)
31
32# See how we were called.
33case "$1" in
34 start)
35 [ ! -f /var/lock/subsys/network ] && exit 0
36 [ "$EUID" != "0" ] && exit 4
37 [ -n "$NFSFSTAB" ] &&
38 {
39 [ ! -f /var/lock/subsys/rpcbind ] && service rpcbind start
40 run_cmd "Mounting NFS filesystems: " mount -a -t nfs,nfs4
41 }
42 [ -n "$CIFSFSTAB" ] && run_cmd "Mounting CIFS filesystems: " mount -a -t cifs
43 [ -n "$NCPFSTAB" ] && run_cmd "Mounting NCP filesystems: " mount -a -t ncpfs
44 [ -n "$NETDEVFSTAB" ] &&
45 {
46 if [ -f /etc/mdadm.conf ]; then
47 mdadm -A -s
48 fi
49 if [ -f /etc/multipath.conf ] && [ -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 run_cmd "Setting up Logical Volume Management:" /sbin/lvm vgchange -a y
59 fi
60 fi
61
62 if [ -f /etc/crypttab ]; then
63 init_crypto 1
64 fi
65
66 show "Checking network-attached filesystems"; started
67 initlog -c "fsck -A -T -R -a -t opts=_netdev"
68 rc=$?
69
70 if [ "$rc" -gt 1 ]; then
71 echo
72 echo
73 nls "*** An error occurred during the file system check."
74 nls "*** Dropping you to a shell; the system will reboot"
75 nls "*** when you leave the shell."
76
77 PS1="$(nls '(Repair filesystem)# ')"; export PS1
78 [ "$SELINUX" = "1" ] && disable_selinux
79 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
80 /sbin/sulogin
81 else
82 /bin/sh
83 fi
84 shutdown -r now
85 fi
86 }
87 touch /var/lock/subsys/netfs
88 run_cmd "Mounting other filesystems: " mount -a -t nonfs,nfs4,cifs,ncpfs,gfs
89 ;;
90 stop)
91 # Unmount loopback stuff first
5b476959 92 [ "$(id -u)" != "0" ] && exit 4
8911a87a
AM
93 __umount_loopback_loop
94 if [ -n "$NETDEVMTAB" ]; then
95 __umount_loop '$4 ~ /_netdev/ && $2 != "/" {print $2}' \
96 /etc/mtab \
5b476959
AM
97 "$(nls "Unmounting network block filesystems: ")" \
98 "$(nls "Unmounting network block filesystems (retry): ")"
8911a87a
AM
99 fi
100 if [ -n "$NFSMTAB" ]; then
101 __umount_loop '$3 ~ /^nfs/ && $3 != "nfsd" && $2 != "/" {print $2}' \
102 /proc/mounts \
5b476959
AM
103 "$(nls "Unmounting NFS filesystems: ")" \
104 "$(nls "Unmounting NFS filesystems (retry): ")" \
8911a87a
AM
105 "-f -l"
106 fi
107 [ -n "$CIFSMTAB" ] && run_cmd "Unmounting CIFS filesystems: " umount -a -t cifs
108 [ -n "$NCPMTAB" ] && run_cmd "Unmounting NCP filesystems: " umount -a -t ncp,ncpfs
109 rm -f /var/lock/subsys/netfs
110 ;;
111 status)
112 if [ -f /proc/mounts ] ; then
113 [ -n "$NFSFSTAB" ] && {
114 nls "Configured NFS mountpoints: "
115 for fs in $NFSFSTAB; do echo $fs ; done
116 }
117 [ -n "$CIFSFSTAB" ] && {
118 nls "Configured CIFS mountpoints: "
119 for fs in $CIFSFSTAB; do echo $fs ; done
120 }
121 [ -n "$NCPFSTAB" ] && {
122 nls "Configured NCP mountpoints: "
123 for fs in $NCPFSTAB; do echo $fs ; done
124 }
125 [ -n "$NETDEVFSTAB" ] && {
126 nls "Configured network block devices: "
127 for fs in $NETDEVFSTAB; do echo $fs ; done
128 }
129 [ -n "$NFSMTAB" ] && {
130 nls "Active NFS mountpoints: "
131 for fs in $NFSMTAB; do echo $fs ; done
132 }
133 [ -n "$CIFSMTAB" ] && {
134 nls "Active CIFS mountpoints: "
135 for fs in $CIFSMTAB; do echo $fs ; done
136 }
137 [ -n "$NCPMTAB" ] && {
138 nls "Active NCP mountpoints: "
139 for fs in $NCPMTAB; do echo $fs ; done
140 }
141 [ -n "$NETDEVMTAB" ] && {
142 nls "Active network block devices: "
143 for fs in $NETDEVMTAB; do echo $fs ; done
144 }
145 else
146 nls "/proc filesystem unavailable"
147 fi
148 [ -r /var/lock/subsys/netfs ] || exit 3
149 ;;
150 restart)
151 $0 stop
152 $0 start
153 exit $?
154 ;;
155 reload)
156 $0 start
157 exit $?
158 ;;
159 *)
160 echo $"Usage: $0 {start|stop|restart|reload|status}"
161 exit 2
162esac
163
164exit 0
This page took 0.037799 seconds and 4 git commands to generate.