~ubuntu-branches/ubuntu/natty/sysvinit/natty-proposed

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Scott James Remnant
  • Date: 2009-09-15 02:45:59 UTC
  • Revision ID: james.westby@ubuntu.com-20090915024559-2bv3ihsb0cu9xw2c
Tags: 2.87dsf-4ubuntu3
FFE LP: #427356.

* Various initscripts have been replaced by Upstart jobs shipped in
  other packages, the following have been removed:
  - hostname.sh
  - mountkernfs.sh
  - mountdevsubfs.sh
  - checkroot.sh
  - mtab.sh
  - checkfs.sh
  - mountall.sh
  - mountall-bootclean.sh
  - mountoverflowtmp
  - mountnfs.sh
  - mountnfs-bootclean.sh
  - bootmisc.sh
  - bootlogs
  - rmnlogin

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /bin/sh
2
 
### BEGIN INIT INFO
3
 
# Provides:          checkfs
4
 
# Required-Start:    checkroot
5
 
# Required-Stop:
6
 
# Should-Start:      mtab cryptdisks
7
 
# Default-Start:     S
8
 
# Default-Stop:
9
 
# X-Interactive:     true
10
 
# Short-Description: Check all filesystems.
11
 
### END INIT INFO
12
 
 
13
 
# Include /usr/bin in path to find on_ac_power if /usr/ is on the root
14
 
# partition.
15
 
PATH=/sbin:/bin:/usr/bin
16
 
FSCK_LOGFILE=/var/log/fsck/checkfs
17
 
[ "$FSCKFIX" ] || FSCKFIX=no
18
 
. /lib/init/vars.sh
19
 
 
20
 
. /lib/lsb/init-functions
21
 
. /lib/init/splash-functions-base
22
 
. /lib/init/usplash-fsck-functions.sh
23
 
 
24
 
do_start () {
25
 
        # See if we're on AC Power.  If not, we're not gonna run our
26
 
        # check.  If on_ac_power (in /usr/) is unavailable, behave as
27
 
        # before and check all file systems needing it.
28
 
 
29
 
# Disabled AC power check until fsck can be told to only check the
30
 
# file system if it is corrupt when running on battery. (bug #526398)
31
 
#       if which on_ac_power >/dev/null 2>&1
32
 
#       then
33
 
#               on_ac_power >/dev/null 2>&1
34
 
#               if [ $? -eq 1 ]
35
 
#               then
36
 
#                       [ "$VERBOSE" = no ] || log_success_msg "Running on battery power, so skipping file system check."
37
 
#                       BAT=yes
38
 
#               fi
39
 
#       fi
40
 
        BAT=""
41
 
        fscheck="yes"
42
 
 
43
 
        if [ -f /fastboot ] || grep -s -w -i "fastboot" /proc/cmdline
44
 
        then
45
 
                [ "$fscheck" = yes ] && log_warning_msg "Fast boot enabled, so skipping file system check."
46
 
                fscheck=no
47
 
        fi
48
 
 
49
 
        #
50
 
        # Check the rest of the file systems.
51
 
        #
52
 
        if [ "$fscheck" = yes ] && [ ! "$BAT" ] && [ "$FSCKTYPES" != "none" ]
53
 
        then
54
 
                if [ -f /forcefsck ] || grep -s -w -i "forcefsck" /proc/cmdline
55
 
                then
56
 
                        force="-f"
57
 
                else
58
 
                        force=""
59
 
                fi
60
 
                if [ "$FSCKFIX" = yes ]
61
 
                then
62
 
                        fix="-y"
63
 
                else
64
 
                        fix="-a"
65
 
                fi
66
 
                spinner="-C"
67
 
                case "$TERM" in
68
 
                  dumb|network|unknown|"")
69
 
                        spinner=""
70
 
                        ;;
71
 
                esac
72
 
                [ "$(uname -m)" = s390 ] && spinner=""  # This should go away
73
 
                FSCKTYPES_OPT=""
74
 
                [ "$FSCKTYPES" ] && FSCKTYPES_OPT="-t $FSCKTYPES"
75
 
                handle_failed_fsck() {
76
 
                        log_failure_msg "File system check failed. 
77
 
A log is being saved in ${FSCK_LOGFILE} if that location is writable. 
78
 
Please repair the file system manually."
79
 
                        log_warning_msg "A maintenance shell will now be started. 
80
 
CONTROL-D will terminate this shell and resume system boot."
81
 
                        # Start a single user shell on the console
82
 
                        if ! sulogin $CONSOLE
83
 
                        then
84
 
                                log_failure_msg "Attempt to start maintenance shell failed. 
85
 
Continuing with system boot in 5 seconds."
86
 
                                sleep 5
87
 
                        fi
88
 
                }
89
 
                if [ "$VERBOSE" = no ]
90
 
                then
91
 
                        log_action_begin_msg "Checking file systems"
92
 
                        if usplash_running; then
93
 
                            PROGRESS_FILE=`mktemp` || exit 1
94
 
                            set -m
95
 
                            logsave -s $FSCK_LOGFILE fsck -C3 -R -A $fix $force $FSCKTYPES_OPT >/dev/console 2>&1 3>$PROGRESS_FILE &
96
 
                            set +m
97
 
                            usplash_progress "$PROGRESS_FILE"
98
 
                            rm -f $PROGRESS_FILE
99
 
                        else
100
 
                            splash_start_indefinite
101
 
                            logsave -s $FSCK_LOGFILE fsck $spinner -R -A $fix $force $FSCKTYPES_OPT
102
 
                            FSCKCODE=$?
103
 
                            splash_stop_indefinite
104
 
                        fi
105
 
 
106
 
                        if [ "$FSCKCODE" -gt 1 ]
107
 
                        then
108
 
                                log_action_end_msg 1 "code $FSCKCODE"
109
 
                                handle_failed_fsck
110
 
                        else
111
 
                                log_action_end_msg 0
112
 
                        fi
113
 
                else
114
 
                        if [ "$FSCKTYPES" ]
115
 
                        then
116
 
                                log_action_msg "Will now check all file systems of types $FSCKTYPES"
117
 
                        else
118
 
                                log_action_msg "Will now check all file systems"
119
 
                        fi
120
 
                        splash_start_indefinite
121
 
                        logsave -s $FSCK_LOGFILE fsck $spinner -V -R -A $fix $force $FSCKTYPES_OPT
122
 
                        FSCKCODE=$?
123
 
                        splash_stop_indefinite
124
 
                        if [ "$FSCKCODE" -gt 1 ]
125
 
                        then
126
 
                                handle_failed_fsck
127
 
                        else
128
 
                                log_success_msg "Done checking file systems. 
129
 
A log is being saved in ${FSCK_LOGFILE} if that location is writable."
130
 
                        fi
131
 
                fi
132
 
        fi
133
 
        rm -f /fastboot /forcefsck 2>/dev/null
134
 
}
135
 
 
136
 
case "$1" in
137
 
  start|"")
138
 
        do_start
139
 
        ;;
140
 
  restart|reload|force-reload)
141
 
        echo "Error: argument '$1' not supported" >&2
142
 
        exit 3
143
 
        ;;
144
 
  stop)
145
 
        # No-op
146
 
        ;;
147
 
  *)
148
 
        echo "Usage: checkfs.sh [start|stop]" >&2
149
 
        exit 3
150
 
        ;;
151
 
esac
152
 
 
153
 
: