4 |
- |
1 |
#!/bin/bash
|
|
|
2 |
#
|
|
|
3 |
# /etc/rc.d/rc.sysinit - run once at boot time
|
|
|
4 |
#
|
|
|
5 |
# Taken in part from Miquel van Smoorenburg's bcheckrc.
|
|
|
6 |
#
|
|
|
7 |
|
|
|
8 |
HOSTNAME=$(/bin/hostname)
|
|
|
9 |
|
|
|
10 |
set -m
|
|
|
11 |
|
|
|
12 |
if [ -f /etc/sysconfig/network ]; then
|
|
|
13 |
. /etc/sysconfig/network
|
|
|
14 |
fi
|
|
|
15 |
if [ -z "$HOSTNAME" -o "$HOSTNAME" = "(none)" ]; then
|
|
|
16 |
HOSTNAME=localhost
|
|
|
17 |
fi
|
|
|
18 |
|
|
|
19 |
if [ ! -e /proc/mounts ]; then
|
|
|
20 |
mount -n -t proc /proc /proc
|
|
|
21 |
mount -n -t sysfs /sys /sys >/dev/null 2>&1
|
|
|
22 |
fi
|
|
|
23 |
if [ ! -d /proc/bus/usb ]; then
|
|
|
24 |
modprobe usbcore >/dev/null 2>&1 && mount -n -t usbfs /proc/bus/usb /proc/bus/usb
|
|
|
25 |
else
|
|
|
26 |
mount -n -t usbfs /proc/bus/usb /proc/bus/usb
|
|
|
27 |
fi
|
|
|
28 |
|
|
|
29 |
#remount /dev/shm to set attributes from fstab #669700
|
|
|
30 |
mount -n -o remount /dev/shm >/dev/null 2>&1
|
|
|
31 |
#remount /proc to set attributes from fstab #984003
|
|
|
32 |
mount -n -o remount /proc >/dev/null 2>&1
|
|
|
33 |
|
|
|
34 |
. /etc/init.d/functions
|
|
|
35 |
|
|
|
36 |
PLYMOUTH=
|
|
|
37 |
[ -x /bin/plymouth ] && PLYMOUTH=yes
|
|
|
38 |
|
|
|
39 |
# Check SELinux status
|
|
|
40 |
SELINUX_STATE=
|
|
|
41 |
if [ -e "/selinux/enforce" ] && [ "$(cat /proc/self/attr/current)" != "kernel" ]; then
|
|
|
42 |
if [ -r "/selinux/enforce" ] ; then
|
|
|
43 |
SELINUX_STATE=$(cat "/selinux/enforce")
|
|
|
44 |
else
|
|
|
45 |
# assume enforcing if you can't read it
|
|
|
46 |
SELINUX_STATE=1
|
|
|
47 |
fi
|
|
|
48 |
fi
|
|
|
49 |
|
|
|
50 |
if [ -n "$SELINUX_STATE" -a -x /sbin/restorecon ] && __fgrep " /dev " /proc/mounts >/dev/null 2>&1 ; then
|
|
|
51 |
/sbin/restorecon -R -F /dev 2>/dev/null
|
|
|
52 |
fi
|
|
|
53 |
|
|
|
54 |
disable_selinux() {
|
|
|
55 |
echo $"*** Warning -- SELinux is active"
|
|
|
56 |
echo $"*** Disabling security enforcement for system recovery."
|
|
|
57 |
echo $"*** Run 'setenforce 1' to reenable."
|
|
|
58 |
echo "0" > "/selinux/enforce"
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
relabel_selinux() {
|
|
|
62 |
# if /sbin/init is not labeled correctly this process is running in the
|
|
|
63 |
# wrong context, so a reboot will be required after relabel
|
|
|
64 |
AUTORELABEL=
|
|
|
65 |
. /etc/selinux/config
|
|
|
66 |
echo "0" > /selinux/enforce
|
|
|
67 |
[ -n "$PLYMOUTH" ] && plymouth --hide-splash
|
|
|
68 |
|
|
|
69 |
if [ "$AUTORELABEL" = "0" ]; then
|
|
|
70 |
echo
|
|
|
71 |
echo $"*** Warning -- SELinux ${SELINUXTYPE} policy relabel is required. "
|
|
|
72 |
echo $"*** /etc/selinux/config indicates you want to manually fix labeling"
|
|
|
73 |
echo $"*** problems. Dropping you to a shell; the system will reboot"
|
|
|
74 |
echo $"*** when you leave the shell."
|
|
|
75 |
start rcS-emergency
|
|
|
76 |
|
|
|
77 |
else
|
|
|
78 |
echo
|
|
|
79 |
echo $"*** Warning -- SELinux ${SELINUXTYPE} policy relabel is required."
|
|
|
80 |
echo $"*** Relabeling could take a very long time, depending on file"
|
|
|
81 |
echo $"*** system size and speed of hard drives."
|
|
|
82 |
|
|
|
83 |
/sbin/fixfiles -F restore > /dev/null 2>&1
|
|
|
84 |
fi
|
|
|
85 |
rm -f /.autorelabel
|
|
|
86 |
echo $"Unmounting file systems"
|
|
|
87 |
umount -a
|
|
|
88 |
mount -n -o remount,ro /
|
|
|
89 |
echo $"Automatic reboot in progress."
|
|
|
90 |
reboot -f
|
|
|
91 |
}
|
|
|
92 |
|
|
|
93 |
# Print a text banner.
|
|
|
94 |
echo -en $"\t\tWelcome to "
|
|
|
95 |
read -r system_release < /etc/system-release
|
|
|
96 |
if [[ "$system_release" == *"Red Hat"* ]]; then
|
|
|
97 |
[ "$BOOTUP" = "color" ] && echo -en "\\033[0;31m"
|
|
|
98 |
echo -en "Red Hat"
|
|
|
99 |
[ "$BOOTUP" = "color" ] && echo -en "\\033[0;39m"
|
|
|
100 |
PRODUCT=$(sed "s/Red Hat \(.*\) release.*/\1/" /etc/system-release)
|
|
|
101 |
echo " $PRODUCT"
|
|
|
102 |
elif [[ "$system_release" == *Fedora* ]]; then
|
|
|
103 |
[ "$BOOTUP" = "color" ] && echo -en "\\033[0;34m"
|
|
|
104 |
echo -en "Fedora"
|
|
|
105 |
[ "$BOOTUP" = "color" ] && echo -en "\\033[0;39m"
|
|
|
106 |
PRODUCT=$(sed "s/Fedora \(.*\) \?release.*/\1/" /etc/system-release)
|
|
|
107 |
echo " $PRODUCT"
|
|
|
108 |
elif [[ "$system_release" =~ "CentOS" ]]; then
|
|
|
109 |
[ "$BOOTUP" = "color" ] && echo -en "\\033[0;36m"
|
|
|
110 |
echo -en "CentOS"
|
|
|
111 |
[ "$BOOTUP" = "color" ] && echo -en "\\033[0;39m"
|
|
|
112 |
PRODUCT=$(sed "s/CentOS \(.*\) \?release.*/\1/" /etc/system-release)
|
|
|
113 |
echo " $PRODUCT"
|
|
|
114 |
else
|
|
|
115 |
PRODUCT=$(sed "s/ release.*//g" /etc/system-release)
|
|
|
116 |
echo "$PRODUCT"
|
|
|
117 |
fi
|
|
|
118 |
|
|
|
119 |
# Only read this once.
|
|
|
120 |
cmdline=$(cat /proc/cmdline)
|
|
|
121 |
|
|
|
122 |
# Initialize hardware
|
|
|
123 |
if [ -f /proc/sys/kernel/modprobe ]; then
|
|
|
124 |
if ! strstr "$cmdline" nomodules && [ -f /proc/modules ] ; then
|
|
|
125 |
sysctl -w kernel.modprobe="/sbin/modprobe" >/dev/null 2>&1
|
|
|
126 |
else
|
|
|
127 |
# We used to set this to NULL, but that causes 'failed to exec' messages"
|
|
|
128 |
sysctl -w kernel.modprobe="/bin/true" >/dev/null 2>&1
|
|
|
129 |
fi
|
|
|
130 |
fi
|
|
|
131 |
|
|
|
132 |
touch /dev/.in_sysinit >/dev/null 2>&1
|
|
|
133 |
|
|
|
134 |
# Set default affinity
|
|
|
135 |
if [ -x /bin/taskset ]; then
|
|
|
136 |
if strstr "$cmdline" default_affinity= ; then
|
|
|
137 |
for arg in $cmdline ; do
|
|
|
138 |
if [ "${arg##default_affinity=}" != "${arg}" ]; then
|
|
|
139 |
/bin/taskset -p ${arg##default_affinity=} 1
|
34 |
- |
140 |
/bin/taskset -p ${arg##default_affinity=} $$
|
4 |
- |
141 |
fi
|
|
|
142 |
done
|
|
|
143 |
fi
|
|
|
144 |
fi
|
|
|
145 |
|
|
|
146 |
nashpid=$(pidof nash 2>/dev/null)
|
|
|
147 |
[ -n "$nashpid" ] && kill $nashpid >/dev/null 2>&1
|
|
|
148 |
unset nashpid
|
9 |
- |
149 |
|
|
|
150 |
apply_sysctl
|
|
|
151 |
|
4 |
- |
152 |
/sbin/start_udev
|
|
|
153 |
|
|
|
154 |
# Load other user-defined modules
|
|
|
155 |
for file in /etc/sysconfig/modules/*.modules ; do
|
|
|
156 |
[ -x $file ] && $file
|
|
|
157 |
done
|
|
|
158 |
|
|
|
159 |
# Load modules (for backward compatibility with VARs)
|
|
|
160 |
if [ -f /etc/rc.modules ]; then
|
|
|
161 |
/etc/rc.modules
|
|
|
162 |
fi
|
|
|
163 |
|
|
|
164 |
mount -n /dev/pts >/dev/null 2>&1
|
|
|
165 |
[ -n "$SELINUX_STATE" ] && restorecon -F /dev/pts >/dev/null 2>&1
|
|
|
166 |
|
|
|
167 |
# Configure kernel parameters
|
|
|
168 |
update_boot_stage RCkernelparam
|
|
|
169 |
apply_sysctl
|
|
|
170 |
|
|
|
171 |
# Set the hostname.
|
|
|
172 |
update_boot_stage RChostname
|
|
|
173 |
action $"Setting hostname ${HOSTNAME}: " hostname ${HOSTNAME}
|
|
|
174 |
[ -n "${NISDOMAIN}" ] && domainname ${NISDOMAIN}
|
|
|
175 |
|
|
|
176 |
# Sync waiting for storage.
|
|
|
177 |
{ rmmod scsi_wait_scan ; modprobe scsi_wait_scan ; rmmod scsi_wait_scan ; } >/dev/null 2>&1
|
|
|
178 |
|
|
|
179 |
# Device mapper & related initialization
|
|
|
180 |
if ! __fgrep "device-mapper" /proc/devices >/dev/null 2>&1 ; then
|
|
|
181 |
modprobe dm-mod >/dev/null 2>&1
|
|
|
182 |
fi
|
|
|
183 |
|
|
|
184 |
if [ -f /etc/crypttab ]; then
|
|
|
185 |
init_crypto 0
|
|
|
186 |
fi
|
|
|
187 |
|
|
|
188 |
if ! strstr "$cmdline" nompath && [ -f /etc/multipath.conf -a \
|
|
|
189 |
-x /sbin/multipath ]; then
|
|
|
190 |
modprobe dm-multipath > /dev/null 2>&1
|
|
|
191 |
/sbin/multipath -v 0
|
|
|
192 |
if [ -x /sbin/kpartx ]; then
|
34 |
- |
193 |
action_silent $"Add partition mappings: " /sbin/dmsetup ls --target multipath --exec "/sbin/kpartx -a -p p"
|
4 |
- |
194 |
fi
|
|
|
195 |
fi
|
|
|
196 |
|
|
|
197 |
if ! strstr "$cmdline" nodmraid && [ -x /sbin/dmraid ]; then
|
|
|
198 |
modprobe dm-mirror >/dev/null 2>&1
|
|
|
199 |
dmraidsets=$(LC_ALL=C /sbin/dmraid -s -c -i)
|
|
|
200 |
if [ "$?" = "0" ]; then
|
|
|
201 |
for dmname in $dmraidsets; do
|
|
|
202 |
if [[ "$dmname" == isw_* ]] && \
|
|
|
203 |
! strstr "$cmdline" noiswmd; then
|
|
|
204 |
continue
|
|
|
205 |
fi
|
34 |
- |
206 |
action_silent $"Activate software (ATA)RAID: " /sbin/dmraid -ay -i --rm_partitions -p "$dmname"
|
4 |
- |
207 |
/sbin/kpartx -a -p p "/dev/mapper/$dmname"
|
|
|
208 |
done
|
|
|
209 |
fi
|
|
|
210 |
fi
|
|
|
211 |
|
|
|
212 |
# Start any MD RAID arrays that haven't been started yet
|
34 |
- |
213 |
[ -r /proc/mdstat -a -r /dev/md/md-device-map ] && action $"Run MD devices: " /sbin/mdadm -IRs
|
4 |
- |
214 |
|
|
|
215 |
if [ -x /sbin/lvm ]; then
|
|
|
216 |
if [ ! -f /.nolvm ] && ! strstr "$cmdline" nolvm ; then
|
9 |
- |
217 |
action $"Setting up Logical Volume Management:" /sbin/lvm vgchange -a ay --sysinit --ignoreskippedcluster
|
4 |
- |
218 |
else
|
|
|
219 |
echo $"Logical Volume Management disabled at boot."
|
|
|
220 |
fi
|
|
|
221 |
fi
|
|
|
222 |
|
|
|
223 |
if [ -f /etc/crypttab ]; then
|
|
|
224 |
init_crypto 0
|
|
|
225 |
fi
|
|
|
226 |
|
|
|
227 |
if [ -f /fastboot ] || strstr "$cmdline" fastboot ; then
|
|
|
228 |
fastboot=yes
|
|
|
229 |
fi
|
|
|
230 |
|
|
|
231 |
if [ -f /fsckoptions ]; then
|
|
|
232 |
fsckoptions=$(cat /fsckoptions)
|
|
|
233 |
fi
|
|
|
234 |
|
|
|
235 |
if [ -f /forcefsck ] || strstr "$cmdline" forcefsck ; then
|
|
|
236 |
fsckoptions="-f $fsckoptions"
|
|
|
237 |
elif [ -f /.autofsck ]; then
|
|
|
238 |
[ -f /etc/sysconfig/autofsck ] && . /etc/sysconfig/autofsck
|
|
|
239 |
if [ "$AUTOFSCK_DEF_CHECK" = "yes" ]; then
|
|
|
240 |
AUTOFSCK_OPT="$AUTOFSCK_OPT -f"
|
|
|
241 |
fi
|
|
|
242 |
if [ -n "$AUTOFSCK_SINGLEUSER" ]; then
|
|
|
243 |
[ -n "$PLYMOUTH" ] && plymouth --hide-splash
|
|
|
244 |
echo
|
|
|
245 |
echo $"*** Warning -- the system did not shut down cleanly. "
|
|
|
246 |
echo $"*** Dropping you to a shell; the system will continue"
|
|
|
247 |
echo $"*** when you leave the shell."
|
|
|
248 |
[ -n "$SELINUX_STATE" ] && echo "0" > /selinux/enforce
|
|
|
249 |
start rcS-emergency
|
|
|
250 |
[ -n "$SELINUX_STATE" ] && echo "1" > /selinux/enforce
|
|
|
251 |
[ -n "$PLYMOUTH" ] && plymouth --show-splash
|
|
|
252 |
fi
|
|
|
253 |
fsckoptions="$AUTOFSCK_OPT $fsckoptions"
|
|
|
254 |
fi
|
|
|
255 |
|
|
|
256 |
if [ "$BOOTUP" = "color" ]; then
|
|
|
257 |
fsckoptions="-C $fsckoptions"
|
|
|
258 |
else
|
|
|
259 |
fsckoptions="-V $fsckoptions"
|
|
|
260 |
fi
|
|
|
261 |
|
|
|
262 |
READONLY=
|
|
|
263 |
if [ -f /etc/sysconfig/readonly-root ]; then
|
|
|
264 |
. /etc/sysconfig/readonly-root
|
|
|
265 |
fi
|
|
|
266 |
if strstr "$cmdline" readonlyroot ; then
|
|
|
267 |
READONLY=yes
|
|
|
268 |
[ -z "$RW_MOUNT" ] && RW_MOUNT=/var/lib/stateless/writable
|
|
|
269 |
[ -z "$STATE_MOUNT" ] && STATE_MOUNT=/var/lib/stateless/state
|
|
|
270 |
fi
|
|
|
271 |
if strstr "$cmdline" noreadonlyroot ; then
|
|
|
272 |
READONLY=no
|
|
|
273 |
fi
|
|
|
274 |
|
|
|
275 |
if [ "$READONLY" = "yes" -o "$TEMPORARY_STATE" = "yes" ]; then
|
|
|
276 |
|
|
|
277 |
mount_empty() {
|
|
|
278 |
if [ -e "$1" ]; then
|
|
|
279 |
echo "$1" | cpio -p -vd "$RW_MOUNT" &>/dev/null
|
|
|
280 |
mount -n --bind "$RW_MOUNT$1" "$1"
|
|
|
281 |
fi
|
|
|
282 |
}
|
|
|
283 |
|
|
|
284 |
mount_dirs() {
|
|
|
285 |
if [ -e "$1" ]; then
|
|
|
286 |
mkdir -p "$RW_MOUNT$1"
|
|
|
287 |
find "$1" -type d -print0 | cpio -p -0vd "$RW_MOUNT" &>/dev/null
|
|
|
288 |
mount -n --bind "$RW_MOUNT$1" "$1"
|
|
|
289 |
fi
|
|
|
290 |
}
|
|
|
291 |
|
|
|
292 |
mount_files() {
|
|
|
293 |
if [ -e "$1" ]; then
|
|
|
294 |
cp -a --parents "$1" "$RW_MOUNT"
|
|
|
295 |
mount -n --bind "$RW_MOUNT$1" "$1"
|
|
|
296 |
fi
|
|
|
297 |
}
|
|
|
298 |
|
|
|
299 |
# Common mount options for scratch space regardless of
|
|
|
300 |
# type of backing store
|
|
|
301 |
mountopts=
|
|
|
302 |
|
|
|
303 |
# Scan partitions for local scratch storage
|
|
|
304 |
rw_mount_dev=$(blkid -t LABEL="$RW_LABEL" -l -o device)
|
|
|
305 |
|
|
|
306 |
# First try to mount scratch storage from /etc/fstab, then any
|
|
|
307 |
# partition with the proper label. If either succeeds, be sure
|
|
|
308 |
# to wipe the scratch storage clean. If both fail, then mount
|
|
|
309 |
# scratch storage via tmpfs.
|
|
|
310 |
if mount $mountopts "$RW_MOUNT" > /dev/null 2>&1 ; then
|
|
|
311 |
rm -rf "$RW_MOUNT" > /dev/null 2>&1
|
|
|
312 |
elif [ x$rw_mount_dev != x ] && mount $rw_mount_dev $mountopts "$RW_MOUNT" > /dev/null 2>&1; then
|
|
|
313 |
rm -rf "$RW_MOUNT" > /dev/null 2>&1
|
|
|
314 |
else
|
|
|
315 |
mount -n -t tmpfs $RW_OPTIONS $mountopts none "$RW_MOUNT"
|
|
|
316 |
fi
|
|
|
317 |
|
|
|
318 |
for file in /etc/rwtab /etc/rwtab.d/* /dev/.initramfs/rwtab ; do
|
|
|
319 |
is_ignored_file "$file" && continue
|
|
|
320 |
[ -f $file ] && cat $file | while read type path ; do
|
|
|
321 |
case "$type" in
|
|
|
322 |
empty)
|
|
|
323 |
mount_empty $path
|
|
|
324 |
;;
|
|
|
325 |
files)
|
|
|
326 |
mount_files $path
|
|
|
327 |
;;
|
|
|
328 |
dirs)
|
|
|
329 |
mount_dirs $path
|
|
|
330 |
;;
|
|
|
331 |
*)
|
|
|
332 |
;;
|
|
|
333 |
esac
|
|
|
334 |
[ -n "$SELINUX_STATE" -a -e "$path" ] && restorecon -R "$path"
|
|
|
335 |
done
|
|
|
336 |
done
|
|
|
337 |
|
|
|
338 |
# Use any state passed by initramfs
|
|
|
339 |
[ -d /dev/.initramfs/state ] && cp -a /dev/.initramfs/state/* $RW_MOUNT
|
|
|
340 |
|
|
|
341 |
# In theory there should be no more than one network interface active
|
|
|
342 |
# this early in the boot process -- the one we're booting from.
|
|
|
343 |
# Use the network address to set the hostname of the client. This
|
|
|
344 |
# must be done even if we have local storage.
|
|
|
345 |
ipaddr=
|
|
|
346 |
if [ "$HOSTNAME" = "localhost" -o "$HOSTNAME" = "localhost.localdomain" ]; then
|
|
|
347 |
ipaddr=$(ip addr show to 0.0.0.0/0 scope global | awk '/[[:space:]]inet / { print gensub("/.*","","g",$2) }')
|
|
|
348 |
for ip in $ipaddr ; do
|
|
|
349 |
HOSTNAME=
|
|
|
350 |
eval $(ipcalc -h $ip 2>/dev/null)
|
|
|
351 |
[ -n "$HOSTNAME" ] && { hostname ${HOSTNAME} ; break; }
|
|
|
352 |
done
|
|
|
353 |
fi
|
|
|
354 |
|
|
|
355 |
# Clients with read-only root filesystems may be provided with a
|
|
|
356 |
# place where they can place minimal amounts of persistent
|
|
|
357 |
# state. SSH keys or puppet certificates for example.
|
|
|
358 |
#
|
|
|
359 |
# Ideally we'll use puppet to manage the state directory and to
|
|
|
360 |
# create the bind mounts. However, until that's all ready this
|
|
|
361 |
# is sufficient to build a working system.
|
|
|
362 |
|
|
|
363 |
# First try to mount persistent data from /etc/fstab, then any
|
|
|
364 |
# partition with the proper label, then fallback to NFS
|
|
|
365 |
state_mount_dev=$(blkid -t LABEL="$STATE_LABEL" -l -o device)
|
|
|
366 |
if mount $mountopts $STATE_OPTIONS "$STATE_MOUNT" > /dev/null 2>&1 ; then
|
|
|
367 |
/bin/true
|
|
|
368 |
elif [ x$state_mount_dev != x ] && mount $state_mount_dev $mountopts "$STATE_MOUNT" > /dev/null 2>&1; then
|
|
|
369 |
/bin/true
|
|
|
370 |
elif [ ! -z "$CLIENTSTATE" ]; then
|
|
|
371 |
# No local storage was found. Make a final attempt to find
|
|
|
372 |
# state on an NFS server.
|
|
|
373 |
|
|
|
374 |
mount -t nfs $CLIENTSTATE/$HOSTNAME $STATE_MOUNT -o rw,nolock
|
|
|
375 |
fi
|
|
|
376 |
|
|
|
377 |
if [ -w "$STATE_MOUNT" ]; then
|
|
|
378 |
|
|
|
379 |
mount_state() {
|
|
|
380 |
if [ -e "$1" ]; then
|
|
|
381 |
[ ! -e "$STATE_MOUNT$1" ] && cp -a --parents "$1" "$STATE_MOUNT"
|
|
|
382 |
mount -n --bind "$STATE_MOUNT$1" "$1"
|
|
|
383 |
fi
|
|
|
384 |
}
|
|
|
385 |
|
|
|
386 |
for file in /etc/statetab /etc/statetab.d/* ; do
|
|
|
387 |
is_ignored_file "$file" && continue
|
|
|
388 |
[ ! -f "$file" ] && continue
|
|
|
389 |
|
|
|
390 |
if [ -f "$STATE_MOUNT/$file" ] ; then
|
|
|
391 |
mount -n --bind "$STATE_MOUNT/$file" "$file"
|
|
|
392 |
fi
|
|
|
393 |
|
|
|
394 |
for path in $(grep -v "^#" "$file" 2>/dev/null); do
|
|
|
395 |
mount_state "$path"
|
|
|
396 |
[ -n "$SELINUX_STATE" -a -e "$path" ] && restorecon -R "$path"
|
|
|
397 |
done
|
|
|
398 |
done
|
|
|
399 |
|
|
|
400 |
if [ -f "$STATE_MOUNT/files" ] ; then
|
|
|
401 |
for path in $(grep -v "^#" "$STATE_MOUNT/files" 2>/dev/null); do
|
|
|
402 |
mount_state "$path"
|
|
|
403 |
[ -n "$SELINUX_STATE" -a -e "$path" ] && restorecon -R "$path"
|
|
|
404 |
done
|
|
|
405 |
fi
|
|
|
406 |
fi
|
9 |
- |
407 |
|
|
|
408 |
if mount | grep -q /var/lib/nfs/rpc_pipefs ; then
|
|
|
409 |
mount -t rpc_pipefs sunrpc /var/lib/nfs/rpc_pipefs && service rpcidmapd restart
|
|
|
410 |
fi
|
4 |
- |
411 |
fi
|
|
|
412 |
|
|
|
413 |
if [[ " $fsckoptions" != *" -y"* ]]; then
|
|
|
414 |
fsckoptions="-a $fsckoptions"
|
|
|
415 |
fi
|
|
|
416 |
|
|
|
417 |
_RUN_QUOTACHECK=0
|
|
|
418 |
if [ -f /forcequotacheck ] || strstr "$cmdline" forcequotacheck ; then
|
|
|
419 |
_RUN_QUOTACHECK=1
|
|
|
420 |
fi
|
|
|
421 |
if [ -z "$fastboot" -a "$READONLY" != "yes" ]; then
|
|
|
422 |
|
|
|
423 |
STRING=$"Checking filesystems"
|
|
|
424 |
echo $STRING
|
|
|
425 |
fsck -T -t noopts=_netdev -A $fsckoptions
|
|
|
426 |
rc=$?
|
|
|
427 |
|
|
|
428 |
if [ "$rc" -eq "0" ]; then
|
|
|
429 |
success "$STRING"
|
|
|
430 |
echo
|
|
|
431 |
elif [ "$rc" -eq "1" ]; then
|
|
|
432 |
passed "$STRING"
|
|
|
433 |
echo
|
|
|
434 |
elif [ "$rc" -eq "2" -o "$rc" -eq "3" ]; then
|
|
|
435 |
echo $"Unmounting file systems"
|
|
|
436 |
umount -a
|
|
|
437 |
mount -n -o remount,ro /
|
|
|
438 |
echo $"Automatic reboot in progress."
|
|
|
439 |
reboot -f
|
|
|
440 |
fi
|
|
|
441 |
|
|
|
442 |
# A return of 4 or higher means there were serious problems.
|
|
|
443 |
if [ $rc -gt 1 ]; then
|
|
|
444 |
[ -n "$PLYMOUTH" ] && plymouth --hide-splash
|
|
|
445 |
|
|
|
446 |
failure "$STRING"
|
|
|
447 |
echo
|
|
|
448 |
echo
|
|
|
449 |
echo $"*** An error occurred during the file system check."
|
|
|
450 |
echo $"*** Dropping you to a shell; the system will reboot"
|
|
|
451 |
echo $"*** when you leave the shell."
|
|
|
452 |
|
|
|
453 |
str=$"(Repair filesystem)"
|
|
|
454 |
PS1="$str \# # "; export PS1
|
|
|
455 |
[ "$SELINUX_STATE" = "1" ] && disable_selinux
|
|
|
456 |
start rcS-emergency
|
|
|
457 |
|
|
|
458 |
echo $"Unmounting file systems"
|
|
|
459 |
umount -a
|
|
|
460 |
mount -n -o remount,ro /
|
|
|
461 |
echo $"Automatic reboot in progress."
|
|
|
462 |
reboot -f
|
|
|
463 |
elif [ "$rc" -eq "1" ]; then
|
|
|
464 |
_RUN_QUOTACHECK=1
|
|
|
465 |
fi
|
|
|
466 |
fi
|
|
|
467 |
|
|
|
468 |
remount_needed() {
|
|
|
469 |
local state oldifs
|
|
|
470 |
[ "$READONLY" = "yes" ] && return 1
|
|
|
471 |
state=$(LC_ALL=C awk '/ \/ / && ($3 !~ /rootfs/) { print $4 }' /proc/mounts)
|
|
|
472 |
oldifs=$IFS
|
|
|
473 |
IFS=","
|
|
|
474 |
for opt in $state ; do
|
|
|
475 |
if [ "$opt" = "rw" ]; then
|
|
|
476 |
IFS=$oldifs
|
|
|
477 |
return 1
|
|
|
478 |
fi
|
|
|
479 |
done
|
|
|
480 |
IFS=$oldifs
|
|
|
481 |
return 0
|
|
|
482 |
}
|
|
|
483 |
|
|
|
484 |
# Remount the root filesystem read-write.
|
|
|
485 |
update_boot_stage RCmountfs
|
|
|
486 |
if remount_needed ; then
|
|
|
487 |
action $"Remounting root filesystem in read-write mode: " mount -n -o remount,rw /
|
|
|
488 |
fi
|
|
|
489 |
|
|
|
490 |
# Clean up SELinux labels
|
|
|
491 |
if [ -n "$SELINUX_STATE" ]; then
|
|
|
492 |
restorecon /etc/mtab /etc/ld.so.cache /etc/blkid/blkid.tab /etc/resolv.conf >/dev/null 2>&1
|
|
|
493 |
fi
|
|
|
494 |
|
|
|
495 |
# If relabeling, relabel mount points.
|
|
|
496 |
if [ -n "$SELINUX_STATE" -a "$READONLY" != "yes" ]; then
|
|
|
497 |
if [ -f /.autorelabel ] || strstr "$cmdline" autorelabel ; then
|
|
|
498 |
restorecon $(awk '!/^#/ && $4 !~ /noauto/ && $2 ~ /^\// { print $2 }' /etc/fstab) >/dev/null 2>&1
|
|
|
499 |
fi
|
|
|
500 |
fi
|
|
|
501 |
|
|
|
502 |
if [ "$READONLY" != "yes" ] ; then
|
|
|
503 |
# Clear mtab
|
|
|
504 |
(> /etc/mtab) &> /dev/null
|
|
|
505 |
|
|
|
506 |
# Remove stale backups
|
|
|
507 |
rm -f /etc/mtab~ /etc/mtab~~
|
|
|
508 |
|
|
|
509 |
# Enter mounted filesystems into /etc/mtab
|
|
|
510 |
mount -f /
|
|
|
511 |
mount -f /proc >/dev/null 2>&1
|
|
|
512 |
mount -f /sys >/dev/null 2>&1
|
|
|
513 |
mount -f /dev/pts >/dev/null 2>&1
|
|
|
514 |
mount -f /dev/shm >/dev/null 2>&1
|
|
|
515 |
mount -f /proc/bus/usb >/dev/null 2>&1
|
|
|
516 |
fi
|
|
|
517 |
|
|
|
518 |
# Mount all other filesystems (except for NFS and /proc, which is already
|
|
|
519 |
# mounted). Contrary to standard usage,
|
|
|
520 |
# filesystems are NOT unmounted in single user mode.
|
|
|
521 |
# The 'no' applies to all listed filesystem types. See mount(8).
|
|
|
522 |
if [ "$READONLY" != "yes" ] ; then
|
9 |
- |
523 |
action $"Mounting local filesystems: " mount -a -t nonfs,nfs4,smbfs,ncpfs,cifs,gfs,gfs2,glusterfs -O no_netdev
|
4 |
- |
524 |
else
|
9 |
- |
525 |
action $"Mounting local filesystems: " mount -a -n -t nonfs,nfs4,smbfs,ncpfs,cifs,gfs,gfs2i,glusterfs -O no_netdev
|
4 |
- |
526 |
fi
|
|
|
527 |
|
|
|
528 |
# Check to see if a full relabel is needed
|
|
|
529 |
if [ -n "$SELINUX_STATE" -a "$READONLY" != "yes" ]; then
|
|
|
530 |
if [ -f /.autorelabel ] || strstr "$cmdline" autorelabel ; then
|
|
|
531 |
relabel_selinux
|
|
|
532 |
fi
|
|
|
533 |
else
|
|
|
534 |
if [ -d /etc/selinux -a "$READONLY" != "yes" ]; then
|
|
|
535 |
[ -f /.autorelabel ] || touch /.autorelabel
|
|
|
536 |
fi
|
|
|
537 |
fi
|
|
|
538 |
|
38 |
- |
539 |
# Update quotas if necessary
|
|
|
540 |
if [ X"$_RUN_QUOTACHECK" = X1 -a -x /sbin/quotacheck ]; then
|
|
|
541 |
action $"Checking local filesystem quotas: " /sbin/quotacheck -anug
|
|
|
542 |
fi
|
|
|
543 |
|
|
|
544 |
if [ -x /sbin/quotaon ]; then
|
|
|
545 |
action $"Enabling local filesystem quotas: " /sbin/quotaon -aug
|
|
|
546 |
fi
|
|
|
547 |
|
4 |
- |
548 |
# Initialize pseudo-random number generator
|
|
|
549 |
if [ -f "/var/lib/random-seed" ]; then
|
|
|
550 |
cat /var/lib/random-seed > /dev/urandom
|
|
|
551 |
else
|
|
|
552 |
[ "$READONLY" != "yes" ] && touch /var/lib/random-seed
|
|
|
553 |
fi
|
|
|
554 |
if [ "$READONLY" != "yes" ]; then
|
|
|
555 |
chmod 600 /var/lib/random-seed
|
9 |
- |
556 |
dd if=/dev/urandom of=/var/lib/random-seed count=1 bs=4096 2>/dev/null
|
4 |
- |
557 |
fi
|
|
|
558 |
|
|
|
559 |
if [ -f /etc/crypttab ]; then
|
|
|
560 |
init_crypto 1
|
|
|
561 |
fi
|
|
|
562 |
|
|
|
563 |
# Configure machine if necessary.
|
|
|
564 |
if [ -f /.unconfigured ]; then
|
|
|
565 |
|
|
|
566 |
if [ -x /bin/plymouth ]; then
|
|
|
567 |
/bin/plymouth quit
|
|
|
568 |
fi
|
|
|
569 |
|
|
|
570 |
if [ -x /usr/bin/system-config-keyboard ]; then
|
|
|
571 |
/usr/bin/system-config-keyboard
|
|
|
572 |
fi
|
|
|
573 |
if [ -x /usr/bin/passwd ]; then
|
|
|
574 |
/usr/bin/passwd root
|
|
|
575 |
fi
|
|
|
576 |
if [ -x /usr/sbin/system-config-network-tui ]; then
|
|
|
577 |
/usr/sbin/system-config-network-tui
|
|
|
578 |
fi
|
|
|
579 |
if [ -x /usr/sbin/timeconfig ]; then
|
|
|
580 |
/usr/sbin/timeconfig
|
|
|
581 |
fi
|
|
|
582 |
if [ -x /usr/sbin/authconfig-tui ]; then
|
|
|
583 |
/usr/sbin/authconfig-tui --nostart
|
|
|
584 |
fi
|
|
|
585 |
if [ -x /usr/sbin/ntsysv ]; then
|
|
|
586 |
/usr/sbin/ntsysv --level 35
|
|
|
587 |
fi
|
|
|
588 |
|
|
|
589 |
# Reread in network configuration data.
|
|
|
590 |
if [ -f /etc/sysconfig/network ]; then
|
|
|
591 |
. /etc/sysconfig/network
|
|
|
592 |
|
|
|
593 |
# Reset the hostname.
|
|
|
594 |
action $"Resetting hostname ${HOSTNAME}: " hostname ${HOSTNAME}
|
|
|
595 |
fi
|
|
|
596 |
|
|
|
597 |
rm -f /.unconfigured
|
|
|
598 |
fi
|
|
|
599 |
|
|
|
600 |
# Clean out /.
|
|
|
601 |
rm -f /fastboot /fsckoptions /forcefsck /.autofsck /forcequotacheck /halt \
|
|
|
602 |
/poweroff /.suspended &> /dev/null
|
|
|
603 |
|
|
|
604 |
# Do we need (w|u)tmpx files? We don't set them up, but the sysadmin might...
|
|
|
605 |
_NEED_XFILES=
|
|
|
606 |
[ -f /var/run/utmpx -o -f /var/log/wtmpx ] && _NEED_XFILES=1
|
|
|
607 |
|
|
|
608 |
# Clean up /var.
|
|
|
609 |
rm -rf /var/lock/cvs/* /var/run/screen/*
|
|
|
610 |
find /var/lock /var/run ! -type d -exec rm -f {} \;
|
|
|
611 |
rm -f /var/lib/rpm/__db* &> /dev/null
|
|
|
612 |
rm -f /var/gdm/.gdmfifo &> /dev/null
|
|
|
613 |
|
|
|
614 |
[ "$PROMPT" != no ] && plymouth watch-keystroke --command "touch /var/run/confirm" --keys=Ii &
|
|
|
615 |
|
|
|
616 |
# Clean up utmp/wtmp
|
|
|
617 |
> /var/run/utmp
|
|
|
618 |
touch /var/log/wtmp
|
|
|
619 |
chgrp utmp /var/run/utmp /var/log/wtmp
|
|
|
620 |
chmod 0664 /var/run/utmp /var/log/wtmp
|
|
|
621 |
if [ -n "$_NEED_XFILES" ]; then
|
|
|
622 |
> /var/run/utmpx
|
|
|
623 |
touch /var/log/wtmpx
|
|
|
624 |
chgrp utmp /var/run/utmpx /var/log/wtmpx
|
|
|
625 |
chmod 0664 /var/run/utmpx /var/log/wtmpx
|
|
|
626 |
fi
|
|
|
627 |
[ -n "$SELINUX_STATE" ] && restorecon /var/run/utmp* /var/log/wtmp* >/dev/null 2>&1
|
|
|
628 |
|
|
|
629 |
# Clean up various /tmp bits
|
|
|
630 |
[ -n "$SELINUX_STATE" ] && restorecon /tmp
|
|
|
631 |
rm -f /tmp/.X*-lock /tmp/.lock.* /tmp/.gdm_socket /tmp/.s.PGSQL.*
|
|
|
632 |
rm -rf /tmp/.X*-unix /tmp/.ICE-unix /tmp/.font-unix /tmp/hsperfdata_* \
|
|
|
633 |
/tmp/kde-* /tmp/ksocket-* /tmp/mc-* /tmp/mcop-* /tmp/orbit-* \
|
|
|
634 |
/tmp/scrollkeeper-* /tmp/ssh-* \
|
|
|
635 |
/dev/.in_sysinit
|
|
|
636 |
|
|
|
637 |
# Make ICE directory
|
|
|
638 |
mkdir -m 1777 -p /tmp/.ICE-unix >/dev/null 2>&1
|
|
|
639 |
chown root:root /tmp/.ICE-unix
|
|
|
640 |
[ -n "$SELINUX_STATE" ] && restorecon /tmp/.ICE-unix >/dev/null 2>&1
|
|
|
641 |
|
|
|
642 |
# Start up swapping.
|
|
|
643 |
update_boot_stage RCswap
|
|
|
644 |
action $"Enabling /etc/fstab swaps: " swapon -a -e
|
|
|
645 |
if [ "$AUTOSWAP" = "yes" ]; then
|
|
|
646 |
curswap=$(awk '/^\/dev/ { print $1 }' /proc/swaps | while read x; do get_numeric_dev dec $x ; echo -n " "; done)
|
|
|
647 |
swappartitions=$(blkid -t TYPE=swap -o device)
|
|
|
648 |
if [ x"$swappartitions" != x ]; then
|
|
|
649 |
for partition in $swappartitions ; do
|
|
|
650 |
[ ! -e $partition ] && continue
|
|
|
651 |
majmin=$(get_numeric_dev dec $partition)
|
|
|
652 |
echo $curswap | grep -qw "$majmin" || action $"Enabling local swap partitions: " swapon $partition
|
|
|
653 |
done
|
|
|
654 |
fi
|
|
|
655 |
fi
|
|
|
656 |
|
|
|
657 |
# Set up binfmt_misc
|
|
|
658 |
/bin/mount -t binfmt_misc none /proc/sys/fs/binfmt_misc > /dev/null 2>&1
|
|
|
659 |
|
|
|
660 |
# Boot time profiles. Yes, this should be somewhere else.
|
|
|
661 |
if [ -x /usr/sbin/system-config-network-cmd ]; then
|
|
|
662 |
if strstr "$cmdline" netprofile= ; then
|
|
|
663 |
for arg in $cmdline ; do
|
|
|
664 |
if [ "${arg##netprofile=}" != "${arg}" ]; then
|
|
|
665 |
/usr/sbin/system-config-network-cmd --profile ${arg##netprofile=}
|
|
|
666 |
fi
|
|
|
667 |
done
|
|
|
668 |
fi
|
|
|
669 |
fi
|
|
|
670 |
|
|
|
671 |
# Now that we have all of our basic modules loaded and the kernel going,
|
|
|
672 |
# let's dump the syslog ring somewhere so we can find it later
|
|
|
673 |
[ -f /var/log/dmesg ] && mv -f /var/log/dmesg /var/log/dmesg.old
|
|
|
674 |
dmesg -s 131072 > /var/log/dmesg
|
|
|
675 |
|
|
|
676 |
# create the crash indicator flag to warn on crashes, offer fsck with timeout
|
|
|
677 |
touch /.autofsck &> /dev/null
|
|
|
678 |
|
|
|
679 |
[ "$PROMPT" != no ] && plymouth --ignore-keystroke=Ii
|
|
|
680 |
if strstr "$cmdline" confirm ; then
|
|
|
681 |
touch /var/run/confirm
|
|
|
682 |
fi
|
|
|
683 |
|
|
|
684 |
# Let rhgb know that we're leaving rc.sysinit
|
|
|
685 |
if [ -x /bin/plymouth ]; then
|
|
|
686 |
/bin/plymouth --sysinit
|
|
|
687 |
fi
|
|
|
688 |
|