~ubuntu-branches/debian/experimental/sysvinit/experimental

« back to all changes in this revision

Viewing changes to debian/initscripts/etc/init.d/mountnfs.sh

  • Committer: Bazaar Package Importer
  • Author(s): Petter Reinholdtsen
  • Date: 2008-08-12 16:07:50 UTC
  • Revision ID: james.westby@ubuntu.com-20080812160750-65gpyv74vh4qr69w
Tags: 2.86.ds1-61
* Fix typo in rcS(5), proberly->properly (Closes: #484233).  Thanks to
  Julien Danjou for noticing.
* Fix typo in rcS(5), maually->manually (Closes: #493680).  Thanks to
  Xr for noticing.
* Modify runlevel detection code in invoke-rc.d to notice the
  difference between runlevels 0 and 6, and the boot runlevel, to
  make it possible to use invoke-rc.d during boot (Closes: 384509).
* Make sure to call restorecon after mounting tmpfs file systems, to
  set SELinux permissions (Closes: #493679).  Patch from Russell
  Coker.
* Move responsibility of stopping the splash screen process from
  individual init.d scripts to init.d/rc.  This make sure the
  progress calculation reflect reality, and that the splash screen
  is taken down in runlevel 1 (Closes: #431560) and that it stop
  before gdm and kdm (Closes: #422922, #489734).
* Skip error message from checkfs.sh when / is read-only.  Patch
  from Mirek Slugen (Closes: #492214).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#
2
 
# mountnfs.sh   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
 
# Version:      @(#)mountnfs.sh  2.86-5  10-Sep-2004  miquels@cistron.nl
11
 
#
12
 
 
13
 
VERBOSE=yes
14
 
TMPTIME=0
15
 
[ -f /etc/default/rcS ] && . /etc/default/rcS
16
 
. /etc/init.d/bootclean.sh
17
 
 
18
 
#
19
 
#       Run in a subshell because of I/O redirection.
20
 
#
21
 
test -f /etc/fstab && (
22
 
 
23
 
#
24
 
#       Read through fstab line by line. If it is NFS, set the flag
25
 
#       for mounting NFS file systems. If any NFS partition is found and it
26
 
#       not mounted with the nolock option, we start the portmapper.
27
 
#
28
 
portmap=no
29
 
while read device mountpt fstype options
30
 
do
31
 
        case "$device" in
32
 
                ""|\#*)
33
 
                        continue
34
 
                        ;;
35
 
        esac
36
 
 
37
 
        case "$options" in
38
 
                *noauto*)
39
 
                        continue
40
 
                        ;;
41
 
        esac
42
 
 
43
 
        case "$fstype" in
44
 
                nfs|nfs4)
45
 
                        case "$options" in
46
 
                                *nolock*)
47
 
                                        ;;
48
 
                                *)
49
 
                                        portmap=yes
50
 
                                        ;;
51
 
                        esac
52
 
                        ;;
53
 
                smbfs|cifs|coda|ncp|ncpfs)
54
 
                        ;;
55
 
                *)
56
 
                        fstype=
57
 
                        ;;
58
 
        esac
59
 
        if [ -n "$fstype" ]
60
 
        then
61
 
                case "$NETFS" in
62
 
                        $fstype|*,$fstype|$fstype,*|*,$fstype,*)
63
 
                                ;;
64
 
                        *)
65
 
                                NETFS="$NETFS${NETFS:+,}$fstype"
66
 
                                ;;
67
 
                esac
68
 
        fi
69
 
done
70
 
 
71
 
exec 0>&1
72
 
 
73
 
if [ "$portmap" = yes ]
74
 
then
75
 
        if [ -x /sbin/portmap ]
76
 
        then
77
 
                echo -n "Starting portmapper..."
78
 
                start-stop-daemon --start --quiet --exec /sbin/portmap
79
 
                sleep 2
80
 
        fi
81
 
fi
82
 
 
83
 
if [ -n "$NETFS" ]
84
 
then
85
 
        echo "Mounting remote filesystems..."
86
 
        mount -a -t$NETFS
87
 
fi
88
 
 
89
 
) < /etc/fstab
90
 
 
91
 
#
92
 
#       Clean /tmp, /var/lock, /var/run
93
 
#
94
 
bootclean mountnfs
 
1
#! /bin/sh
 
2
### BEGIN INIT INFO
 
3
# Provides:          mountnfs
 
4
# Required-Start:    $local_fs
 
5
# Required-Stop:
 
6
# Should-Start:      $network $portmap nfs-common  udev-mtab
 
7
# Default-Start:     S
 
8
# Default-Stop:
 
9
# Short-Description: Wait for network file systems to be mounted
 
10
# Description:       Network file systems are mounted by
 
11
#                    /etc/network/if-up.d/mountnfs in the background
 
12
#                    when interfaces are brought up; this script waits
 
13
#                    for them to be mounted before carrying on.
 
14
### END INIT INFO
 
15
 
 
16
. /lib/init/vars.sh
 
17
. /lib/lsb/init-functions
 
18
 
 
19
do_wait_async_mount() {
 
20
        [ -f /etc/fstab ] || return
 
21
        #
 
22
        # Read through fstab line by line. If it is NFS, set the flag
 
23
        # for mounting NFS file systems. If any NFS partition is found
 
24
        # then wait around for it.
 
25
        #
 
26
 
 
27
        exec 9<&0 </etc/fstab
 
28
 
 
29
        waitnfs=
 
30
        while read DEV MTPT FSTYPE OPTS REST
 
31
        do
 
32
                case "$DEV" in
 
33
                  ""|\#*)
 
34
                        continue
 
35
                        ;;
 
36
                esac
 
37
                case "$OPTS" in
 
38
                  noauto|*,noauto|noauto,*|*,noauto,*)
 
39
                        continue
 
40
                        ;;
 
41
                esac
 
42
                case "$FSTYPE" in
 
43
                  nfs|nfs4|smbfs|cifs|coda|ncp|ncpfs|ocfs2|gfs)
 
44
                        ;;
 
45
                  *)
 
46
                        continue
 
47
                        ;;
 
48
                esac
 
49
                case "$MTPT" in
 
50
                  /usr/local|/usr/local/*)
 
51
                        ;;
 
52
                  /usr|/usr/*)
 
53
                        waitnfs="$waitnfs $MTPT"
 
54
                        ;;
 
55
                  /var|/var/*)
 
56
                        waitnfs="$waitnfs $MTPT"
 
57
                        ;;
 
58
                esac
 
59
        done
 
60
 
 
61
        exec 0<&9 9<&-
 
62
 
 
63
        # Wait for each path, the timeout is for all of them as that's
 
64
        # really the maximum time we have to wait anyway
 
65
        TIMEOUT=900
 
66
        for mountpt in $waitnfs; do
 
67
                log_action_begin_msg "Waiting for $mountpt"
 
68
 
 
69
                while ! mountpoint -q $mountpt; do
 
70
                        sleep 0.1
 
71
 
 
72
                        TIMEOUT=$(( $TIMEOUT - 1 ))
 
73
                        if [ $TIMEOUT -le 0 ]; then
 
74
                                log_action_end_msg 1
 
75
                                break
 
76
                        fi
 
77
                done
 
78
 
 
79
                if [ $TIMEOUT -gt 0 ]; then
 
80
                        log_action_end_msg 0
 
81
                fi
 
82
        done
 
83
}
 
84
 
 
85
case "$1" in
 
86
    start)
 
87
        # Using 'no !=' instead of 'yes =' to make sure async nfs
 
88
        # mounting is the default even without a value in
 
89
        # /etc/default/rcS
 
90
        if [ no != "$ASYNCMOUNTNFS" ] ; then
 
91
                do_wait_async_mount
 
92
        else
 
93
                FROMINITD=yes /etc/network/if-up.d/mountnfs
 
94
        fi
 
95
        ;;
 
96
    restart|reload|force-reload)
 
97
        echo "Error: argument '$1' not supported" >&2
 
98
        exit 3
 
99
        ;;
 
100
    stop)
 
101
        ;;
 
102
    *)
 
103
        echo "Usage: $0 start|stop" >&2
 
104
        exit 3
 
105
        ;;
 
106
esac
95
107
 
96
108
: exit 0
97