Subversion Repositories configs

Rev

Rev 3 | Rev 33 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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