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

Contents of /trunk/init.d/checkfs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 389 - (show annotations) (download)
Mon Jul 28 01:23:46 2003 UTC (15 years, 8 months ago) by azarah
File size: 4841 byte(s)
adelie fixes, add better logger support

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