Advertisement
that0n3guy

earlynetfs

Aug 7th, 2013
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.25 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # earlynetfs         Mount network filesystems.
  4. #
  5. # This is a modification of /etc/init.d/netfs in XCP 1.6 (centos)
  6. # Authors:  Copied from Bill Nottingham <notting@redhat.com>
  7. #       AJ Lewis <alewis@redhat.com>
  8. #       Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
  9. #
  10. # chkconfig: 345 25 06
  11. # description: Unmounts all Network File System (NFS), \
  12. #      used when you need to unmount NFS before you disable the NFS server \
  13. #      in case you are mounting nfs on the same server as you are exporting (xen for instance) \
  14. #      I don't think this would work on debian/ubuntu systems...
  15. ### BEGIN INIT INFO
  16. # Provides: $local_fs $remote_fs
  17. ### END INIT INFO
  18.  
  19. [ -f /etc/sysconfig/network ] || exit 0
  20. . /etc/init.d/functions
  21. . /etc/sysconfig/network
  22.  
  23. # Check that networking is up.
  24. [ "${NETWORKING}" = "no" ] && exit 0
  25.  
  26. NFSFSTAB=`LC_ALL=C awk '!/^#/ && $3 ~ /^nfs/ && $3 != "nfsd" && $4 !~ /noauto/ { print $2 }' /etc/fstab`
  27.  
  28. NFSMTAB=`LC_ALL=C awk '$3 ~ /^nfs/ && $3 != "nfsd" && $2 != "/" { print $2 }' /proc/mounts`
  29.  
  30.  
  31. # See how we were called.
  32. case "$1" in
  33.   start)
  34.     # Let udev handle any backlog before trying to mount file systems
  35.  
  36.     touch /var/lock/subsys/earlynetfs
  37.     # The 'no' applies to all listed filesystem types. See mount(8).
  38.     action $"EarlyNetFS doing nothing on start(thats good): "
  39.     ;;
  40.   stop)
  41.         # Unmount loopback stuff first
  42.     __umount_loopback_loop
  43.     __umount_blktap_loop
  44.     if [ -n "$NFSMTAB" ]; then
  45.         __umount_loop '$3 ~ /^nfs/ && $3 != "nfsd" && $2 != "/" {print $2}' \
  46.             /proc/mounts \
  47.             $"Unmounting NFS(early) filesystems: " \
  48.             $"Unmounting NFS(early) filesystems (retry): " \
  49.             "-f -l"
  50.     fi
  51.  
  52.     rm -f /var/lock/subsys/earlynetfs
  53.     ;;
  54.   status)
  55.     if [ -f /proc/mounts ] ; then
  56.         [ -n "$NFSFSTAB" ] && {
  57.              echo $"Configured NFS mountpoints: "
  58.              for fs in $NFSFSTAB; do echo $fs ; done
  59.         }
  60.         [ -n "$NFSMTAB" ] && {
  61.                       echo $"Active NFS mountpoints: "
  62.               for fs in $NFSMTAB; do echo $fs ; done
  63.         }
  64.     else
  65.         echo $"/proc filesystem unavailable"
  66.     fi
  67.     [ -r /var/lock/subsys/earlynetfs ] || exit 2
  68.     ;;
  69.   restart)
  70.     $0 stop
  71.     $0 start
  72.     ;;
  73.   reload)
  74.         $0 start
  75.     ;;
  76.   *)
  77.     echo $"Usage: $0 {start|stop|restart|reload|status}"
  78.     exit 1
  79. esac
  80.  
  81. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement