|
|
f43afa |
From bb241c250cf74865382bfe099b550118d4badba0 Mon Sep 17 00:00:00 2001
|
|
|
f43afa |
From: Jonathan Lebon <jlebon@redhat.com>
|
|
|
f43afa |
Date: Wed, 26 Mar 2014 11:39:11 -0400
|
|
|
f43afa |
Subject: [PATCH] initscript: use new-kernel-pkg after dracut
|
|
|
f43afa |
|
|
|
f43afa |
With this patch, we now also call new-kernel-pkg --update after creating
|
|
|
f43afa |
the new image so that the bootloader is updated if need be (see also
|
|
|
f43afa |
BZ1051649#c9).
|
|
|
f43afa |
|
|
|
f43afa |
This patch also includes some polishing re. console log output.
|
|
|
f43afa |
---
|
|
|
f43afa |
initscript/systemtap.in | 54 ++++++++++++++++++++++++++++++++++++++++---------
|
|
|
f43afa |
1 file changed, 45 insertions(+), 9 deletions(-)
|
|
|
f43afa |
|
|
|
f43afa |
diff --git a/initscript/systemtap.in b/initscript/systemtap.in
|
|
|
f43afa |
index 21f9018..075226e 100755
|
|
|
f43afa |
--- a/initscript/systemtap.in
|
|
|
f43afa |
+++ b/initscript/systemtap.in
|
|
|
f43afa |
@@ -37,6 +37,7 @@ STAPRUN=@bindir@/staprun
|
|
|
f43afa |
UNAME=/bin/uname
|
|
|
f43afa |
LSMOD=/sbin/lsmod
|
|
|
f43afa |
DRACUT=/sbin/dracut
|
|
|
f43afa |
+NEWKERNELPKG=/usr/sbin/new-kernel-pkg
|
|
|
f43afa |
|
|
|
f43afa |
# Not actually used directly, but needed by
|
|
|
f43afa |
# stap dracut module for inclusion in initramfs
|
|
|
f43afa |
@@ -81,6 +82,7 @@ OPTS=
|
|
|
f43afa |
OPT_ASSUMEYES=
|
|
|
f43afa |
INITRAMFS=
|
|
|
f43afa |
BACKUP_INITRAMFS=
|
|
|
f43afa |
+EXPLICIT_INITRAMFS=
|
|
|
f43afa |
|
|
|
f43afa |
echo_usage () {
|
|
|
f43afa |
echo $"Usage: $prog {start|stop|status|restart|compile|onboot|cleanup|condrestart|try-restart|reload|force-reload} [OPTIONS] [SCRIPTS]"
|
|
|
f43afa |
@@ -202,6 +204,9 @@ parse_args $OPTS
|
|
|
f43afa |
# Set default output file if not given as an option
|
|
|
f43afa |
if [ ! "$INITRAMFS" ]; then
|
|
|
f43afa |
INITRAMFS=/boot/initramfs-$KRELEASE.img
|
|
|
f43afa |
+else
|
|
|
f43afa |
+ # User explicitly specified an img file to output to
|
|
|
f43afa |
+ EXPLICIT_INITRAMFS=1
|
|
|
f43afa |
fi
|
|
|
f43afa |
|
|
|
f43afa |
# Include configs
|
|
|
f43afa |
@@ -738,9 +743,9 @@ compile () {
|
|
|
f43afa |
return 0
|
|
|
f43afa |
}
|
|
|
f43afa |
|
|
|
f43afa |
-# Writes info to $DRACUT_SRC, which the stap dracut module will source
|
|
|
f43afa |
+# Writes info to $DRACUT_SRC, which the stap dracut module will source.
|
|
|
f43afa |
# Includes all needed info such as location of stap/staprun, which
|
|
|
f43afa |
-# scripts to insert, and their options
|
|
|
f43afa |
+# scripts to insert, and their options.
|
|
|
f43afa |
update_dracut() { # scripts
|
|
|
f43afa |
local s opts
|
|
|
f43afa |
|
|
|
f43afa |
@@ -773,20 +778,29 @@ update_dracut() { # scripts
|
|
|
f43afa |
backup_initramfs() {
|
|
|
f43afa |
# does target file exist?
|
|
|
f43afa |
if [ -f "$INITRAMFS" ]; then
|
|
|
f43afa |
+ clog
|
|
|
f43afa |
# don't overwrite an existing backup
|
|
|
f43afa |
if [ ! -f "$INITRAMFS.bak" ]; then
|
|
|
f43afa |
mv "$INITRAMFS" "$INITRAMFS.bak"
|
|
|
f43afa |
- clog "Renamed $INITRAMFS"
|
|
|
f43afa |
- clog " to $INITRAMFS.bak"
|
|
|
f43afa |
+ clog " Renamed $INITRAMFS"
|
|
|
f43afa |
+ clog " to $INITRAMFS.bak ... " -n
|
|
|
f43afa |
RESTORE_INITRAMFS_ON_FAIL=1
|
|
|
f43afa |
else
|
|
|
f43afa |
- clog "Backup already exists: $INITRAMFS.bak"
|
|
|
f43afa |
+ clog " Backup already exists: $INITRAMFS.bak ... " -n
|
|
|
f43afa |
fi
|
|
|
f43afa |
fi
|
|
|
f43afa |
}
|
|
|
f43afa |
|
|
|
f43afa |
onboot () {
|
|
|
f43afa |
local s ret ss
|
|
|
f43afa |
+ if [ ! -f "$NEWKERNELPKG" ]; then
|
|
|
f43afa |
+ clog "Could not find $NEWKERNELPKG" -n
|
|
|
f43afa |
+ do_failure "$NEWKERNELPKG not found"
|
|
|
f43afa |
+ clog
|
|
|
f43afa |
+ clog "This feature requires $NEWKERNELPKG."
|
|
|
f43afa |
+ clog "If it is located elsewhere, modify the \$NEWKERNELPKG parameter" -n
|
|
|
f43afa |
+ return 1
|
|
|
f43afa |
+ fi
|
|
|
f43afa |
if [ ! -f "$DRACUT" ]; then
|
|
|
f43afa |
clog "Could not find $DRACUT" -n
|
|
|
f43afa |
do_failure "$DRACUT not found"
|
|
|
f43afa |
@@ -845,6 +859,9 @@ onboot () {
|
|
|
f43afa |
do_failure "Failed to make temporary file in $dir"
|
|
|
f43afa |
return 1
|
|
|
f43afa |
fi
|
|
|
f43afa |
+ # Create the initramfs image. We could have combined this with the
|
|
|
f43afa |
+ # new-kernel-pkg call below using --dracut, but then we would have
|
|
|
f43afa |
+ # lost error-checking and our backing up facilities.
|
|
|
f43afa |
out=$($DRACUT --force $TMPINITRAMFS $KRELEASE 2>&1)
|
|
|
f43afa |
# dracut will report success even if some modules (e.g. stap) failed
|
|
|
f43afa |
# to install some files, so we need to be a bit more involved in
|
|
|
f43afa |
@@ -856,7 +873,7 @@ onboot () {
|
|
|
f43afa |
else
|
|
|
f43afa |
do_failure "See dracut log for more info"
|
|
|
f43afa |
fi
|
|
|
f43afa |
- echo # We need a new line
|
|
|
f43afa |
+ clog
|
|
|
f43afa |
if [ -f "$TMPINITRAMFS" ]; then
|
|
|
f43afa |
rm "$TMPINITRAMFS"
|
|
|
f43afa |
fi
|
|
|
f43afa |
@@ -864,13 +881,32 @@ onboot () {
|
|
|
f43afa |
# whatever initramfs they used to boot in is still there)
|
|
|
f43afa |
if [ "$RESTORE_INITRAMFS_ON_FAIL" ]; then
|
|
|
f43afa |
mv "$INITRAMFS.bak" "$INITRAMFS"
|
|
|
f43afa |
- clog "Renamed $INITRAMFS.bak"
|
|
|
f43afa |
- clog " to $INITRAMFS"
|
|
|
f43afa |
+ clog " Renamed $INITRAMFS.bak"
|
|
|
f43afa |
+ clog " to $INITRAMFS"
|
|
|
f43afa |
fi
|
|
|
f43afa |
return 1
|
|
|
f43afa |
fi
|
|
|
f43afa |
mv "$TMPINITRAMFS" "$INITRAMFS"
|
|
|
f43afa |
- might_success "initramfs created"
|
|
|
f43afa |
+ # The initramfs is in place. If the user explicitly specified an
|
|
|
f43afa |
+ # output file using -o, then we should skip updating the bootloader
|
|
|
f43afa |
+ # (the output file may not even be in /boot/).
|
|
|
f43afa |
+ if [ "$EXPLICIT_INITRAMFS" ]; then
|
|
|
f43afa |
+ might_success "initramfs created"
|
|
|
f43afa |
+ clog
|
|
|
f43afa |
+ clog "NB: bootloader was not updated" -n
|
|
|
f43afa |
+ return 0
|
|
|
f43afa |
+ fi
|
|
|
f43afa |
+ clog "done"
|
|
|
f43afa |
+ # We're installing the initramfs in the default location, so user
|
|
|
f43afa |
+ # expects the next boot to use it. Let's also update the bootloader.
|
|
|
f43afa |
+ clog " Updating bootloader ... " -n
|
|
|
f43afa |
+ logex $NEWKERNELPKG --initrdfile="$INITRAMFS" \
|
|
|
f43afa |
+ --update $KRELEASE
|
|
|
f43afa |
+ if [ $? -ne 0 ]; then
|
|
|
f43afa |
+ do_failure "$NEWKERNELPKG exited with nonzero status"
|
|
|
f43afa |
+ return 1
|
|
|
f43afa |
+ fi
|
|
|
f43afa |
+ might_success "initramfs created and bootloader updated"
|
|
|
f43afa |
return 0
|
|
|
f43afa |
}
|
|
|
f43afa |
|
|
|
f43afa |
--
|
|
|
f43afa |
1.8.3.1
|
|
|
f43afa |
|