summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/initscripts/initscripts-1.0/checkroot.sh
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2010-08-27 15:14:24 +0100
committerRichard Purdie <rpurdie@linux.intel.com>2010-08-27 15:29:45 +0100
commit29d6678fd546377459ef75cf54abeef5b969b5cf (patch)
tree8edd65790e37a00d01c3f203f773fe4b5012db18 /meta/recipes-core/initscripts/initscripts-1.0/checkroot.sh
parentda49de6885ee1bc424e70bc02f21f6ab920efb55 (diff)
downloadpoky-29d6678fd546377459ef75cf54abeef5b969b5cf.tar.gz
Major layout change to the packages directory
Having one monolithic packages directory makes it hard to find things and is generally overwhelming. This commit splits it into several logical sections roughly based on function, recipes.txt gives more information about the classifications used. The opportunity is also used to switch from "packages" to "recipes" as used in OpenEmbedded as the term "packages" can be confusing to people and has many different meanings. Not all recipes have been classified yet, this is just a first pass at separating things out. Some packages are moved to meta-extras as they're no longer actively used or maintained. Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'meta/recipes-core/initscripts/initscripts-1.0/checkroot.sh')
-rwxr-xr-xmeta/recipes-core/initscripts/initscripts-1.0/checkroot.sh137
1 files changed, 137 insertions, 0 deletions
diff --git a/meta/recipes-core/initscripts/initscripts-1.0/checkroot.sh b/meta/recipes-core/initscripts/initscripts-1.0/checkroot.sh
new file mode 100755
index 0000000000..02697ce9bf
--- /dev/null
+++ b/meta/recipes-core/initscripts/initscripts-1.0/checkroot.sh
@@ -0,0 +1,137 @@
1### BEGIN INIT INFO
2# Provides: checkroot
3# Required-Start: udev
4# Required-Stop:
5# Default-Start: S
6# Default-Stop:
7# Short-Description: Check to root file system.
8### END INIT INFO
9
10. /etc/default/rcS
11
12#
13# Set SULOGIN in /etc/default/rcS to yes if you want a sulogin to be spawned
14# from this script *before anything else* with a timeout, like SCO does.
15#
16test "$SULOGIN" = yes && sulogin -t 30 $CONSOLE
17
18#
19# Read /etc/fstab.
20#
21exec 9< /etc/fstab
22rootmode=rw
23rootopts=rw
24rootcheck=no
25swap_on_md=no
26devfs=
27while read fs mnt type opts dump pass junk <&9
28do
29 case "$fs" in
30 ""|\#*)
31 continue;
32 ;;
33 /dev/md*)
34 # Swap on md device.
35 test "$type" = swap && swap_on_md=yes
36 ;;
37 /dev/*)
38 ;;
39 *)
40 # Might be a swapfile.
41 test "$type" = swap && swap_on_md=yes
42 ;;
43 esac
44 test "$type" = devfs && devfs="$fs"
45 test "$mnt" != / && continue
46 rootopts="$opts"
47 test "$pass" = 0 -o "$pass" = "" && rootcheck=no
48 case "$opts" in
49 ro|ro,*|*,ro|*,ro,*)
50 rootmode=ro
51 ;;
52 esac
53done
54exec 0>&9 9>&-
55
56#
57# Activate the swap device(s) in /etc/fstab. This needs to be done
58# before fsck, since fsck can be quite memory-hungry.
59#
60test "$VERBOSE" != no && echo "Activating swap"
61swapon -a 2> /dev/null
62
63#
64# Check the root filesystem.
65#
66if test -f /fastboot || test $rootcheck = no
67then
68 test $rootcheck = yes && echo "Fast boot, no filesystem check"
69else
70 #
71 # Ensure that root is quiescent and read-only before fsck'ing.
72 #
73 mount -n -o remount,ro /
74 if test $? = 0
75 then
76 if test -f /forcefsck
77 then
78 force="-f"
79 else
80 force=""
81 fi
82 if test "$FSCKFIX" = yes
83 then
84 fix="-y"
85 else
86 fix="-a"
87 fi
88 spinner="-C"
89 case "$TERM" in
90 dumb|network|unknown|"") spinner="" ;;
91 esac
92 test `uname -m` = s390 && spinner="" # This should go away
93 test "$VERBOSE" != no && echo "Checking root filesystem..."
94 fsck $spinner $force $fix /
95 #
96 # If there was a failure, drop into single-user mode.
97 #
98 # NOTE: "failure" is defined as exiting with a return code of
99 # 2 or larger. A return code of 1 indicates that filesystem
100 # errors were corrected but that the boot may proceed.
101 #
102 if test "$?" -gt 1
103 then
104 # Surprise! Re-directing from a HERE document (as in
105 # "cat << EOF") won't work, because the root is read-only.
106 echo
107 echo "fsck failed. Please repair manually and reboot. Please note"
108 echo "that the root filesystem is currently mounted read-only. To"
109 echo "remount it read-write:"
110 echo
111 echo " # mount -n -o remount,rw /"
112 echo
113 echo "CONTROL-D will exit from this shell and REBOOT the system."
114 echo
115 # Start a single user shell on the console
116 /sbin/sulogin $CONSOLE
117 reboot -f
118 fi
119 else
120 echo "*** ERROR! Cannot fsck root fs because it is not mounted read-only!"
121 echo
122 fi
123fi
124
125#
126# If the root filesystem was not marked as read-only in /etc/fstab,
127# remount the rootfs rw but do not try to change mtab because it
128# is on a ro fs until the remount succeeded. Then clean up old mtabs
129# and finally write the new mtab.
130#
131mount -n -o remount,$rootmode /
132if test "$rootmode" = rw
133then
134 ln -sf /proc/mounts /dev/mtab
135fi
136
137: exit 0