From e91c994c49b2a3aa61190a6d95eff4c0cdb3bbb1 Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Mon, 12 Sep 2011 14:01:48 +0200 Subject: add new package kexecinit, to realize kexec booting --- package/kexecinit/Makefile | 26 +++++++++++++++++ package/kexecinit/src/kexecinit | 65 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 package/kexecinit/Makefile create mode 100755 package/kexecinit/src/kexecinit (limited to 'package/kexecinit') diff --git a/package/kexecinit/Makefile b/package/kexecinit/Makefile new file mode 100644 index 000000000..ef042592b --- /dev/null +++ b/package/kexecinit/Makefile @@ -0,0 +1,26 @@ +# This file is part of the OpenADK project. OpenADK is copyrighted +# material, please see the LICENCE file in the top-level directory. + +include ${TOPDIR}/rules.mk + +PKG_NAME:= kexecinit +PKG_VERSION:= 1.0 +PKG_RELEASE:= 1 +PKG_DESCR:= init for kexec rootfilesystem +PKG_SECTION:= base + +WRKDIST= ${WRKDIR}/${PKG_NAME}-${PKG_VERSION} +NO_DISTFILES:= 1 + +include ${TOPDIR}/mk/package.mk + +$(eval $(call PKG_template,KEXECINIT,${PKG_NAME},${PKG_VERSION}-${PKG_RELEASE},${PKG_DEPENDS},${PKG_DESCR},${PKG_SECTION})) + +CONFIG_STYLE:= manual +BUILD_STYLE:= manual +INSTALL_STYLE:= manual + +do-install: + $(INSTALL_BIN) ./src/kexecinit $(IDIR_KEXECINIT)/ + +include ${TOPDIR}/mk/pkg-bottom.mk diff --git a/package/kexecinit/src/kexecinit b/package/kexecinit/src/kexecinit new file mode 100755 index 000000000..3aee9ce18 --- /dev/null +++ b/package/kexecinit/src/kexecinit @@ -0,0 +1,65 @@ +#!/bin/sh + +load_system() { + echo "Loading OpenADK from microdrive (${micro}1)" + mount ${micro}1 /mnt + if [ $? -ne 0 ];then echo "Mounting ${micro}1 failed"; exit 1;fi + kexec -l /mnt/boot/kernel + umount /mnt + kexec -e -x +} + +cf_install() { + mkdir /mnt/root + mkdir /mnt/cf + mount -t ext2 ${micro}1 /mnt/root + if [ $? -ne 0 ];then echo "Mounting ${micro}1 failed"; exit 1;fi + mount ${cfd}1 /mnt/cf + if [ $? -ne 0 ];then echo "Mounting ${cfd}1 failed"; exit 1;fi + if [ -f /mnt/cf/sharp.tgz ];then + echo "Installing OpenADK from CF (${cfd}1) to microdrive (${micro}1)" + umount /mnt/root + mke2fs -q ${micro}1 + mount -t ext2 ${micro}1 /mnt/root + if [ $? -ne 0 ];then echo "Mounting ${micro}1 failed"; exit 1;fi + tar -xzpf /mnt/cf/sharp.tgz -C /mnt/root + fi + umount /mnt/root + umount /mnt/cf +} + +check_cf() { + cf=0 + if [ $(lsscsi|wc -l) -eq 1 ];then + cf=0 + else + cf=1 + fi + micro=$(lsscsi |awk '$4 ~ "HMS360" { print $6 }') + if [ "$micro" = "/dev/sda" ];then + cfd=/dev/sdb + else + cfd=/dev/sda + fi +} + +echo " ___ _ ____ _ __ " +echo " / _ \ _ __ ___ _ __ / \ | _ \| |/ / " +echo "| | | | '_ \ / _ \ '_ \ / _ \ | | | | ' / " +echo "| |_| | |_) | __/ | | |/ ___ \| |_| | . \ " +echo " \___/| .__/ \___|_| |_/_/ \_\____/|_|\_\ " +echo " |_| " +echo "" + +sleep 2 +check_cf +if [ $cf -eq 0 ];then + load_system +else + echo "Should I install OpenADK to microdrive (y/n)" + read answer + if [ "$answer" = "y" ];then + cf_install + fi + load_system +fi -- cgit v1.2.3