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

Contents of /trunk/init.d/checkfs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 484 - (show annotations) (download)
Wed Apr 21 17:09:18 2004 UTC (15 years, 1 month ago) by vapier
File size: 5028 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 need checkroot modules
8 }
9
10 start() {
11 local retval=0
12
13 #
14 # EVMS2 summport for /usr, /var ....
15 #
16 if [ -z "${CDBOOT}" -a -f /sbin/evms_activate ]
17 then
18 ebegin "Activating EVMS2"
19 evms_activate
20 retval=$?
21 eend ${retval}
22 fi
23
24 # LVM support for /usr, /home, /opt ....
25 # This should be done *before* checking local
26 # volumes, or they never get checked.
27
28 # NOTE: Add needed modules for LVM or RAID, etc
29 # to /etc/modules.autoload if needed
30
31 if [ -z "${CDBOOT}" -a -x /sbin/vgscan ] && \
32 [ -d /proc/lvm -o "$(grep device-mapper /proc/misc 2>/dev/null)" ]
33 then
34 ebegin "Setting up the Logical Volume Manager"
35 #still echo stderr for debugging
36 /sbin/vgscan >/dev/null
37 if [ "$?" -eq 0 ] && [ -x /sbin/vgchange ] && \
38 [ -f /etc/lvmtab -o -d /etc/lvm ]
39 then
40 /sbin/vgchange -a y >/dev/null
41 fi
42 eend $? "Failed to setup the LVM"
43 fi
44
45 # Start software raid.
46 # You need a properly configured /etc/raidtab for raidtools usage or a
47 # properly configured /etc/mdadm.conf for mdadm usage. Devices in
48 # /etc/mdadm.conf are initialized first, so any duplicate devices in
49 # /etc/raidtab will not get initialized.
50 if [ -z "${CDBOOT}" -a -f /proc/mdstat ]
51 then
52 local mdadm_devices=
53 local raidtools_devices=
54 # If /etc/mdadm.conf exists, grab all the RAID devices from it
55 if [ -f /etc/mdadm.conf ]
56 then
57 mdadm_devices=$(awk '/^[[:space:]]*ARRAY/ { print $2 }' /etc/mdadm.conf)
58 fi
59 # If /etc/raidtab exists, grab all the RAID devices from it
60 if [ -f /etc/raidtab ]
61 then
62 raidtools_devices=$(awk '/^[[:space:]]*raiddev/ { print $2 }' /etc/raidtab)
63 fi
64 ebegin "Starting up RAID devices: "
65
66 local rc=0
67 local retval=0
68
69 for i in ${mdadm_devices}
70 do
71 local raiddev="${i##*/}"
72 local raidstat="$(egrep "^${raiddev} : active" /proc/mdstat)"
73
74 if [ -z "${raidstat}" ]
75 then
76 # First scan the /etc/fstab for the "noauto"-flag
77 # for this device. If found, skip the initialization
78 # for it to avoid dropping to a shell on errors.
79 # If not, try raidstart...if that fails then
80 # fall back to raidadd, raidrun. If that
81 # also fails, then we drop to a shell
82 local retval=1
83 local noauto="$(egrep "^${i}" /etc/fstab | grep -c 'noauto')"
84
85 einfon " Trying ${raiddev}..."
86
87 raiddev=""
88
89 if [ "${noauto}" -gt 0 ]
90 then
91 retval=0
92 raiddev=" (skipped)"
93 fi
94 if [ "${retval}" -gt 0 -a -x /sbin/mdadm ]
95 then
96 /sbin/mdadm -As "${i}" &>/dev/null
97 retval=$?
98 fi
99
100 echo "${raiddev}"
101
102 if [ "${retval}" -gt 0 ]
103 then
104 rc=1
105 eend ${retval}
106 else
107 ewend ${retval}
108 fi
109 fi
110 done
111
112 for i in ${raidtools_devices}
113 do
114 local raiddev="${i##*/}"
115 local raidstat="$(egrep "^${raiddev} : active" /proc/mdstat)"
116
117 if [ -z "${raidstat}" ]
118 then
119 # First scan the /etc/fstab for the "noauto"-flag
120 # for this device. If found, skip the initialization
121 # for it to avoid dropping to a shell on errors.
122 # If not, try raidstart...if that fails then
123 # fall back to raidadd, raidrun. If that
124 # also fails, then we drop to a shell
125 local retval=1
126 local noauto="$(egrep "^${i}" /etc/fstab | grep -c 'noauto')"
127
128 einfon " Trying ${raiddev}..."
129
130 raiddev=""
131
132 if [ "${noauto}" -gt 0 ]
133 then
134 retval=0
135 raiddev=" (skipped)"
136 fi
137 if [ "${retval}" -gt 0 -a -x /sbin/raidstart ]
138 then
139 /sbin/raidstart "${i}"
140 retval=$?
141 fi
142 if [ "${retval}" -gt 0 -a -x /sbin/raid0run ]
143 then
144 /sbin/raid0run "${i}"
145 retval=$?
146 fi
147 if [ "${retval}" -gt 0 -a -x /sbin/raidadd -a -x /sbin/raidrun ]
148 then
149 /sbin/raidadd "${i}"
150 /sbin/raidrun "${i}"
151 retval=$?
152 fi
153
154 echo "${raiddev}"
155
156 if [ "${retval}" -gt 0 ]
157 then
158 rc=1
159 eend ${retval}
160 else
161 ewend ${retval}
162 fi
163 fi
164 done
165
166 # A non-zero return means there were problems.
167 if [ "${rc}" -gt 0 ]
168 then
169 echo
170 eerror "An error occurred during the RAID startup"
171 eerror "Dropping you to a shell; the system will reboot"
172 eerror "when you leave the shell."
173 echo; echo
174 /sbin/sulogin ${CONSOLE}
175 einfo "Unmounting filesystems"
176 /bin/mount -a -o remount,ro &>/dev/null
177 einfo "Rebooting"
178 /sbin/reboot -f
179 fi
180 fi
181
182 if [ -f /fastboot -o -n "${CDBOOT}" ]
183 then
184 rm -f /fastboot
185 else
186 ebegin "Checking all filesystems"
187 if [ -f /forcefsck ]
188 then
189 ewarn "A full fsck has been forced"
190 fsck -C -R -A -a -f
191 retval=$?
192 rm -f /forcefsck
193 else
194 fsck -C -T -R -A -a
195 retval=$?
196 fi
197 if [ "${retval}" -eq 0 ]
198 then
199 eend 0
200 elif [ "${retval}" -ge 1 -a "${retval}" -le 3 ]
201 then
202 ewend 1 "Filesystem errors corrected."
203 # Everything should be ok, so return a pass
204 return 0
205 else
206 eend 2 "Fsck could not correct all errors, manual repair needed"
207 /sbin/sulogin ${CONSOLE}
208 fi
209 fi
210 }
211
212
213 # 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