Starting mkdumprd2 -> dracut conversion
This commit is contained in:
parent
377434b49f
commit
4049dbdcd9
@ -8,3 +8,4 @@ makedumpfile-1.2.6.tar.gz
|
||||
kexec-tools-2.0.0.tar.bz2
|
||||
makedumpfile-1.3.3.tar.gz
|
||||
mkdumprd2-files.tbz2
|
||||
dracut-files.tbz2
|
||||
|
8
Makefile
8
Makefile
@ -20,14 +20,12 @@ endef
|
||||
MAKEFILE_COMMON := $(shell $(checkout-makefile-common))
|
||||
endif
|
||||
|
||||
mkdumprd2_tarball:
|
||||
dracut_tarball:
|
||||
mkdir stage
|
||||
ln -s ../kdump_build_helpers stage/kdump_build_helpers
|
||||
ln -s ../kdump_runtime_helpers stage/kdump_runtime_helpers
|
||||
ln -s ../kdump_initscripts stage/kdump_initscripts
|
||||
ln -s ../kdump_sample_manifests stage/kdump_sample_manifests
|
||||
ln -s ../mkdumprd2_functions stage/mkdumprd2_functions
|
||||
tar -C stage -j -h -c --exclude=CVS -f ./mkdumprd2-files.tbz2 .
|
||||
ln -s ../kdump_dracut_modules stage/kdump_dracut_modules
|
||||
tar -C stage -j -h -c --exclude=CVS -f ./dracut-files.tbz2 .
|
||||
rm -rf stage
|
||||
|
||||
include $(MAKEFILE_COMMON)
|
||||
|
13
kdump.init
13
kdump.init
@ -53,15 +53,20 @@ function save_core()
|
||||
|
||||
function check_config()
|
||||
{
|
||||
if [ -f /etc/kdump-adv-conf ]
|
||||
if [ -f /etc/kdump-adv-conf/initramfs.conf ]
|
||||
then
|
||||
$LOGGER "Using Kdump advanced configuration service"
|
||||
MKDUMPRD=/sbin/mkdumprd2
|
||||
if [ -n "DRACUT_CMD" ]
|
||||
then
|
||||
MKDUMPRD=$DRACUT_CMD
|
||||
else
|
||||
MKDUMPRD="dracut -c /etc/kdump-adv-conf/initramfs.conf"
|
||||
fi
|
||||
# We always rebuild here, since it takes longer
|
||||
# to figure out if anything has changed
|
||||
touch /etc/kdump.conf
|
||||
else
|
||||
MKDUMPRD=/sbin/mkdumprd
|
||||
MKDUMPRD="/sbin/mkdumprd -d -f"
|
||||
fi
|
||||
|
||||
if [ -z "$KDUMP_KERNELVER" ]; then
|
||||
@ -84,7 +89,7 @@ function check_config()
|
||||
if [ ! -f $kdump_initrd ]; then
|
||||
echo -n "No kdump initial ramdisk found."; warning; echo
|
||||
echo "Rebuilding $kdump_initrd"
|
||||
$MKDUMPRD -d -f $kdump_initrd $kdump_kver
|
||||
$MKDUMPRD $kdump_initrd $kdump_kver
|
||||
if [ $? != 0 ]; then
|
||||
echo "Failed to run mkdumprd"
|
||||
$LOGGER "mkdumprd: failed to make kdump initrd"
|
||||
|
3
kdump_dracut_modules/99kdumpbase/check
Executable file
3
kdump_dracut_modules/99kdumpbase/check
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
[[ $1 = -d ]] && echo udev-rules
|
||||
exit 0
|
108
kdump_dracut_modules/99kdumpbase/dracut-lib.sh
Normal file
108
kdump_dracut_modules/99kdumpbase/dracut-lib.sh
Normal file
@ -0,0 +1,108 @@
|
||||
getarg() {
|
||||
local o line
|
||||
if [ -z "$CMDLINE" ]; then
|
||||
read CMDLINE_ETC </etc/cmdline;
|
||||
read CMDLINE </proc/cmdline;
|
||||
CMDLINE="$CMDLINE $CMDLINE_ETC"
|
||||
fi
|
||||
for o in $CMDLINE; do
|
||||
[ "$o" = "$1" ] && return 0
|
||||
[ "${o%%=*}" = "${1%=}" ] && { echo ${o#*=}; return 0; }
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
getargs() {
|
||||
local o line found
|
||||
if [ -z "$CMDLINE" ]; then
|
||||
read CMDLINE_ETC </etc/cmdline;
|
||||
read CMDLINE </proc/cmdline;
|
||||
CMDLINE="$CMDLINE $CMDLINE_ETC"
|
||||
fi
|
||||
for o in $CMDLINE; do
|
||||
[ "$o" = "$1" ] && return 0
|
||||
if [ "${o%%=*}" = "${1%=}" ]; then
|
||||
echo -n "${o#*=} ";
|
||||
found=1;
|
||||
fi
|
||||
done
|
||||
[ -n "$found" ] && return 0
|
||||
return 1
|
||||
}
|
||||
|
||||
source_all() {
|
||||
local f
|
||||
[ "$1" ] && [ -d "/$1" ] || return
|
||||
for f in "/$1"/*.sh; do [ -f "$f" ] && . "$f"; done
|
||||
}
|
||||
|
||||
source_conf() {
|
||||
local f
|
||||
[ "$1" ] && [ -d "/$1" ] || return
|
||||
for f in "/$1"/*.conf; do [ -f "$f" ] && . "$f"; done
|
||||
}
|
||||
|
||||
die() {
|
||||
{
|
||||
echo "<1>dracut: FATAL: $@";
|
||||
echo "<1>dracut: Refusing to continue";
|
||||
} > /dev/kmsg
|
||||
|
||||
{
|
||||
echo "dracut: FATAL: $@";
|
||||
echo "dracut: Refusing to continue";
|
||||
} >&2
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
||||
warn() {
|
||||
echo "<4>dracut Warning: $@" > /dev/kmsg
|
||||
echo "dracut Warning: $@" >&2
|
||||
}
|
||||
|
||||
info() {
|
||||
if [ -z "$DRACUT_QUIET" ]; then
|
||||
DRACUT_QUIET="no"
|
||||
getarg quiet && DRACUT_QUIET="yes"
|
||||
fi
|
||||
echo "<6>dracut: $@" > /dev/kmsg
|
||||
[ "$DRACUT_QUIET" != "yes" ] && \
|
||||
echo "dracut: $@"
|
||||
}
|
||||
|
||||
vinfo() {
|
||||
while read line; do
|
||||
info $line;
|
||||
done
|
||||
}
|
||||
|
||||
check_occurances() {
|
||||
# Count the number of times the character $ch occurs in $str
|
||||
# Return 0 if the count matches the expected number, 1 otherwise
|
||||
local str="$1"
|
||||
local ch="$2"
|
||||
local expected="$3"
|
||||
local count=0
|
||||
|
||||
while [ "${str#*$ch}" != "${str}" ]; do
|
||||
str="${str#*$ch}"
|
||||
count=$(( $count + 1 ))
|
||||
done
|
||||
|
||||
[ $count -eq $expected ]
|
||||
}
|
||||
|
||||
incol2() {
|
||||
local dummy check;
|
||||
local file="$1";
|
||||
local str="$2";
|
||||
|
||||
[ -z "$file" ] && return;
|
||||
[ -z "$str" ] && return;
|
||||
|
||||
while read dummy check restofline; do
|
||||
[ "$check" = "$str" ] && return 0
|
||||
done < $file
|
||||
return 1
|
||||
}
|
12
kdump_dracut_modules/99kdumpbase/initqueue
Executable file
12
kdump_dracut_modules/99kdumpbase/initqueue
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "$1" = "--onetime" ]; then
|
||||
onetime="yes"
|
||||
shift
|
||||
fi
|
||||
echo "$@" > /tmp/$$.sh
|
||||
if [ -n "$onetime" ]; then
|
||||
echo '[ -e "$job" ] && rm "$job"' >> /tmp/$$.sh
|
||||
fi
|
||||
mv /tmp/$$.sh /initqueue/
|
||||
>> /initqueue/work
|
23
kdump_dracut_modules/99kdumpbase/install
Executable file
23
kdump_dracut_modules/99kdumpbase/install
Executable file
@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
dracut_install mount mknod mkdir modprobe pidof sleep chroot \
|
||||
sed ls flock cp mv dmesg rm ln
|
||||
if [ ! -e "${initdir}/bin/sh" ]; then
|
||||
dracut_install bash
|
||||
(ln -s bash "${initdir}/bin/sh" || :)
|
||||
fi
|
||||
# install our scripts and hooks
|
||||
inst "/etc/kdump-adv-conf/init" "/init"
|
||||
inst "$moddir/initqueue" "/sbin/initqueue"
|
||||
mkdir -p ${initdir}/initqueue
|
||||
mkdir -p ${initdir}/tmp
|
||||
# Bail out if switch_root does not exist
|
||||
if which switch_root >/dev/null 2>&1; then
|
||||
dracut_install switch_root
|
||||
else
|
||||
inst "$moddir/switch_root" "/sbin/switch_root" \
|
||||
|| derror "Failed to install switch_root"
|
||||
fi
|
||||
inst "$moddir/dracut-lib.sh" "/lib/dracut-lib.sh"
|
||||
inst_hook cmdline 10 "$moddir/parse-root-opts.sh"
|
||||
inst_hook cmdline 20 "$moddir/parse-blacklist.sh"
|
||||
inst_hook pre-pivot 50 "$moddir/selinux-loadpolicy.sh"
|
5
kdump_dracut_modules/99kdumpbase/parse-blacklist.sh
Executable file
5
kdump_dracut_modules/99kdumpbase/parse-blacklist.sh
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
for p in $(getargs rdblacklist=); do
|
||||
echo "blacklist $p" >> /etc/modprobe.d/initramfsblacklist.conf
|
||||
done
|
13
kdump_dracut_modules/99kdumpbase/parse-root-opts.sh
Normal file
13
kdump_dracut_modules/99kdumpbase/parse-root-opts.sh
Normal file
@ -0,0 +1,13 @@
|
||||
root=$(getarg root=)
|
||||
|
||||
if rflags="$(getarg rootflags=)"; then
|
||||
getarg rw && rflags="${rflags},rw" || rflags="${rflags},ro"
|
||||
else
|
||||
getarg rw && rflags=rw || rflags=ro
|
||||
fi
|
||||
|
||||
fstype="$(getarg rootfstype=)"
|
||||
if [ -z "$fstype" ]; then
|
||||
fstype="auto"
|
||||
fi
|
||||
|
11
kdump_dracut_modules/99kdumpbase/selinux-loadpolicy.sh
Executable file
11
kdump_dracut_modules/99kdumpbase/selinux-loadpolicy.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
# FIXME: load selinux policy. this should really be done after we switchroot
|
||||
if [ -x "$NEWROOT/usr/sbin/load_policy" ] && [ -e "$NEWROOT/etc/sysconfig/selinux" ]; then
|
||||
chroot $NEWROOT /usr/sbin/load_policy -i
|
||||
if [ $? -eq 3 ]; then
|
||||
echo "Initial SELinux policy load failed and enforcing mode requested."
|
||||
echo "Not continuing"
|
||||
sleep 100d
|
||||
exit 1
|
||||
fi
|
||||
fi
|
233
kdump_initscripts/init
Executable file
233
kdump_initscripts/init
Executable file
@ -0,0 +1,233 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Licensed under the GPLv2
|
||||
#
|
||||
# Copyright 2008, Red Hat, Inc.
|
||||
# Jeremy Katz <katzj@redhat.com>
|
||||
|
||||
emergency_shell()
|
||||
{
|
||||
exec >/dev/console 2>&1 </dev/console
|
||||
echo ; echo
|
||||
echo $@
|
||||
source_all emergency
|
||||
echo
|
||||
if getarg rdshell || getarg rdbreak; then
|
||||
echo "Dropping to debug shell."
|
||||
echo
|
||||
sh -i
|
||||
else
|
||||
echo "Boot has failed, sleeping forever."
|
||||
while :; do sleep 365d;done
|
||||
fi
|
||||
}
|
||||
|
||||
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
||||
export TERM=linux
|
||||
NEWROOT="/sysroot"
|
||||
|
||||
trap "emergency_shell Signal caught!" 0
|
||||
|
||||
. /lib/dracut-lib.sh
|
||||
|
||||
mknod /dev/null c 1 3
|
||||
|
||||
# mount some important things
|
||||
mount -t proc /proc /proc >/dev/null 2>&1
|
||||
mount -t sysfs /sys /sys >/dev/null 2>&1
|
||||
|
||||
if [ ! -c /dev/ptmx ]; then
|
||||
# try to mount devtmpfs
|
||||
if ! mount -t devtmpfs -omode=0755 udev /dev >/dev/null 2>&1; then
|
||||
# if it failed fall back to normal tmpfs
|
||||
mount -t tmpfs -omode=0755 udev /dev >/dev/null 2>&1
|
||||
# Make some basic devices first, let udev handle the rest
|
||||
mknod /dev/null c 1 3
|
||||
mknod /dev/ptmx c 5 2
|
||||
mknod /dev/console c 5 1
|
||||
mknod /dev/kmsg c 1 11
|
||||
fi
|
||||
fi
|
||||
|
||||
if getarg rdinitdebug; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
mkdir /dev/shm
|
||||
mkdir /dev/pts
|
||||
mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts >/dev/null 2>&1
|
||||
|
||||
UDEVVERSION=$(udevadm --version)
|
||||
|
||||
source_conf /etc/conf.d
|
||||
|
||||
# run scriptlets to parse the command line
|
||||
getarg 'rdbreak=cmdline' && emergency_shell "Break before cmdline"
|
||||
source_all cmdline
|
||||
|
||||
[ -z "$root" ] && die "No or empty root= argument"
|
||||
[ -z "$rootok" ] && die "Don't know how to handle 'root=$root'"
|
||||
|
||||
# Network root scripts may need updated root= options,
|
||||
# so deposit them where they can see them (udev purges the env)
|
||||
{
|
||||
echo "root='$root'"
|
||||
echo "rflags='$rflags'"
|
||||
echo "fstype='$fstype'"
|
||||
echo "netroot='$netroot'"
|
||||
echo "NEWROOT='$NEWROOT'"
|
||||
} > /tmp/root.info
|
||||
|
||||
# pre-udev scripts run before udev starts, and are run only once.
|
||||
getarg 'rdbreak=pre-udev' && emergency_shell "Break before pre-udev"
|
||||
source_all pre-udev
|
||||
|
||||
# start up udev and trigger cold plugs
|
||||
udevd --daemon
|
||||
|
||||
UDEV_LOG_PRIO_ARG=--log-priority
|
||||
UDEV_QUEUE_EMPTY="udevadm settle --timeout=0"
|
||||
|
||||
if [ $UDEVVERSION -lt 140 ]; then
|
||||
UDEV_LOG_PRIO_ARG=--log_priority
|
||||
UDEV_QUEUE_EMPTY="udevadm settle --timeout=1"
|
||||
fi
|
||||
|
||||
getarg rdudevinfo && udevadm control $UDEV_LOG_PRIO_ARG=info
|
||||
getarg rdudevdebug && udevadm control $UDEV_LOG_PRIO_ARG=debug
|
||||
|
||||
getarg 'rdbreak=pre-trigger' && emergency_shell "Break before pre-trigger"
|
||||
source_all pre-trigger
|
||||
|
||||
# then the rest
|
||||
udevadm trigger $udevtriggeropts >/dev/null 2>&1
|
||||
|
||||
getarg 'rdbreak=initqueue' && emergency_shell "Break before initqueue"
|
||||
|
||||
i=0
|
||||
while :; do
|
||||
# bail out, if we have mounted the root filesystem
|
||||
[ -d "$NEWROOT/proc" ] && break;
|
||||
|
||||
# check if root can be mounted
|
||||
[ -e /dev/root ] && break;
|
||||
|
||||
if [ $UDEVVERSION -ge 143 ]; then
|
||||
udevadm settle --exit-if-exists=/initqueue/work --exit-if-exists=/dev/root
|
||||
else
|
||||
udevadm settle --timeout=30
|
||||
fi
|
||||
|
||||
# bail out, if we have mounted the root filesystem
|
||||
[ -d "$NEWROOT/proc" ] && break;
|
||||
# check if root can be mounted
|
||||
[ -e /dev/root ] && break;
|
||||
|
||||
unset queuetriggered
|
||||
if [ -f /initqueue/work ]; then
|
||||
rm /initqueue/work
|
||||
queuetriggered="1"
|
||||
fi
|
||||
|
||||
for job in /initqueue/*.sh; do
|
||||
[ -e "$job" ] || break
|
||||
job=$job . $job
|
||||
|
||||
# bail out, if we have mounted the root filesystem
|
||||
[ -d "$NEWROOT/proc" ] && break;
|
||||
# check if root can be mounted
|
||||
[ -e /dev/root ] && break;
|
||||
done
|
||||
|
||||
[ -n "$queuetriggered" ] && continue
|
||||
|
||||
if $UDEV_QUEUE_EMPTY >/dev/null 2>&1; then
|
||||
# no more udev jobs
|
||||
sleep 0.5
|
||||
i=$(($i+1))
|
||||
[ $i -gt 20 ] \
|
||||
&& { flock -s 9 ; emergency_shell "No root device found"; } 9>/.console_lock
|
||||
fi
|
||||
done
|
||||
unset job
|
||||
unset queuetriggered
|
||||
|
||||
# pre-mount happens before we try to mount the root filesystem,
|
||||
# and happens once.
|
||||
getarg 'rdbreak=pre-mount' && emergency_shell "Break pre-mount"
|
||||
source_all pre-mount
|
||||
|
||||
|
||||
getarg 'rdbreak=mount' && emergency_shell "Break mount"
|
||||
# mount scripts actually try to mount the root filesystem, and may
|
||||
# be sourced any number of times. As soon as one suceeds, no more are sourced.
|
||||
i=0
|
||||
while :; do
|
||||
[ -d "$NEWROOT/proc" ] && break;
|
||||
for f in /mount/*.sh; do
|
||||
[ -f "$f" ] && . "$f"
|
||||
[ -d "$NEWROOT/proc" ] && break;
|
||||
done
|
||||
|
||||
i=$(($i+1))
|
||||
[ $i -gt 20 ] \
|
||||
&& { flock -s 9 ; emergency_shell "Can't mount root filesystem"; } 9>/.console_lock
|
||||
done
|
||||
|
||||
# pre pivot scripts are sourced just before we switch over to the new root.
|
||||
getarg 'rdbreak=pre-pivot' && emergency_shell "Break pre-pivot"
|
||||
source_all pre-pivot
|
||||
|
||||
# by the time we get here, the root filesystem should be mounted.
|
||||
# Try to find init.
|
||||
for i in "$(getarg init=)" /sbin/init /etc/init /init /bin/sh; do
|
||||
[ -f "$NEWROOT$i" -a -x "$NEWROOT$i" ] && { INIT="$i"; break; }
|
||||
done
|
||||
[ "$INIT" ] || {
|
||||
echo "Cannot find init!"
|
||||
echo "Please check to make sure you passed a valid root filesystem!"
|
||||
emergency_shell
|
||||
}
|
||||
|
||||
getarg rdbreak && emergency_shell "Break before switch_root"
|
||||
|
||||
HARD=""
|
||||
while pidof udevd >/dev/null 2>&1; do
|
||||
for pid in $(pidof udevd); do
|
||||
kill $HARD $pid >/dev/null 2>&1
|
||||
done
|
||||
HARD="-9"
|
||||
done
|
||||
|
||||
# Clean up the environment
|
||||
for i in $(export -p); do
|
||||
i=${i#declare -x}
|
||||
i=${i#export}
|
||||
i=${i%%=*}
|
||||
[ "$i" = "root" -o "$i" = "PATH" -o "$i" = "HOME" -o "$i" = "TERM" ] || unset $i
|
||||
done
|
||||
|
||||
initargs=""
|
||||
initrdargs="$initrdargs console BOOT_IMAGE rdbreak rdinitdebug rdudevinfo rdudevdebug rdnetdebug rdcopystate rdshell"
|
||||
|
||||
for x in "$@"; do
|
||||
for s in $initrdargs; do
|
||||
[ "${x%%=*}" = $s ] && continue 2
|
||||
done
|
||||
initargs="$initargs $x"
|
||||
done
|
||||
|
||||
# Copy state
|
||||
mkdir /dev/.initramfs/
|
||||
if getarg rdcopystate; then
|
||||
cp /tmp/* /dev/.initramfs/ >/dev/null 2>&1
|
||||
else
|
||||
cp /tmp/net.* /dev/.initramfs/ >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
exec switch_root "$NEWROOT" "$INIT" $initargs || {
|
||||
# davej doesn't like initrd bugs
|
||||
echo "Something went very badly wrong in the initrd. Please "
|
||||
echo "file a bug against mkinitrd."
|
||||
emergency_shell
|
||||
}
|
@ -1,87 +1,9 @@
|
||||
######################################################
|
||||
# Generic kdump initramfs manifest
|
||||
# 1) Loads all modules
|
||||
# 2) Starts all mdraid, lvm partitions
|
||||
# 3) Mounts the rootfs
|
||||
# 4) Copies /proc/vmcore to /mnt/var/crash/<date>/vmcore
|
||||
#########################################################
|
||||
# Sample manifest for default kdump configuration
|
||||
#
|
||||
# Notes on syntax:
|
||||
# There are 6 major commands to use when generating manifest files
|
||||
# They are:
|
||||
# 1) reg
|
||||
# reg <source file> <dest path>
|
||||
# A regular file copy from the source to the dst directory
|
||||
#
|
||||
# 2) creg
|
||||
# creg <source file> <dest path>
|
||||
# like reg, but only copy if the source file exists
|
||||
#
|
||||
# 3) ren
|
||||
# ren <src file> <dst file>
|
||||
# rename a file into the initramfs
|
||||
#
|
||||
# 4) cren
|
||||
# cren <src file> <dst file>
|
||||
# like creg, but rename the dst file
|
||||
#
|
||||
# 5) gen
|
||||
# gen <binary> <dst file> <options>
|
||||
# execute the specified binary, redirecting stdout to <dst>
|
||||
#
|
||||
# 6) exec
|
||||
# exec <binary> <options>
|
||||
# execute the specified binary. Option 1 is the
|
||||
# base dir where the initramfs is being built
|
||||
# $1/temp is temp file space, $1/stage is the initramfs
|
||||
# options passed on command line after that
|
||||
#####################################################
|
||||
|
||||
####################################################
|
||||
#This script populates the initramfs with:
|
||||
# busybox
|
||||
# kpartx
|
||||
# lvm
|
||||
# dmsetup
|
||||
# It also symlinks all the supported apps in busybox to
|
||||
# busybox
|
||||
####################################################
|
||||
exec populate_kdump_std_files
|
||||
# This manifest will build an initramfs which mounts the
|
||||
# root filesystem and switchroots to it
|
||||
#########################################################
|
||||
|
||||
|
||||
####################################################
|
||||
# Pull in udev so that we can easily setup block
|
||||
# devices for lvm and all that
|
||||
####################################################
|
||||
exec populate_udev_files
|
||||
|
||||
####################################################
|
||||
# This is a rudimentary module population script
|
||||
# It looks at the currently loaded modules, copies them
|
||||
# To the initramfs, and generates /etc/module_load_list
|
||||
# which is a dependency ordered list of those modules
|
||||
# which can be used at runtime for module loading
|
||||
###################################################
|
||||
exec generate_module_list
|
||||
|
||||
###################################################
|
||||
# Lets get all our lvm and mdraid configs on board
|
||||
###################################################
|
||||
creg /etc/lvm/lvm.conf /etc/lvm
|
||||
creg /etc/mdadm.conf /etc
|
||||
|
||||
###################################################
|
||||
# Grab fstab, modifying it to mount under /mnt
|
||||
###################################################
|
||||
gen awk /etc/fstab '/^[^#]/{print $1 " /mnt"$2 " "$3 " "$4 " "$5 " "$6}' /etc/fstab
|
||||
|
||||
###################################################
|
||||
# Grab /etc/clock so we can set the clock properly
|
||||
###################################################
|
||||
creg /etc/clock /etc
|
||||
|
||||
###################################################
|
||||
# Grab the standard initscript to capture to the local
|
||||
# rootfs
|
||||
###################################################
|
||||
#
|
||||
ren /etc/kdump-adv-conf/kdump_initscripts/kdumpinit.rootfs /init
|
||||
dracutmodules="base crypt lvm kernel-modules rootfs-block udev-rules"
|
||||
|
@ -1,6 +1,6 @@
|
||||
Name: kexec-tools
|
||||
Version: 2.0.0
|
||||
Release: 22%{?dist}
|
||||
Release: 23%{?dist}
|
||||
License: GPLv2
|
||||
Group: Applications/System
|
||||
Summary: The kexec/kdump userspace component.
|
||||
@ -24,8 +24,7 @@ Source14: 98-kexec.rules
|
||||
# These are sources for mkdumprd2
|
||||
# Which is currently in development
|
||||
#######################################
|
||||
Source100: mkdumprd2-files.tbz2
|
||||
Source101: mkdumprd2
|
||||
Source100: dracut-files.tbz2
|
||||
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
Requires(pre): coreutils chkconfig sed zlib
|
||||
@ -148,10 +147,13 @@ install -m 755 makedumpfile-1.3.3/makedumpfile $RPM_BUILD_ROOT/sbin/makedumpfile
|
||||
make -C kexec-tools-po install DESTDIR=$RPM_BUILD_ROOT
|
||||
%find_lang %{name}
|
||||
|
||||
# untar the mkdumprd2 package
|
||||
# untar the dracut package
|
||||
mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf
|
||||
tar -C $RPM_BUILD_ROOT/etc/kdump-adv-conf -jxvf %{SOURCE100}
|
||||
install -m 755 %{SOURCE101} $RPM_BUILD_ROOT/sbin
|
||||
|
||||
#and move the custom dracut modules to the dracut directory
|
||||
mkdir -p $RPM_BUILD_ROOT/usr/share/dracut/modules.d/
|
||||
mv $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/* $RPM_BUILD_ROOT/usr/share/dracut/modules.d/
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
@ -245,13 +247,11 @@ done
|
||||
%{_datadir}/kdump
|
||||
%config(noreplace,missingok) %{_sysconfdir}/sysconfig/kdump
|
||||
%config(noreplace,missingok) %{_sysconfdir}/kdump.conf
|
||||
%{_sysconfdir}/kdump-adv-conf/kdump_build_helpers/
|
||||
%{_sysconfdir}/kdump-adv-conf/kdump_runtime_helpers/
|
||||
%{_sysconfdir}/kdump-adv-conf/kdump_initscripts/
|
||||
%{_sysconfdir}/kdump-adv-conf/kdump_sample_manifests/
|
||||
%{_sysconfdir}/kdump-adv-conf/mkdumprd2_functions
|
||||
%config %{_sysconfdir}/rc.d/init.d/kdump
|
||||
%config %{_sysconfdir}/udev/rules.d/*
|
||||
%{_datadir}/dracut/modules.d/*
|
||||
%dir %{_localstatedir}/crash
|
||||
%{_mandir}/man8/*
|
||||
%doc News
|
||||
@ -261,6 +261,9 @@ done
|
||||
|
||||
|
||||
%changelog
|
||||
* Wed Jul 29 2009 Neil Horman <nhorman@redhat.com> - 2.0,0-23
|
||||
- Remove mkdumprd2 and start replacement with dracut
|
||||
|
||||
* Fri Jul 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.0.0-22
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild
|
||||
|
||||
|
358
mkdumprd2
358
mkdumprd2
@ -1,358 +0,0 @@
|
||||
#!/bin/sh
|
||||
##########################################################
|
||||
#File: mkdumprd2
|
||||
#Author: Neil Horman <nhorman@redhat.com>
|
||||
#Copyright 2009 Red Hat, Inc.
|
||||
#Summary: A vastly simplified infrastructure for creating
|
||||
# initramfs files for use with kdump
|
||||
#########################################################
|
||||
|
||||
. /etc/kdump-adv-conf/mkdumprd2_functions
|
||||
|
||||
########################################################
|
||||
#Global Variables
|
||||
########################################################
|
||||
#BASE_DIR is the parent of both TEMP_DIR and STAGE_DIR
|
||||
BASE_DIR=""
|
||||
|
||||
#TEMP_DIR is the directory where any temp files that we
|
||||
# create during the build process go, that we
|
||||
# do not want to wind up in our initramfs
|
||||
TEMP_DIR=""
|
||||
|
||||
#STAGE_DIR is the directory we create to do all our
|
||||
# initramfs creation in
|
||||
STAGE_DIR=""
|
||||
|
||||
#IMG_FILE is the file that is our initramfs after cpio
|
||||
IMG_FILE=""
|
||||
|
||||
########################################################
|
||||
#Cleanup functions so that we can get out easily and
|
||||
#sanely when something goes wrong
|
||||
########################################################
|
||||
finish_and_exit()
|
||||
{
|
||||
local EXIT_CODE=$1
|
||||
local EXIT_MSG=$2
|
||||
|
||||
if [ -n "$EXIT_MSG" ]
|
||||
then
|
||||
echo $EXIT_MSG
|
||||
fi
|
||||
exit $EXIT_CODE
|
||||
}
|
||||
|
||||
|
||||
|
||||
#########################################################
|
||||
#Clean up our various temporary files
|
||||
#And exit
|
||||
########################################################
|
||||
cleanup_and_exit()
|
||||
{
|
||||
EXIT_CODE=$1
|
||||
|
||||
if [ -d $BASE_DIR ]
|
||||
then
|
||||
rm -rf $BASE_DIR
|
||||
fi
|
||||
|
||||
if [ -f $IMG_FILE ]
|
||||
then
|
||||
rm -f $IMG_FILE
|
||||
fi
|
||||
|
||||
finish_and_exit $EXIT_CODE $2
|
||||
}
|
||||
|
||||
#########################################################
|
||||
# Setup appropriate environment things
|
||||
#########################################################
|
||||
setup_env()
|
||||
{
|
||||
PATH=/etc/kdump-adv-conf/kdump_build_helpers:$PATH
|
||||
}
|
||||
|
||||
|
||||
#########################################################
|
||||
# Handle sigint so we clean up well
|
||||
#########################################################
|
||||
handle_sigint()
|
||||
{
|
||||
cleanup_and_exit 2 "Caught Sigint"
|
||||
}
|
||||
|
||||
|
||||
#########################################################
|
||||
#Trap sigint so we can clean up
|
||||
#########################################################
|
||||
setup_traps()
|
||||
{
|
||||
trap handle_sigint 2
|
||||
}
|
||||
|
||||
#########################################################
|
||||
#This creates the directory hierarchy that use to
|
||||
#start creating a new initramfs
|
||||
#########################################################
|
||||
create_new_initramfs_dir()
|
||||
{
|
||||
local TMPDIR=`mktemp -d`
|
||||
if [ ! -d $TMPDIR ]
|
||||
then
|
||||
return 1
|
||||
fi
|
||||
|
||||
mkdir $TMPDIR/stage
|
||||
mkdir $TMPDIR/temp
|
||||
|
||||
BASE_DIR=$TMPDIR
|
||||
STAGE_DIR=$TMPDIR/stage
|
||||
TEMP_DIR=$TMPDIR/temp
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
#########################################################
|
||||
#Helper functions for stage_initramfs
|
||||
#########################################################
|
||||
create_initramfs_dirs()
|
||||
{
|
||||
mkdir -p $STAGE_DIR/lib || return 1
|
||||
mkdir -p $STAGE_DIR/lib64 || return 1
|
||||
mkdir -p $STAGE_DIR/bin || return 1
|
||||
mkdir -p $STAGE_DIR/etc || return 1
|
||||
mkdir -p $STAGE_DIR/dev || return 1
|
||||
mkdir -p $STAGE_DIR/proc || return 1
|
||||
mkdir -p $STAGE_DIR/sys || return 1
|
||||
mkdir -p $STAGE_DIR/tmp || return 1
|
||||
mkdir -p $STAGE_DIR/sysroot || return 1
|
||||
mkdir -p $STAGE_DIR/modules || return 1
|
||||
mkdir -p $STAGE_DIR/usr/share/udhcpc || return 1
|
||||
mkdir -p $STAGE_DIR/var/run || return 1
|
||||
mkdir -p $STAGE_DIR/etc/network/if-pre-up.d || return 1
|
||||
mkdir -p $STAGE_DIR/etc/network/if-up.d || return 1
|
||||
mkdir -p $STAGE_DIR/etc/network/if-pre-down.d || return 1
|
||||
mkdir -p $STAGE_DIR/etc/network/if-down.d || return 1
|
||||
mkdir -p $STAGE_DIR/etc/network/if-post-down.d || return 1
|
||||
$(cd $STAGE_DIR; ln -s bin sbin)
|
||||
}
|
||||
|
||||
|
||||
#########################################################
|
||||
#This function is the recepie for populating our initramfs
|
||||
#with the basic included functions/scripts, loading the
|
||||
#manifest files, copying in the init script, and doing
|
||||
#site specific post processing
|
||||
#########################################################
|
||||
prep_std_initramfs()
|
||||
{
|
||||
#start by creating the directories we need
|
||||
create_initramfs_dirs
|
||||
}
|
||||
|
||||
|
||||
##########################################################
|
||||
#This function validates each line in the manifest file to
|
||||
#ensure that we sanitize the input
|
||||
#Args are:
|
||||
#1 - file type
|
||||
#2 - File source
|
||||
#3 - destination path
|
||||
#4 - optional arguments
|
||||
##########################################################
|
||||
validate_manifest_line()
|
||||
{
|
||||
|
||||
case "$1" in
|
||||
creg|cren)
|
||||
# Just like reg/ren, but check nothing
|
||||
# we don't copy anything if its not there
|
||||
;;
|
||||
reg|ren)
|
||||
# Regular file, make sure that the file exists
|
||||
if [ ! -f $2 ]
|
||||
then
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
gen)
|
||||
# Generated file, make sure that the script
|
||||
# exists and is executable
|
||||
TEST_BIN=$(which $2)
|
||||
if [ ! -x $TEST_BIN ]
|
||||
then
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
exec)
|
||||
# exec files have no output, they simply
|
||||
# provide a means by which to manipulate the
|
||||
# the initramfs. Just make sure the file exists
|
||||
TEST_BIN=$(which $2)
|
||||
if [ ! -x $TEST_BIN ]
|
||||
then
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo $1 | grep -q "^#.*$"
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
# its a comment
|
||||
continue
|
||||
fi
|
||||
echo $1 | grep -q "^ *$"
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
# Blank line
|
||||
continue
|
||||
fi
|
||||
# Unknown manifest type, fail
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
##########################################################
|
||||
#This function reads in our manifest file and moves all
|
||||
#the specified contents to their respective destinations
|
||||
#the manifest file has the following format
|
||||
#
|
||||
#{type} {source arg} {dest path}
|
||||
#
|
||||
#see the kexec-adv-manifest man page for details
|
||||
##########################################################
|
||||
populate_from_manifest()
|
||||
{
|
||||
local type
|
||||
local sarg
|
||||
local dpath
|
||||
local opts
|
||||
local ddir
|
||||
|
||||
while read type sarg dpath opts
|
||||
do
|
||||
validate_manifest_line $type $sarg $dpath $opts
|
||||
if [ $? != 0 ]
|
||||
then
|
||||
cleanup_and_exit 1 "$sarg: Invalid line in manifest"
|
||||
fi
|
||||
|
||||
case "$type" in
|
||||
creg|cren)
|
||||
# Conditional regular copy/rename
|
||||
if [ -f $sarg ]
|
||||
then
|
||||
if [ "$type" == "creg" ]
|
||||
then
|
||||
ddir=$STAGE_DIR/$dpath
|
||||
else
|
||||
ddir=$(dirname $STAGE_DIR/$dpath)
|
||||
fi
|
||||
mkdir -p $ddir
|
||||
cp $sarg $STAGE_DIR/$dpath
|
||||
fi
|
||||
;;
|
||||
reg|ren)
|
||||
# Just do a raw copy from the source path
|
||||
# to the dest path
|
||||
if [ "$type" == "reg" ]
|
||||
then
|
||||
ddir=$STAGE_DIR/$dpath
|
||||
else
|
||||
ddir=$(dirname $STAGE_DIR/$dpath)
|
||||
fi
|
||||
mkdir -p $ddir
|
||||
cp $sarg $STAGE_DIR/$dpath
|
||||
;;
|
||||
gen)
|
||||
# Generated file: run the sarg with the provided opts
|
||||
# Assume that the binary will output the generated file
|
||||
# to stdout
|
||||
ddir=$(dirname $STAGE_DIR/$dpath)
|
||||
mkdir -p $ddir
|
||||
/bin/sh -c "$sarg $opts > $STAGE_DIR/$dpath"
|
||||
if [ $? != 0 ]
|
||||
then
|
||||
cleanup_and_exit 1 "$sarg: Non-zero exit"
|
||||
fi
|
||||
;;
|
||||
exec)
|
||||
# Just run $sarg as program, passing $BASE_DIR as the
|
||||
# first argument, and $opts next. This lets us
|
||||
# manipulate the intiramfs without having to add
|
||||
# anything to the file
|
||||
$sarg $BASE_DIR $opts
|
||||
if [ $? != 0 ]
|
||||
then
|
||||
cleanup_and_exit 1 "$sarg: Non-zero exit"
|
||||
fi
|
||||
|
||||
esac
|
||||
done < /etc/kdump-adv-conf/manifest
|
||||
}
|
||||
|
||||
|
||||
##########################################################
|
||||
# This function takes our stage directory, and makes an
|
||||
# image file out of it
|
||||
##########################################################
|
||||
create_initramfs_image()
|
||||
{
|
||||
IMG_FILE=$(mktemp $TEMP_DIR/initrd.img.XXXXXX)
|
||||
(cd $STAGE_DIR; find . | cpio --quiet -c -o) > $IMG_FILE
|
||||
if [ $? != 0 ]
|
||||
then
|
||||
cleanup_and_exit 1 " Could not create initramfs"
|
||||
fi
|
||||
|
||||
# argument 1 is passed in and is the full path to the
|
||||
# output initramfs name
|
||||
gzip -9 -c $IMG_FILE > $1
|
||||
}
|
||||
|
||||
|
||||
##########################################################
|
||||
#Start the actual code here
|
||||
##########################################################
|
||||
|
||||
# Get our passed in options
|
||||
INITRAMFS_NAME=$1
|
||||
|
||||
#validate the options
|
||||
if [ -z "INITRAMFS_NAME" ]
|
||||
then
|
||||
cleanup_and_exit 1 "Need an initramfs name"
|
||||
fi
|
||||
|
||||
|
||||
export INITRAMFS_NAME
|
||||
export KERNEL_NAME
|
||||
|
||||
#setup working env
|
||||
setup_env
|
||||
setup_traps
|
||||
|
||||
# Create a new staging area
|
||||
create_new_initramfs_dir
|
||||
if [ $? != 0 ]
|
||||
then
|
||||
cleanup_and_exit 1 "Unable to stage a new initramfs area"
|
||||
fi
|
||||
|
||||
# Do staging
|
||||
prep_std_initramfs
|
||||
|
||||
# Pull in the user supplied manifest
|
||||
populate_from_manifest
|
||||
|
||||
# Do image file creation
|
||||
create_initramfs_image $INITRAMFS_NAME
|
||||
|
||||
# Cleanup
|
||||
cleanup_and_exit 0 ""
|
@ -1,48 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
##########################################################
|
||||
#File: mkdumprd2
|
||||
#Author: Neil Horman <nhorman@redhat.com>
|
||||
#Copyright 2009 Red Hat, Inc.
|
||||
#Summary: A vastly simplified infrastructure for creating
|
||||
# initramfs files for use with kdump
|
||||
#########################################################
|
||||
|
||||
load_dependent_libs()
|
||||
{
|
||||
local BIN=$1
|
||||
local LIB=""
|
||||
|
||||
ldd $BIN 2>/dev/null | grep -q "not a dynamic executable"
|
||||
if [ $? == 0 ]
|
||||
then
|
||||
#There are no dependencies, we're done
|
||||
return
|
||||
fi
|
||||
|
||||
ldd $BIN | grep -q "statically linked"
|
||||
if [ $? == 0 ]
|
||||
then
|
||||
#There are no dependencies, we're done
|
||||
return
|
||||
fi
|
||||
|
||||
for LIB in `ldd $BIN | awk '/\// {if ($2 == "=>") { print $3} else {print $1}}'`
|
||||
do
|
||||
load_dependent_libs $LIB
|
||||
if [ ! -e $STAGE_DIR/$LIB ]
|
||||
then
|
||||
install --mode=755 $LIB $STAGE_DIR/$LIB
|
||||
fi
|
||||
done
|
||||
return
|
||||
}
|
||||
|
||||
install_with_deps()
|
||||
{
|
||||
local BIN=$1
|
||||
local MODE=$2
|
||||
|
||||
install --mode=$MODE $BIN $STAGE_DIR/bin
|
||||
load_dependent_libs $BIN
|
||||
}
|
2
sources
2
sources
@ -1,4 +1,4 @@
|
||||
d9f2ecd3c3307905f24130a25816e6cc kexec-tools-2.0.0.tar.bz2
|
||||
3e802d638dce0080b910f15908c04a24 kexec-tools-po.tar.gz
|
||||
190f8878aa7e7b63a96fde5d59538eec makedumpfile-1.3.3.tar.gz
|
||||
482347c1f6fcb2480044c42c03a16b9f mkdumprd2-files.tbz2
|
||||
95149c97537d0fb65eda72f4e53a0316 dracut-files.tbz2
|
||||
|
Loading…
Reference in New Issue
Block a user