source: projects/initscripts/tags/initscripts-8.91.3/rc.d/init.d/netfs @ 1108

Revision 1108, 5.5 KB checked in by daisuke, 14 years ago (diff)

import initscripts-8.90.6 from internal cvs repository

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