/[baselayout]/trunk/init.d/checkroot
Gentoo

Contents of /trunk/init.d/checkroot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 484 - (show annotations) (download)
Wed Apr 21 17:09:18 2004 UTC (15 years, 2 months ago) by vapier
File size: 2231 byte(s)
update copyright years

1 #!/sbin/runscript
2 # Copyright 1999-2004 Gentoo Technologies, Inc.
3 # Distributed under the terms of the GNU General Public License v2
4 # $Header$
5
6 depend() {
7 before *
8 }
9
10 start() {
11 local retval=0
12
13 if [ ! -f /fastboot -a -z "${CDBOOT}" ]
14 then
15 ebegin "Remounting root filesystem read-only (if necessary)"
16 mount / -n -o remount,ro &>/dev/null
17 eend $?
18
19 ebegin "Checking root filesystem"
20 if [ -f /forcefsck ]
21 then
22 ewarn "A full fsck has been forced"
23 fsck -C -a -f /
24 # /forcefsck isn't deleted because checkfs needs it.
25 # it'll be deleted in that script.
26 retval=$?
27 else
28 fsck -C -T -a /
29 retval=$?
30 fi
31 if [ "${retval}" -eq 0 ]
32 then
33 eend 0
34 elif [ "${retval}" -eq 1 ]
35 then
36 ewend 1 "Filesystem repaired"
37 elif [ "${retval}" -eq 2 -o "${retval}" -eq 3 ]
38 then
39 ewend 1 "Filesystem repaired, but reboot needed!"
40 echo -ne "\a"; sleep 1; echo -ne "\a"; sleep 1
41 echo -ne "\a"; sleep 1; echo -ne "\a"; sleep 1
42 ewarn "Rebooting in 10 seconds ..."
43 sleep 10
44 einfo "Rebooting"
45 /sbin/reboot -f
46 else
47 eend 2 "Filesystem couldn't be fixed :("
48 /sbin/sulogin ${CONSOLE}
49 einfo "Unmounting filesystems"
50 /bin/mount -a -o remount,ro &>/dev/null
51 einfo "Rebooting"
52 /sbin/reboot -f
53 fi
54 fi
55
56 # Should we mount root rw ?
57 if mount -vf -o remount / 2> /dev/null | \
58 awk '{ if ($6 ~ /rw/) exit 0; else exit 1; }'
59 then
60 ebegin "Remounting root filesystem read/write"
61 mount / -n -o remount,rw &>/dev/null
62 if [ "$?" -ne 0 ]
63 then
64 eend 2 "Root filesystem could not be mounted read/write :("
65 /sbin/sulogin ${CONSOLE}
66 else
67 eend 0
68 fi
69 fi
70
71 if [ "${BOOT}" = "yes" ]
72 then
73 local x=
74 local y=
75
76 #
77 # Create /etc/mtab
78 #
79
80 # Clear the existing mtab
81 > /etc/mtab
82
83 # Add the entry for / to mtab
84 mount -f /
85
86 # Don't list root more than once
87 awk '$2 != "/" {print}' /proc/mounts >> /etc/mtab
88
89 # Now make sure /etc/mtab have additional info (gid, etc) in there
90 for x in $(awk '{ print $2 }' /proc/mounts | uniq)
91 do
92 for y in $(awk '{ print $2 }' /etc/fstab)
93 do
94 if [ "${x}" = "${y}" ]
95 then
96 mount -f -o remount $x
97 continue
98 fi
99 done
100 done
101
102 # Remove stale backups
103 rm -f /etc/mtab~ /etc/mtab~~
104 fi
105 }
106
107
108 # vim:ts=4

Properties

Name Value
svn:eol-style native
svn:executable *
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.20