diff options
author | 2015-08-08 13:49:04 -0700 | |
---|---|---|
committer | 2015-08-08 17:38:18 -0700 | |
commit | 56bd759df1d0c750a065b8c845e93d5dfa6b549d (patch) | |
tree | 3f91093cdb475e565ae857f1c5a7fd339e2d781e /sys-apps/kexec-tools/files | |
download | gentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.tar.gz gentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.tar.bz2 gentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.zip |
proj/gentoo: Initial commit
This commit represents a new era for Gentoo:
Storing the gentoo-x86 tree in Git, as converted from CVS.
This commit is the start of the NEW history.
Any historical data is intended to be grafted onto this point.
Creation process:
1. Take final CVS checkout snapshot
2. Remove ALL ChangeLog* files
3. Transform all Manifests to thin
4. Remove empty Manifests
5. Convert all stale $Header$/$Id$ CVS keywords to non-expanded Git $Id$
5.1. Do not touch files with -kb/-ko keyword flags.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
X-Thanks: Alec Warner <antarus@gentoo.org> - did the GSoC 2006 migration tests
X-Thanks: Robin H. Johnson <robbat2@gentoo.org> - infra guy, herding this project
X-Thanks: Nguyen Thai Ngoc Duy <pclouds@gentoo.org> - Former Gentoo developer, wrote Git features for the migration
X-Thanks: Brian Harring <ferringb@gentoo.org> - wrote much python to improve cvs2svn
X-Thanks: Rich Freeman <rich0@gentoo.org> - validation scripts
X-Thanks: Patrick Lauer <patrick@gentoo.org> - Gentoo dev, running new 2014 work in migration
X-Thanks: Michał Górny <mgorny@gentoo.org> - scripts, QA, nagging
X-Thanks: All of other Gentoo developers - many ideas and lots of paint on the bikeshed
Diffstat (limited to 'sys-apps/kexec-tools/files')
-rw-r--r-- | sys-apps/kexec-tools/files/90_kexec | 9 | ||||
-rw-r--r-- | sys-apps/kexec-tools/files/README.Gentoo | 33 | ||||
-rw-r--r-- | sys-apps/kexec-tools/files/kexec-tools-2.0.0-respect-LDFLAGS.patch | 11 | ||||
-rw-r--r-- | sys-apps/kexec-tools/files/kexec-tools-2.0.4-disable-kexec-test.patch | 17 | ||||
-rw-r--r-- | sys-apps/kexec-tools/files/kexec-tools-2.0.4-out-of-source.patch | 24 | ||||
-rw-r--r-- | sys-apps/kexec-tools/files/kexec-tools-2.0.9-hardened.patch | 16 | ||||
-rw-r--r-- | sys-apps/kexec-tools/files/kexec.conf | 16 | ||||
-rw-r--r-- | sys-apps/kexec-tools/files/kexec.conf-2.0.4 | 34 | ||||
-rw-r--r-- | sys-apps/kexec-tools/files/kexec.conf-9999 | 18 | ||||
-rw-r--r-- | sys-apps/kexec-tools/files/kexec.init-2.0.4 | 144 | ||||
-rw-r--r-- | sys-apps/kexec-tools/files/kexec.init-2.0.4-r2 | 165 | ||||
-rw-r--r-- | sys-apps/kexec-tools/files/kexec.init-2.0.4-r3 | 165 | ||||
-rw-r--r-- | sys-apps/kexec-tools/files/kexec.init-9999 | 165 | ||||
-rw-r--r-- | sys-apps/kexec-tools/files/kexec.service | 16 |
14 files changed, 833 insertions, 0 deletions
diff --git a/sys-apps/kexec-tools/files/90_kexec b/sys-apps/kexec-tools/files/90_kexec new file mode 100644 index 000000000000..40bad423955d --- /dev/null +++ b/sys-apps/kexec-tools/files/90_kexec @@ -0,0 +1,9 @@ +#!/bin/sh + +version="$1" ; shift +image="$1" ; shift + +exec sed \ + -e "s:\"vmlinuz-.*\":\"vmlinuz-${version}\":" \ + -e "s:/boot/initramfs-.*\.img:/boot/initramfs-${version}\.img:" \ + -i /etc/kexec.conf diff --git a/sys-apps/kexec-tools/files/README.Gentoo b/sys-apps/kexec-tools/files/README.Gentoo new file mode 100644 index 000000000000..7735e3275ba4 --- /dev/null +++ b/sys-apps/kexec-tools/files/README.Gentoo @@ -0,0 +1,33 @@ +Usage +===== + +Do + $ man 8 kexec +for full understanding of the underlying kexec command. +Gentoo offers a wrapper to the bare kexec command through +/etc/init.d/kexec. + +Configuration +------------- + +Configuration is done in /etc/conf.d/kexec, which is self-documented. + +Usage +----- + +In Gentoo, kexec is invoked, i.e., the new kernel will be booted when +rebooting, by reboot (8) command or by pressing Ctrl+Alt+Del. + +If you want to use kexec once, just run + $ /etc/init.d/kexec start + +It'll reserve kexec call at reboot. Later on, you can reboot anytime, +letting kexec starts another (or the same) kernel. When all is done in +the runlevel 6 - killing processes, unmounting volumes, etc - kexec +starts the new kernel instead of doing the normal hardware reboot. + +If you want kexec to be run every time you reboot, add it to a runlevel: + $ rc-update add kexec <runlevel> + +If you want to reboot in the normal way this time, do: + $ touch /nokexec diff --git a/sys-apps/kexec-tools/files/kexec-tools-2.0.0-respect-LDFLAGS.patch b/sys-apps/kexec-tools/files/kexec-tools-2.0.0-respect-LDFLAGS.patch new file mode 100644 index 000000000000..040d138ece06 --- /dev/null +++ b/sys-apps/kexec-tools/files/kexec-tools-2.0.0-respect-LDFLAGS.patch @@ -0,0 +1,11 @@ +--- kdump/Makefile ++++ kdump/Makefile +@@ -18,7 +18,7 @@ + $(KDUMP): CC=$(TARGET_CC) + $(KDUMP): $(KDUMP_OBJS) + @$(MKDIR) -p $(@D) +- $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -o $@ $(KDUMP_OBJS) ++ $(LINK.o) $(CFLAGS) -o $@ $(KDUMP_OBJS) + + $(KDUMP_MANPAGE): kdump/kdump.8 + $(MKDIR) -p $(MANDIR)/man8 diff --git a/sys-apps/kexec-tools/files/kexec-tools-2.0.4-disable-kexec-test.patch b/sys-apps/kexec-tools/files/kexec-tools-2.0.4-disable-kexec-test.patch new file mode 100644 index 000000000000..6fc73f2db181 --- /dev/null +++ b/sys-apps/kexec-tools/files/kexec-tools-2.0.4-disable-kexec-test.patch @@ -0,0 +1,17 @@ +diff --git kexec-tools-2.0.3/kexec_test/Makefile kexec-tools-2.0.3/kexec_test/Makefile +index fec6210..2ed4d51 100644 +--- kexec-tools-2.0.3/kexec_test/Makefile ++++ kexec-tools-2.0.3/kexec_test/Makefile +@@ -8,12 +8,6 @@ dist += kexec_test/Makefile $(KEXEC_TEST_SRCS) \ + kexec_test/x86-setup-legacy-pic.S + + BUILD_KEXEC_TEST = no +-ifeq ($(ARCH),i386) +-BUILD_KEXEC_TEST = yes +-endif +-ifeq ($(ARCH),x86_64) +-BUILD_KEXEC_TEST = yes +-endif + + ifeq ($(BUILD_KEXEC_TEST),yes) + diff --git a/sys-apps/kexec-tools/files/kexec-tools-2.0.4-out-of-source.patch b/sys-apps/kexec-tools/files/kexec-tools-2.0.4-out-of-source.patch new file mode 100644 index 000000000000..64c6cd8ab419 --- /dev/null +++ b/sys-apps/kexec-tools/files/kexec-tools-2.0.4-out-of-source.patch @@ -0,0 +1,24 @@ + Makefile.in | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/Makefile.in b/Makefile.in +index c1859d1..1aa8559 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -44,7 +44,7 @@ TARGET_CFLAGS = @TARGET_CFLAGS@ + + # Base compiler flags. These are extended by the subcomponent-Makefiles + # where necessary. +-CPPFLAGS = @CPPFLAGS@ -I$(srcdir)/include -I$(srcdir)/util_lib/include \ ++CPPFLAGS = @CPPFLAGS@ -I$(top_builddir)/include -I$(srcdir)/include -I$(srcdir)/util_lib/include \ + -Iinclude/ $($(ARCH)_CPPFLAGS) + CFLAGS = @CFLAGS@ -fno-strict-aliasing -Wall -Wstrict-prototypes + PURGATORY_EXTRA_CFLAGS = @PURGATORY_EXTRA_CFLAGS@ +@@ -77,6 +77,7 @@ pkgincludedir = $(includedir)/$(PACKAGE_NAME) + DESTDIR = + + srcdir = @srcdir@ ++top_builddir = @top_builddir@ + VPATH = .:$(srcdir) + + # install paths diff --git a/sys-apps/kexec-tools/files/kexec-tools-2.0.9-hardened.patch b/sys-apps/kexec-tools/files/kexec-tools-2.0.9-hardened.patch new file mode 100644 index 000000000000..01a8b4be933b --- /dev/null +++ b/sys-apps/kexec-tools/files/kexec-tools-2.0.9-hardened.patch @@ -0,0 +1,16 @@ +the purgatory subdir gets loaded into the kernel so we need to +make sure it does not get built with compiler settings like the +rest of the userland tools. that means no PIC/PIE/SSP/etc... + +--- a/purgatory/Makefile ++++ b/purgatory/Makefile +@@ -47,7 +47,8 @@ purgatory/sha256.o: $(srcdir)/util_lib/sha256.c + $(PURGATORY): CC=$(TARGET_CC) + $(PURGATORY): CFLAGS+=$(PURGATORY_EXTRA_CFLAGS) \ + $($(ARCH)_PURGATORY_EXTRA_CFLAGS) \ +- -Os -fno-builtin -ffreestanding ++ -Os -fno-builtin -ffreestanding \ ++ -fno-PIC -fno-PIE -fno-stack-protector + + $(PURGATORY): CPPFLAGS=$($(ARCH)_PURGATORY_EXTRA_CFLAGS) \ + -I$(srcdir)/purgatory/include \ diff --git a/sys-apps/kexec-tools/files/kexec.conf b/sys-apps/kexec-tools/files/kexec.conf new file mode 100644 index 000000000000..aa829b9c2349 --- /dev/null +++ b/sys-apps/kexec-tools/files/kexec.conf @@ -0,0 +1,16 @@ +# Kernel image pathname, relative from /boot. +KNAME="bzimage" + +# Additional arguments passed to kexec (8) +# Following arguments are support: +# +# --reuse-cmdline +# Use the current boot command line +# +# --command-line=string +# Use a different command line +# +# --initrd=file +# Specify an initrd to use +# +KEXEC_OPT_ARGS="--reuse-cmdline" diff --git a/sys-apps/kexec-tools/files/kexec.conf-2.0.4 b/sys-apps/kexec-tools/files/kexec.conf-2.0.4 new file mode 100644 index 000000000000..b71ea2bae97f --- /dev/null +++ b/sys-apps/kexec-tools/files/kexec.conf-2.0.4 @@ -0,0 +1,34 @@ +# Load kexec kernel image into memory during shutdown instead of bootup +# (default: yes) +#LOAD_DURING_SHUTDOWN="yes" + +# Additional arguments passed to kexec (8) +#KEXEC_OPT_ARGS="" + +# Kernel image partition. Mounted automatically if not. +# (default: /boot) +#BOOTPART="/boot" + +# Root partition (should be autodetected) +#ROOTPART="/dev/hda3" + +# Kernel image pathname, relative from BOOTPART. +# If it's one of +# {kernel-genkernel,bzImage,vmlinuz,kernel}-<currently running kernel version>, +# or bzImage, vmlinuz (without suffix), +# then it's automaticaly detected. +# Setting it to "-" will disable kexec. +#KNAME="vmlinuz-3.9.0" + +# Initrd +# Same automatic detection restriction as for KNAME apply. +# initramfs-genkernel-<currently running kernel version>, +# initrd{,.img}-<currently running kernel version>{,.img} +# will be detected. +#INITRD="/boot/fbsplash-emergence-1024x768" + +# Kernel parameters (should be autodetected) +#KPARAM="splash=silent,theme:emergence" + +# Do not try to mount /boot +# DONT_MOUNT_BOOT="yes" diff --git a/sys-apps/kexec-tools/files/kexec.conf-9999 b/sys-apps/kexec-tools/files/kexec.conf-9999 new file mode 100644 index 000000000000..74f8b891ce54 --- /dev/null +++ b/sys-apps/kexec-tools/files/kexec.conf-9999 @@ -0,0 +1,18 @@ +# Boot partition +#BOOTPART="/boot" + +# Kernel name +#KNAME="vmlinuz-2.6.10" + +# Root partition (should be autodetected) +#ROOTPART="/dev/hda3" + +# Kernel parameters (should be autodetected) +#KPARAM="splash=silent,theme:emergence" + +# Initrd +#INITRD="/boot/fbsplash-emergence-1024x768" + +# Load kexec kernel image into memory during shutdown instead of bootup +# (default: yes) +#LOAD_DURING_SHUTDOWN="yes" diff --git a/sys-apps/kexec-tools/files/kexec.init-2.0.4 b/sys-apps/kexec-tools/files/kexec.init-2.0.4 new file mode 100644 index 000000000000..a7101efbd87e --- /dev/null +++ b/sys-apps/kexec-tools/files/kexec.init-2.0.4 @@ -0,0 +1,144 @@ +#!/sbin/runscript +# Copyright 1999-2013 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +depend() { + need localmount +} + +image_path() { + local x= kver=$(uname -r) karch=$(uname -m) + BOOTPART="${BOOTPART:-/boot}" + for x in "${KNAME:-bzImage}" vmlinuz \ + bzImage-${kver} vmlinuz-${kver} \ + kernel-genkernel-${karch}-${kver} \ + kernel-${kver} kernel-${karch}; do + if [ -e "${BOOTPART}/${x}" ]; then + echo "${BOOTPART}/${x}" + return 0 + fi + done + + return 1 +} + +initrd_path() { + local x= kver=$(uname -r) karch=$(uname -m) + BOOTPART="${BOOTPART:-/boot}" + for x in "${INITRD:-initrd}" \ + initrd.img-${kver} initrd-${kver}.img \ + initrd-${kver} initramfs-${kver}.img \ + initramfs-genkernel-${karch}-${kver} ; do + if [ -e "${BOOTPART}/${x}" ]; then + echo "${BOOTPART}/${x}" + return 0 + fi + done + + return 1 +} + +mount_boot(){ + local ret + + [ -n ${DONT_MOUNT_BOOT} ] && return 1 + grep -q " ${BOOTPART:-/boot} " /proc/mounts && return 1 + + BOOTPART="${BOOTPART:-/boot}" + ebegin "Mounting ${BOOTPART}" + mount "${BOOTPART}"; ret=$? + eend ${ret} + return ${ret} +} + +load_image() { + local ret + if [ "${KNAME}" = "-" ]; then + ebegin "Disabling kexec" + kexec -u; ret=$? + eend ${ret} + return ${ret} + fi + + BOOTPART="${BOOTPART:-/boot}" + local img= initrd="$(initrd_path)" mounted=false initrdopt= + + if ! img="$(image_path)"; then + if mount_boot; then + if img="$(image_path)"; then + mounted=true + initrd="$(initrd_path)" + else + eerror "No kernel image found in ${BOOTPART}!" + umount "${BOOTPART}" + return 1 + fi + else + eerror "No kernel image found in ${BOOTPART}!" + return 1 + fi + fi + + if [ -n "${INITRD}" ] && \ + ! [ "${INITRD}" = "${initrd}" ]; then + eerror "Requested initrd: ${INITRD}" + eerror "could not be found" + return 1 + fi + + [ -n "${ROOTPART}" ] || \ + ROOTPART="$(readlink -f "$(sed -n '/^\/[^ ]* \/ / s,^\([^ ]*\).*,\1,p' /proc/mounts)")" + + [ -n "${KPARAM}" ] || KEXEC_OPT_ARGS="${KEXEC_OPT_ARGS} --reuse-cmdline" + + [ -n "${initrd}" ] && [ -e "${initrd}" ] && initrdopt="--initrd=${initrd}" + + local msg= + [ -n ${initrd} ] && \ + msg="with ${initrd}" + einfo "Using kernel image ${img} ${msg} for kexec" + + ebegin "Setting kexec with ${KEXEC_OPT_ARGS} -l ${img} root=${ROOTPART} ${KPARAM} ${initrdopt}" + kexec ${KEXEC_OPT_ARGS} -l "${img}" --append="root=${ROOTPART} ${KPARAM}" ${initrdopt} + local res=$? + + ${mounted} && umount "${BOOTPART}" + eend ${res} + return ${res} +} + +start() { + if [ "${LOAD_DURING_SHUTDOWN:-yes}" = "yes" ]; then + if ! image_path > /dev/null; then + ewarn "Cannot find kernel image!" + ewarn "Please make sure a valid kernel image is present before reboot." + return 0 + fi + else + ebegin "Configuring kexec" + load_image + eend $? + fi +} + +stop() { + [ "${LOAD_DURING_SHUTDOWN:-yes}" != "yes" ] && return 0 + + if ! yesno $RC_REBOOT; then + einfo "Not rebooting, so disabling" + kexec -u + return 0 + fi + + if [ -f /nokexec ]; then + einfo "Not using kexec during reboot" + rm -f /nokexec + kexec -u + return 0 + fi + + ebegin "Configuring kexec" + load_image + eend $? +} diff --git a/sys-apps/kexec-tools/files/kexec.init-2.0.4-r2 b/sys-apps/kexec-tools/files/kexec.init-2.0.4-r2 new file mode 100644 index 000000000000..f1306874297c --- /dev/null +++ b/sys-apps/kexec-tools/files/kexec.init-2.0.4-r2 @@ -0,0 +1,165 @@ +#!/sbin/runscript +# Copyright 1999-2013 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +depend() { + need localmount +} + +image_path() { + local x= kver=$(uname -r) karch=$(uname -m) + BOOTPART="${BOOTPART:-/boot}" + KNAME="${KNAME:-bzImage}" + if [ -e "${KNAME}" ]; then + echo "${KNAME}" + return 0 + fi + for x in "${KNAME#${BOOTPART}}" vmlinuz \ + bzImage-${kver} vmlinuz-${kver} \ + kernel-genkernel-${karch}-${kver} \ + kernel-${kver} kernel-${karch}; do + if [ -e "${BOOTPART}/${x}" ]; then + echo "${BOOTPART}/${x}" + return 0 + fi + done + + return 1 +} + +initrd_path() { + local x= kver=$(uname -r) karch=$(uname -m) + BOOTPART="${BOOTPART:-/boot}" + INITRD="${INITRD:-initrd}" + if [ -e "${INITRD}" ]; then + echo "${INITRD}" + return 0 + fi + for x in "${INITRD#${BOOTPART}}" \ + initrd.img-${kver} initrd-${kver}.img \ + initrd-${kver} initramfs-${kver}.img \ + initramfs-genkernel-${karch}-${kver} ; do + if [ -e "${BOOTPART}/${x}" ]; then + echo "${BOOTPART}/${x}" + return 0 + fi + done + + return 1 +} + +mount_boot(){ + local ret + + [ -n "${DONT_MOUNT_BOOT}" ] && return 1 + grep -q " ${BOOTPART:-/boot} " /proc/mounts && return 1 + + BOOTPART="${BOOTPART:-/boot}" + ebegin "Mounting ${BOOTPART}" + mount "${BOOTPART}"; ret=$? + eend ${ret} + return ${ret} +} + +load_image() { + local ret + if [ "${KNAME}" = "-" ]; then + ebegin "Disabling kexec" + kexec -u; ret=$? + eend ${ret} + return ${ret} + fi + + BOOTPART="${BOOTPART:-/boot}" + local img= initrd="$(initrd_path)" mounted=false initrdopt= + + if ! img="$(image_path)"; then + if mount_boot; then + if img="$(image_path)"; then + mounted=true + initrd="$(initrd_path)" + else + eerror "No kernel image found in ${BOOTPART}!" + umount "${BOOTPART}" + return 1 + fi + else + eerror "No kernel image found in ${BOOTPART}!" + return 1 + fi + fi + + if [ -n "${INITRD}" ] && \ + ! [ "${BOOTPART}/${INITRD#${BOOTPART}}" = "${initrd}" ]; then + eerror "Requested initrd: ${INITRD#${BOOTPART}}" + eerror "could not be found" + return 1 + fi + + [ -n "${ROOTPART}" ] || \ + ROOTPART="$(readlink -f "$(sed -n '/^\/[^ ]* \/ / s,^\([^ ]*\).*,\1,p' /proc/mounts)")" + + [ -n "${KPARAM}" ] || KEXEC_OPT_ARGS="${KEXEC_OPT_ARGS} --reuse-cmdline" + + [ -n "${initrd}" ] && [ -e "${initrd}" ] && initrdopt="--initrd=${initrd}" + + local msg= + [ -n "${initrd}" ] && \ + msg="with ${initrd}" + einfo "Using kernel image ${img} ${msg} for kexec" + + ebegin "Setting kexec with ${KEXEC_OPT_ARGS} -l ${img} root=${ROOTPART} ${KPARAM} ${initrdopt}" + kexec ${KEXEC_OPT_ARGS} -l "${img}" --append="root=${ROOTPART} ${KPARAM}" ${initrdopt} + local res=$? + + ${mounted} && umount "${BOOTPART}" + eend ${res} + return ${res} +} + +start() { + if [ "${LOAD_DURING_SHUTDOWN:-yes}" = "yes" ]; then + local ret=0 + BOOTPART="${BOOTPART:-/boot}" + if mount_boot; then + mounted=true + fi + if ! image_path > /dev/null; then + ewarn "Cannot find kernel image!" + ewarn "Please make sure a valid kernel image is present before reboot." + return 0 + fi + if [ -n "${mounted}" ]; then + ebegin "Unmounting ${BOOTPART}" + umount "${BOOTPART}"; ret=$? + eend ${ret} + fi + return ${ret} + else + ebegin "Configuring kexec" + load_image + eend $? + fi +} + +stop() { + [ "${LOAD_DURING_SHUTDOWN:-yes}" != "yes" ] && return 0 + + if ! yesno $RC_REBOOT; then + einfo "Not rebooting, so disabling" + kexec -u + return 0 + fi + + if [ -f /nokexec ]; then + einfo "Not using kexec during reboot" + rm -f /nokexec + kexec -u + return 0 + fi + + ebegin "Configuring kexec" + load_image + eend $? +} diff --git a/sys-apps/kexec-tools/files/kexec.init-2.0.4-r3 b/sys-apps/kexec-tools/files/kexec.init-2.0.4-r3 new file mode 100644 index 000000000000..7aa55af80c00 --- /dev/null +++ b/sys-apps/kexec-tools/files/kexec.init-2.0.4-r3 @@ -0,0 +1,165 @@ +#!/sbin/runscript +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +depend() { + need localmount +} + +image_path() { + local x= kver=$(uname -r) karch=$(uname -m) + BOOTPART="${BOOTPART:-/boot}" + KNAME="${KNAME:-bzImage}" + if [ -e "${KNAME}" ]; then + echo "${KNAME}" + return 0 + fi + for x in "${KNAME#${BOOTPART}}" vmlinuz \ + bzImage-${kver} vmlinuz-${kver} \ + kernel-genkernel-${karch}-${kver} \ + kernel-${kver} kernel-${karch}; do + if [ -e "${BOOTPART}/${x}" ]; then + echo "${BOOTPART}/${x}" + return 0 + fi + done + + return 1 +} + +initrd_path() { + local x= kver=$(uname -r) karch=$(uname -m) + BOOTPART="${BOOTPART:-/boot}" + INITRD="${INITRD:-initrd}" + if [ -e "${INITRD}" ]; then + echo "${INITRD}" + return 0 + fi + for x in "${INITRD#${BOOTPART}}" \ + initrd.img-${kver} initrd-${kver}.img \ + initrd-${kver} initramfs-${kver}.img \ + initramfs-genkernel-${karch}-${kver} ; do + if [ -e "${BOOTPART}/${x}" ]; then + echo "${BOOTPART}/${x}" + return 0 + fi + done + + return 1 +} + +mount_boot(){ + local ret + + [ "${DONT_MOUNT_BOOT:-no}" = "no" ] || return 1 + grep -q " ${BOOTPART:-/boot} " /proc/mounts && return 1 + + BOOTPART="${BOOTPART:-/boot}" + ebegin "Mounting ${BOOTPART}" + mount "${BOOTPART}"; ret=$? + eend ${ret} + return ${ret} +} + +load_image() { + local ret + if [ "${KNAME}" = "-" ]; then + ebegin "Disabling kexec" + kexec -u; ret=$? + eend ${ret} + return ${ret} + fi + + BOOTPART="${BOOTPART:-/boot}" + local img= initrd="$(initrd_path)" mounted=false initrdopt= + + if ! img="$(image_path)"; then + if mount_boot; then + if img="$(image_path)"; then + mounted=true + initrd="$(initrd_path)" + else + eerror "No kernel image found in ${BOOTPART}!" + umount "${BOOTPART}" + return 1 + fi + else + eerror "No kernel image found in ${BOOTPART}!" + return 1 + fi + fi + + if [ -n "${INITRD}" ] && \ + ! [ "${BOOTPART}/${INITRD#${BOOTPART}}" = "${initrd}" ]; then + eerror "Requested initrd: ${INITRD#${BOOTPART}}" + eerror "could not be found" + return 1 + fi + + [ -n "${ROOTPART}" ] || \ + ROOTPART="$(readlink -f "$(sed -n '/^\/[^ ]* \/ / s,^\([^ ]*\).*,\1,p' /proc/mounts)")" + + [ -n "${KPARAM}" ] || KEXEC_OPT_ARGS="${KEXEC_OPT_ARGS} --reuse-cmdline" + + [ -n "${initrd}" ] && [ -e "${initrd}" ] && initrdopt="--initrd=${initrd}" + + local msg= + [ -n "${initrd}" ] && \ + msg="with ${initrd}" + einfo "Using kernel image ${img} ${msg} for kexec" + + ebegin "Setting kexec with ${KEXEC_OPT_ARGS} -l ${img} root=${ROOTPART} ${KPARAM} ${initrdopt}" + kexec ${KEXEC_OPT_ARGS} -l "${img}" --append="root=${ROOTPART} ${KPARAM}" ${initrdopt} + local res=$? + + ${mounted} && umount "${BOOTPART}" + eend ${res} + return ${res} +} + +start() { + if [ "${LOAD_DURING_SHUTDOWN:-yes}" = "yes" ]; then + local ret=0 + BOOTPART="${BOOTPART:-/boot}" + if mount_boot; then + mounted=true + fi + if ! image_path > /dev/null; then + ewarn "Cannot find kernel image!" + ewarn "Please make sure a valid kernel image is present before reboot." + return 0 + fi + if [ -n "${mounted}" ]; then + ebegin "Unmounting ${BOOTPART}" + umount "${BOOTPART}"; ret=$? + eend ${ret} + fi + return ${ret} + else + ebegin "Configuring kexec" + load_image + eend $? + fi +} + +stop() { + if ! yesno $RC_REBOOT; then + einfo "Not rebooting, so disabling" + kexec -u + return 0 + fi + + if [ -f /nokexec ]; then + einfo "Not using kexec during reboot" + rm -f /nokexec + kexec -u + return 0 + fi + + [ "${LOAD_DURING_SHUTDOWN:-yes}" != "yes" ] && return 0 + + ebegin "Configuring kexec" + load_image + eend $? +} diff --git a/sys-apps/kexec-tools/files/kexec.init-9999 b/sys-apps/kexec-tools/files/kexec.init-9999 new file mode 100644 index 000000000000..f1306874297c --- /dev/null +++ b/sys-apps/kexec-tools/files/kexec.init-9999 @@ -0,0 +1,165 @@ +#!/sbin/runscript +# Copyright 1999-2013 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +depend() { + need localmount +} + +image_path() { + local x= kver=$(uname -r) karch=$(uname -m) + BOOTPART="${BOOTPART:-/boot}" + KNAME="${KNAME:-bzImage}" + if [ -e "${KNAME}" ]; then + echo "${KNAME}" + return 0 + fi + for x in "${KNAME#${BOOTPART}}" vmlinuz \ + bzImage-${kver} vmlinuz-${kver} \ + kernel-genkernel-${karch}-${kver} \ + kernel-${kver} kernel-${karch}; do + if [ -e "${BOOTPART}/${x}" ]; then + echo "${BOOTPART}/${x}" + return 0 + fi + done + + return 1 +} + +initrd_path() { + local x= kver=$(uname -r) karch=$(uname -m) + BOOTPART="${BOOTPART:-/boot}" + INITRD="${INITRD:-initrd}" + if [ -e "${INITRD}" ]; then + echo "${INITRD}" + return 0 + fi + for x in "${INITRD#${BOOTPART}}" \ + initrd.img-${kver} initrd-${kver}.img \ + initrd-${kver} initramfs-${kver}.img \ + initramfs-genkernel-${karch}-${kver} ; do + if [ -e "${BOOTPART}/${x}" ]; then + echo "${BOOTPART}/${x}" + return 0 + fi + done + + return 1 +} + +mount_boot(){ + local ret + + [ -n "${DONT_MOUNT_BOOT}" ] && return 1 + grep -q " ${BOOTPART:-/boot} " /proc/mounts && return 1 + + BOOTPART="${BOOTPART:-/boot}" + ebegin "Mounting ${BOOTPART}" + mount "${BOOTPART}"; ret=$? + eend ${ret} + return ${ret} +} + +load_image() { + local ret + if [ "${KNAME}" = "-" ]; then + ebegin "Disabling kexec" + kexec -u; ret=$? + eend ${ret} + return ${ret} + fi + + BOOTPART="${BOOTPART:-/boot}" + local img= initrd="$(initrd_path)" mounted=false initrdopt= + + if ! img="$(image_path)"; then + if mount_boot; then + if img="$(image_path)"; then + mounted=true + initrd="$(initrd_path)" + else + eerror "No kernel image found in ${BOOTPART}!" + umount "${BOOTPART}" + return 1 + fi + else + eerror "No kernel image found in ${BOOTPART}!" + return 1 + fi + fi + + if [ -n "${INITRD}" ] && \ + ! [ "${BOOTPART}/${INITRD#${BOOTPART}}" = "${initrd}" ]; then + eerror "Requested initrd: ${INITRD#${BOOTPART}}" + eerror "could not be found" + return 1 + fi + + [ -n "${ROOTPART}" ] || \ + ROOTPART="$(readlink -f "$(sed -n '/^\/[^ ]* \/ / s,^\([^ ]*\).*,\1,p' /proc/mounts)")" + + [ -n "${KPARAM}" ] || KEXEC_OPT_ARGS="${KEXEC_OPT_ARGS} --reuse-cmdline" + + [ -n "${initrd}" ] && [ -e "${initrd}" ] && initrdopt="--initrd=${initrd}" + + local msg= + [ -n "${initrd}" ] && \ + msg="with ${initrd}" + einfo "Using kernel image ${img} ${msg} for kexec" + + ebegin "Setting kexec with ${KEXEC_OPT_ARGS} -l ${img} root=${ROOTPART} ${KPARAM} ${initrdopt}" + kexec ${KEXEC_OPT_ARGS} -l "${img}" --append="root=${ROOTPART} ${KPARAM}" ${initrdopt} + local res=$? + + ${mounted} && umount "${BOOTPART}" + eend ${res} + return ${res} +} + +start() { + if [ "${LOAD_DURING_SHUTDOWN:-yes}" = "yes" ]; then + local ret=0 + BOOTPART="${BOOTPART:-/boot}" + if mount_boot; then + mounted=true + fi + if ! image_path > /dev/null; then + ewarn "Cannot find kernel image!" + ewarn "Please make sure a valid kernel image is present before reboot." + return 0 + fi + if [ -n "${mounted}" ]; then + ebegin "Unmounting ${BOOTPART}" + umount "${BOOTPART}"; ret=$? + eend ${ret} + fi + return ${ret} + else + ebegin "Configuring kexec" + load_image + eend $? + fi +} + +stop() { + [ "${LOAD_DURING_SHUTDOWN:-yes}" != "yes" ] && return 0 + + if ! yesno $RC_REBOOT; then + einfo "Not rebooting, so disabling" + kexec -u + return 0 + fi + + if [ -f /nokexec ]; then + einfo "Not using kexec during reboot" + rm -f /nokexec + kexec -u + return 0 + fi + + ebegin "Configuring kexec" + load_image + eend $? +} diff --git a/sys-apps/kexec-tools/files/kexec.service b/sys-apps/kexec-tools/files/kexec.service new file mode 100644 index 000000000000..289aae0df0b1 --- /dev/null +++ b/sys-apps/kexec-tools/files/kexec.service @@ -0,0 +1,16 @@ +[Unit] +Description=Gracefully restart the box +Documentation=man:kexec(8) +After=boot.mount +Before=shutdown.target umount.target final.target +ConditionPathExists=!/nokexec + +[Service] +Type=oneshot +RemainAfterExit=yes +EnvironmentFile=/etc/kexec.conf +ExecStart=/usr/sbin/kexec -l /boot/${KNAME} ${KEXEC_OPT_ARGS} +ExecStop=/usr/sbin/kexec -l /boot/${KNAME} ${KEXEC_OPT_ARGS} + +[Install] +WantedBy=multi-user.target |