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

« back to all changes in this revision

Viewing changes to debian/initscripts/etc/init.d/umountnfs.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
1
#! /bin/sh
2
 
#
3
 
# umountnfs     Unmount all network filesystems except the root file system.
4
 
#
5
 
#               Also unmounts all virtual filesystems (proc, devfs,
6
 
#               devpts, usbfs, sysfs) that are not mounted at the
7
 
#               top-level.
8
 
#
9
 
# Version:      @(#)umountnfs  2.85-23  29-Jul-2004  miquels@cistron.nl
10
 
#
11
 
 
12
 
PATH=/sbin:/bin:/usr/sbin:/usr/bin
13
 
 
14
 
KERNEL=`uname -s`
15
 
RELEASE=`uname -r`
 
2
### BEGIN INIT INFO
 
3
# Provides:          umountnfs
 
4
# Required-Start:
 
5
# Required-Stop:     umountfs
 
6
# Should-Stop:       $network $portmap nfs-common
 
7
# Default-Start:
 
8
# Default-Stop:      0 6
 
9
# Short-Description: Unmount all network filesystems except the root fs.
 
10
# Description:       Also unmounts all virtual filesystems (proc, devfs,
 
11
#                    devpts, usbfs, sysfs) that are not mounted at the
 
12
#                    top level.
 
13
### END INIT INFO
 
14
 
 
15
PATH=/sbin:/usr/sbin:/bin:/usr/bin
 
16
KERNEL="$(uname -s)"
 
17
RELEASE="$(uname -r)"
 
18
. /lib/init/vars.sh
 
19
 
 
20
. /lib/lsb/init-functions
16
21
 
17
22
case "${KERNEL}:${RELEASE}" in
18
 
        Linux:[01].*|Linux:2.[01].*)
19
 
                FLAGS=""
20
 
                ;;
21
 
        Linux:2.[23].*|Linux:2.4.?|Linux:2.4.?-*|Linux:2.4.10|Linux:2.4.10-*)
22
 
                FLAGS="-f"
23
 
                ;;
24
 
        *)
25
 
                FLAGS="-f -l"
26
 
                ;;
 
23
  Linux:[01].*|Linux:2.[01].*)
 
24
        FLAGS=""
 
25
        ;;
 
26
  Linux:2.[23].*|Linux:2.4.?|Linux:2.4.?-*|Linux:2.4.10|Linux:2.4.10-*)
 
27
        FLAGS="-f"
 
28
        ;;
 
29
  *)
 
30
        FLAGS="-f -l"
 
31
        ;;
27
32
esac
28
33
 
29
 
# Write a reboot record to /var/log/wtmp before unmounting
30
 
halt -w
31
 
 
32
 
# Remove any .clean files in auto-clean dirs.
33
 
rm -f /tmp/.clean /var/lock/.clean /var/run/.clean
34
 
 
35
 
echo -n "Unmounting remote and non-toplevel virtual filesystems..."
36
 
 
37
 
#
38
 
#       Read mtab file and add the directories we want to
39
 
#       unmount in reverse to a list.
40
 
#
41
 
(
42
 
DIRS=""
43
 
        while read DEV DIR TYPE REST
 
34
do_stop () {
 
35
        # Write a reboot record to /var/log/wtmp before unmounting
 
36
        halt -w
 
37
 
 
38
        # Remove bootclean flag files (precaution against symlink attacks)
 
39
        rm -f /tmp/.clean /var/lock/.clean /var/run/.clean
 
40
 
 
41
        #
 
42
        # Make list of points to unmount in reverse order of their creation
 
43
        #
 
44
 
 
45
        exec 9<&0 </etc/mtab
 
46
 
 
47
        DIRS=""
 
48
        while read DEV MTPT FSTYPE OPTS REST
44
49
        do
45
 
                case "$DIR" in
46
 
                        /|/proc|/dev|/dev/pts|/proc/*|/sys)
47
 
                                continue
48
 
                                ;;
49
 
                esac
50
 
                case "$TYPE" in
51
 
                        nfs|nfs4|smbfs|ncp|ncpfs|cifs|coda)
52
 
                                DIRS="$DIR $DIRS"
53
 
                                ;;
54
 
                        proc|procfs|devfs|devpts|usbfs|usbdevfs|sysfs)
55
 
                                DIRS="$DIR $DIRS"
56
 
                                ;;
 
50
                case "$MTPT" in
 
51
                  /|/proc|/dev|/dev/pts|/dev/shm|/proc/*|/sys|/lib/init/rw)
 
52
                        continue
 
53
                        ;;
 
54
                  /var/run)
 
55
                        if [ yes = "$RAMRUN" ] ; then
 
56
                                continue
 
57
                        fi
 
58
                        ;;
 
59
                  /var/lock)
 
60
                        if [ yes = "$RAMLOCK" ] ; then
 
61
                                continue
 
62
                        fi
 
63
                        ;;
 
64
                esac
 
65
                case "$FSTYPE" in
 
66
                  nfs|nfs4|smbfs|ncp|ncpfs|cifs|coda|ocfs2|gfs)
 
67
                        DIRS="$MTPT $DIRS"
 
68
                        ;;
 
69
                  proc|procfs|linprocfs|devfs|devpts|usbfs|usbdevfs|sysfs)
 
70
                        DIRS="$MTPT $DIRS"
 
71
                        ;;
 
72
                esac
 
73
                case "$OPTS" in
 
74
                  _netdev|*,_netdev|_netdev,*|*,_netdev,*)
 
75
                        DIRS="$MTPT $DIRS"
 
76
                        ;;
57
77
                esac
58
78
        done
59
 
        exec </dev/null
60
 
        if [ -n "$DIRS" ]
 
79
 
 
80
        exec 0<&9 9<&-
 
81
 
 
82
        if [ "$DIRS" ]
61
83
        then
 
84
                [ "$VERBOSE" = no ] || log_action_begin_msg "Unmounting remote and non-toplevel virtual filesystems"
62
85
                umount $FLAGS $DIRS
 
86
                ES=$?
 
87
                [ "$VERBOSE" = no ] || log_action_end_msg $ES
63
88
        fi
64
 
) </etc/mtab
65
 
 
66
 
echo "done."
67
 
 
68
 
: exit 0
 
89
}
 
90
 
 
91
case "$1" in
 
92
  start)
 
93
        # No-op
 
94
        ;;
 
95
  restart|reload|force-reload)
 
96
        echo "Error: argument '$1' not supported" >&2
 
97
        exit 3
 
98
        ;;
 
99
  stop|"")
 
100
        do_stop
 
101
        ;;
 
102
  *)
 
103
        echo "Usage: umountnfs.sh [start|stop]" >&2
 
104
        exit 3
 
105
        ;;
 
106
esac
 
107
 
 
108
: