From 57b071ccaa313ef63f5c9fba5f45acc8fcd108f6 Mon Sep 17 00:00:00 2001 From: Romain Perier Date: Sun, 28 Sep 2014 11:46:39 +0000 Subject: [PATCH] recipies-devtools: Add net-kexec package This installs a script which is able to kexec a kernel through the network from user space. As the proprietary bootloader is limited and does not offer such a feature, this is a good alternative for developers. --- recipes-devtools/net-kexec/files/net-kexec.sh | 27 +++++++++++++++++++ recipes-devtools/net-kexec/net-kexec_1.0.bb | 20 ++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 recipes-devtools/net-kexec/files/net-kexec.sh create mode 100644 recipes-devtools/net-kexec/net-kexec_1.0.bb diff --git a/recipes-devtools/net-kexec/files/net-kexec.sh b/recipes-devtools/net-kexec/files/net-kexec.sh new file mode 100644 index 0000000..44983d5 --- /dev/null +++ b/recipes-devtools/net-kexec/files/net-kexec.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# Copyright (C) 2014 Romain Perier +# Released under the MIT license (see COPYING.MIT for the terms) + +GATEWAY=$(route | grep default | sed 's/ [ ]*/:/g' | cut -d ':' -f 2) + +fail() { + echo $1 + exit 1 +} + +# If we are not already connected, connect eth0 with DHCP +ifconfig eth0 | grep 'inet addr:[0-9]*\.[0-9]*\.[0-9]*\.[0-9]* ' >/dev/null +if [ $? -ne 0 ]; then + echo "* Starting DHCP on eth0" + udhcpc -n -i eth0 || fail "Unable to establish a DHCP session with eth0" +fi + +tftp -g -r zImage $GATEWAY >/dev/null || fail "Unable to get zImage throught TFTP" +echo "* Found zImage on $TFTP_SERVER" +echo -n "Do you want to reboot to the new kernel on the fly ? [y/n] " +read boot + +if [ "$boot" = "y" ]; then + kexec -l zImage + kexec -e +fi diff --git a/recipes-devtools/net-kexec/net-kexec_1.0.bb b/recipes-devtools/net-kexec/net-kexec_1.0.bb new file mode 100644 index 0000000..4de0f0a --- /dev/null +++ b/recipes-devtools/net-kexec/net-kexec_1.0.bb @@ -0,0 +1,20 @@ +# Copyright (C) 2014 Romain Perier +# Released under the MIT license (see COPYING.MIT for the terms) + +SUMMARY = "Extremely basic script to kexec over the network" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" +SRC_URI = "file://net-kexec.sh" + +PR = "r1" + +RDEPENDS_${PN} += "kexec" + +do_install() { + install -d ${D}/sbin + install -m 0755 ${WORKDIR}/net-kexec.sh ${D}/sbin/net-kexec +} + +inherit allarch + +FILES_${PN} += "/sbin/net-kexec"