summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Lecher <jlec@gentoo.org>2013-09-21 11:35:53 +0000
committerJustin Lecher <jlec@gentoo.org>2013-09-21 11:35:53 +0000
commit331d37f2d817a26bfdadf816a8f11830787e0b4c (patch)
tree98b0da311d1b4f74772280f14abeaf5990ed1897 /sys-apps/kexec-tools/files
parentAdd missing dependency on dev-perl/Net-DNS (#478356 by Michael Weber) (diff)
downloadgentoo-2-331d37f2d817a26bfdadf816a8f11830787e0b4c.tar.gz
gentoo-2-331d37f2d817a26bfdadf816a8f11830787e0b4c.tar.bz2
gentoo-2-331d37f2d817a26bfdadf816a8f11830787e0b4c.zip
sys-apps/kexec-tools: Add support for systemd, #478072; Fix issues with openrc init scripts, #481506; thanks BobbyK for the patches
(Portage version: 2.2.6/cvs/Linux x86_64, signed Manifest commit with key B9D4F231BD1558AB!)
Diffstat (limited to 'sys-apps/kexec-tools/files')
-rw-r--r--sys-apps/kexec-tools/files/kexec.conf32
-rw-r--r--sys-apps/kexec-tools/files/kexec.conf-2.0.331
-rw-r--r--sys-apps/kexec-tools/files/kexec.conf-999918
-rw-r--r--sys-apps/kexec-tools/files/kexec.init-2.0.3119
-rw-r--r--sys-apps/kexec-tools/files/kexec.init-2.0.4-r2165
-rw-r--r--[-rwxr-xr-x]sys-apps/kexec-tools/files/kexec.init-9999 (renamed from sys-apps/kexec-tools/files/kexec.init)4
-rw-r--r--sys-apps/kexec-tools/files/kexec.init-ng101
-rw-r--r--sys-apps/kexec-tools/files/kexec.service16
8 files changed, 216 insertions, 270 deletions
diff --git a/sys-apps/kexec-tools/files/kexec.conf b/sys-apps/kexec-tools/files/kexec.conf
index 74f8b891ce54..aa829b9c2349 100644
--- a/sys-apps/kexec-tools/files/kexec.conf
+++ b/sys-apps/kexec-tools/files/kexec.conf
@@ -1,18 +1,16 @@
-# Boot partition
-#BOOTPART="/boot"
+# Kernel image pathname, relative from /boot.
+KNAME="bzimage"
-# 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"
+# 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.3 b/sys-apps/kexec-tools/files/kexec.conf-2.0.3
deleted file mode 100644
index a1d409edabc6..000000000000
--- a/sys-apps/kexec-tools/files/kexec.conf-2.0.3
+++ /dev/null
@@ -1,31 +0,0 @@
-# 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-2.6.10"
-
-# 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"
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.3 b/sys-apps/kexec-tools/files/kexec.init-2.0.3
deleted file mode 100644
index a2d32f030219..000000000000
--- a/sys-apps/kexec-tools/files/kexec.init-2.0.3
+++ /dev/null
@@ -1,119 +0,0 @@
-#!/sbin/runscript
-# Copyright 1999-2013 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/sys-apps/kexec-tools/files/kexec.init-2.0.3,v 1.2 2013/03/27 11:50:55 jlec Exp $
-
-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
-}
-
-load_image() {
- if [[ "${KNAME}" = "-" ]]; then
- ebegin "Disabling kexec"
- kexec -u
- eend $?
- return $?
- fi
-
- BOOTPART="${BOOTPART:-/boot}"
- local img="$(image_path)" initrd="$(initrd_path)" mounted=false initrdopt=
-
- if [[ -z "${img}" ]] || [[ -z "${initrd}" ]]; then
- # If we cannot find our image, try mounting ${BOOTPART}
- if ! grep -q " ${BOOTPART} " /proc/mounts; then
- ebegin "Mounting ${BOOTPART}"
- mount "${BOOTPART}" && mounted=true
- eend $? || return $?
- img="$(image_path)"
- initrd="$(initrd_path)"
- fi
- fi
-
- if [[ -z "${img}" ]]; then
- eerror "No kernel image found in ${BOOTPART}!"
- ${mounted} && umount "${BOOTPART}"
- return 1
- else
- ebegin "Loading kernel image ${img} for kexec"
- fi
-
- [[ -n "${ROOTPART}" ]] || \
- ROOTPART="$(readlink -f "$(sed -n '/^\/[^ ]* \/ / s,^\([^ ]*\).*,\1,p' /proc/mounts)")"
-
- [[ -n "${KPARAM}" ]] || KEXEC_OPT_ARGS+=" --reuse-cmdline"
-
- [[ -n "${initrd}" ]] && [[ -e "${initrd}" ]] && initrdopt="--initrd=${initrd}"
-
- einfo " 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
- image_path > /dev/null || \
- ewarn "Cannot find kernel image. Please make sure a valid kernel image is present before reboot."
- return 0
- 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..f22566d6a085
--- /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
+# $Header: /var/cvsroot/gentoo-x86/sys-apps/kexec-tools/files/kexec.init-2.0.4-r2,v 1.1 2013/09/21 11:35:53 jlec Exp $
+
+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 b/sys-apps/kexec-tools/files/kexec.init-9999
index 80edb435c89b..56a092832ec8 100755..100644
--- a/sys-apps/kexec-tools/files/kexec.init
+++ b/sys-apps/kexec-tools/files/kexec.init-9999
@@ -1,7 +1,7 @@
#!/sbin/runscript
-# Copyright 1999-2010 Gentoo Foundation
+# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/sys-apps/kexec-tools/files/kexec.init,v 1.15 2010/10/29 06:44:51 jlec Exp $
+# $Header: /var/cvsroot/gentoo-x86/sys-apps/kexec-tools/files/kexec.init-9999,v 1.1 2013/09/21 11:35:53 jlec Exp $
depend() {
need localmount
diff --git a/sys-apps/kexec-tools/files/kexec.init-ng b/sys-apps/kexec-tools/files/kexec.init-ng
deleted file mode 100644
index 20a03e3a35bb..000000000000
--- a/sys-apps/kexec-tools/files/kexec.init-ng
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/sbin/runscript
-# Copyright 1999-2011 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/sys-apps/kexec-tools/files/kexec.init-ng,v 1.1 2011/03/27 08:31:50 jlec Exp $
-
-depend() {
- need localmount
-}
-
-image_path() {
- local x= kver=$(uname -r)
- for x in "${KNAME:-bzImage}" vmlinuz \
- bzImage-"${kver}" vmlinuz-"${kver}" ; do
- if [ -e "${BOOTPART}/${x}" ] ; then
- echo "${BOOTPART}/${x}"
- return 0
- fi
- done
-
- return 1
-}
-
-load_image() {
- if [ "${KNAME}" = "-" ] ; then
- ebegin "Disabling kexec"
- kexec -u
- eend $?
- return $?
- fi
-
- BOOTPART="${BOOTPART:-/boot}"
- local img="$(image_path)" mounted=false initrdopt=
-
- if [ -z "${img}" ] ; then
- # If we cannot find our image, try mounting ${BOOTPART}
- if ! grep -q " ${BOOTPART} " /proc/mounts ; then
- ebegin "Mounting ${BOOTPART}"
- mount "${BOOTPART}" && mounted=true
- eend $? || return $?
- img="$(image_path)"
- fi
- fi
-
- if [ -z "${img}" ] ; then
- eerror "No kernel image found in ${BOOTPART}!"
- ${mounted} && umount "${BOOTPART}"
- return 1
- fi
-
- ebegin "Loading kernel image ${img} for kexec"
- if [ -z "${ROOTPART}" ] ; then
- ROOTPART="$(readlink -f "$(sed -n '/^\/[^ ]* \/ / s,^\([^ ]*\).*,\1,p' /etc/mtab)")"
- fi
- if [ -z "${KPARAM}" ] ; then
- KPARAM="$(sed -e 's/ /\n/g' /proc/cmdline | grep -v -e "^root=" | tr '\n' ' ')"
- fi
-
- # Use the default initrd if it exists and none other given
- if [ -z "${INITRD}" -a -e "${BOOTPART}"/initrd ] ; then
- INITRD="${BOOTPART}/initrd"
- fi
- if [ -e "${INITRD}" ] ; then
- initrdopt="--initrd=${INITRD}"
- fi
-
- kexec -l "${img}" --append="root=${ROOTPART} ${KPARAM}" ${initrdopt}
- local res=$?
-
- ${mounted} && umount "${BOOTPART}"
- eend ${res}
- return ${res}
-}
-
-start() {
- [ "${LOAD_DURING_SHUTDOWN:-yes}" = "yes" ] && return 0
-
- ebegin "Configuring kexec"
- load_image
- eend 0
-}
-
-stop() {
- [ "${LOAD_DURING_SHUTDOWN:-yes}" != "yes" ] && return 0
-
- ebegin "Configuring kexec"
- if [ "`/sbin/runlevel|/bin/cut -c 3`" != "6" ]; then
- einfo "Not rebooting, so disabling"
- kexec -u
- return 0
- fi
-
- if [ "`/sbin/runlevel|/bin/cut -c 3`" = "6" ] && [ -f /nokexec ]; then
- einfo "Not using kexec during reboot"
- rm -f /nokexec
- kexec -u
- return 0
- fi
-
- 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