home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / etc / network / if-up.d / mountnfs < prev    next >
Encoding:
Text File  |  2006-10-06  |  3.1 KB  |  136 lines

  1. #! /bin/sh
  2. # Description:       Now that TCP/IP is configured, mount the NFS file
  3. #                    systems in /etc/fstab if needed. If possible,
  4. #                    start the portmapper before mounting (this is needed for
  5. #                    Linux 2.1.x and up).
  6. #
  7. #                    Also mounts SMB filesystems now, so the name of
  8. #                    this script is getting increasingly inaccurate.
  9.  
  10. PATH=/sbin:/bin
  11. . /lib/init/vars.sh
  12.  
  13. . /lib/lsb/init-functions
  14. . /lib/init/mount-functions.sh
  15.  
  16. do_start() {
  17.     [ -f /etc/fstab ] || return
  18.     #
  19.     # Read through fstab line by line. If it is NFS, set the flag
  20.     # for mounting NFS file systems. If any NFS partition is found and it
  21.     # not mounted with the nolock option, we start the portmapper.
  22.     # 
  23.     # If any sec={krb5,krb5i,krb5p} option is given, or any of the file
  24.     # systems are nfs4, we'll need to start rpc.gssd and/or rpc.idmapd too;
  25.     # we'll leave that to nfs-common.
  26.     #
  27.  
  28.     exec 9<&0 </etc/fstab
  29.  
  30.     portmap=no
  31.     gss_or_idmap=no
  32.     while read DEV MTPT FSTYPE OPTS REST
  33.     do
  34.         case "$DEV" in
  35.           ""|\#*)
  36.             continue
  37.             ;;
  38.         esac
  39.         case "$OPTS" in
  40.           noauto|*,noauto|noauto,*|*,noauto,*)
  41.             continue
  42.             ;;
  43.         esac
  44.         case "$FSTYPE" in
  45.           nfs|nfs4)
  46.             case "$OPTS" in
  47.               nolock|*,nolock|nolock,*|*,nolock,*)
  48.                 ;;
  49.               *)
  50.                 portmap=yes
  51.                 ;;
  52.             esac
  53.             case "$OPTS" in
  54.               sec=krb5|*,sec=krb5|sec=krb5,*|*,sec=krb5i,*|sec=krb5i|*,sec=krb5i|sec=krb5i,*|*,sec=krb5i,*|sec=krb5p|*,sec=krb5p|sec=krb5p,*|*,sec=krb5p,*)
  55.                   gss_or_idmap=yes
  56.                 ;;
  57.             esac
  58.             ;;
  59.           smbfs|cifs|coda|ncp|ncpfs|ocfs2|gfs)
  60.             ;;
  61.           *)
  62.             FSTYPE=
  63.             ;;
  64.         esac
  65.         if [ "$FSTYPE" ]
  66.         then
  67.             case "$NETFS" in
  68.               $FSTYPE|*,$FSTYPE|$FSTYPE,*|*,$FSTYPE,*)
  69.                 ;;
  70.               *)
  71.                 NETFS="$NETFS${NETFS:+,}$FSTYPE"
  72.                 ;;
  73.             esac
  74.         fi
  75.         if [ "$FSTYPE" = "nfs4" ]
  76.         then
  77.             gss_or_idmap=yes
  78.         fi
  79.     done
  80.  
  81.     exec 0<&9 9<&-
  82.  
  83.     #
  84.     # With contemporary portmap packages it is no longer necessary
  85.     # to start portmap here because the package has its own initscript.
  86.     # This code will disappear after etch.
  87.     #
  88.     if [ "$portmap" = yes ]
  89.     then
  90.         if [ -x /sbin/portmap ] && ! pidof portmap >/dev/null 2>&1
  91.         then
  92.             if [ -x /etc/init.d/portmap ] 
  93.             then
  94.                 /etc/init.d/portmap start
  95.             else
  96.                 start-stop-daemon --start --quiet --oknodo --exec /sbin/portmap
  97.                 sleep 1  # FIXME: Actually synchronize with the process?
  98.             fi
  99.         fi
  100.     fi
  101.  
  102.     #
  103.     # Initialize nfs-common (which starts rpc.gssd and/or rpc.idmapd, and loads
  104.     # the right kernel modules if applicable) if we use Kerberos and/or NFSv4 mounts.
  105.     #
  106.     if [ "$gss_or_idmap" = yes ] && [ -x /etc/init.d/nfs-common ]
  107.     then
  108.         /etc/init.d/nfs-common start
  109.     fi
  110.  
  111.     if [ "$NETFS" ]
  112.     then
  113.         mount_all_nfs() { mount -a -t$NETFS ; }
  114.         
  115.         # Accept 64 or 96 (32/mount failure + 64/some mount succeeded)
  116.         # as valid return statuses from mount.  This partly works around
  117.         # the problem of mount reporting an error status when
  118.         # some filesystems are already mounted.
  119.  
  120.         pre_mountall
  121.         mount_all_nfs
  122.         post_mountall
  123.     fi
  124. }
  125.  
  126.  
  127. # Not for loopback!
  128. [ "$IFACE" != "lo" ] || exit 0
  129.  
  130. # Lock around this otherwise insanity may occur
  131. mkdir /var/run/network/mountnfs 2>/dev/null || exit 0
  132.  
  133. do_start
  134.  
  135. rmdir /var/run/network/mountnfs 2>/dev/null || exit 0
  136.