diff options
author | Waldemar Brodkorb <wbx@openadk.org> | 2011-09-12 14:01:48 +0200 |
---|---|---|
committer | Waldemar Brodkorb <wbx@openadk.org> | 2011-09-12 14:01:48 +0200 |
commit | e91c994c49b2a3aa61190a6d95eff4c0cdb3bbb1 (patch) | |
tree | ae04fa6c90f02b2807db9961f05103fac8a67dc9 | |
parent | 4d516a84eae1e4e5591c65ee11bd6af53532d15d (diff) |
add new package kexecinit, to realize kexec booting
-rw-r--r-- | package/base-files/Makefile | 2 | ||||
-rwxr-xr-x | package/base-files/src/init | 3 | ||||
-rw-r--r-- | package/kexecinit/Makefile | 26 | ||||
-rwxr-xr-x | package/kexecinit/src/kexecinit | 65 |
4 files changed, 94 insertions, 2 deletions
diff --git a/package/base-files/Makefile b/package/base-files/Makefile index 4cc7e970a..27ecdaa7c 100644 --- a/package/base-files/Makefile +++ b/package/base-files/Makefile @@ -6,7 +6,7 @@ include $(TOPDIR)/mk/rootfs.mk PKG_NAME:= base-files PKG_VERSION:= 1.0 -PKG_RELEASE:= 46 +PKG_RELEASE:= 47 PKG_SECTION:= base PKG_DESCR:= basic files and scripts diff --git a/package/base-files/src/init b/package/base-files/src/init index a3232cb9c..a9564011d 100755 --- a/package/base-files/src/init +++ b/package/base-files/src/init @@ -1,7 +1,7 @@ #!/bin/sh echo "System initialization ..." export PATH=/bin:/sbin:/usr/bin:/usr/sbin -mount -t devtmpfs devtmpfs /dev > /dev/null 2>&1 +mount -t devtmpfs devtmpfs /dev >/dev/null 2>&1 mount -nt proc proc /proc mount -o nosuid,nodev,noexec -t sysfs sysfs /sys [ ! -f /etc/notmpfs ] && { @@ -18,6 +18,7 @@ echo >/dev/mdev.seq echo "/sbin/mdev" >/proc/sys/kernel/hotplug mdev -s cat /etc/.rnd >/dev/urandom 2>&1 +[ -x /kexecinit ] && { /kexecinit; } [ -x /cryptinit ] && { /cryptinit; exec switch_root /mnt "/init";} [ -x /sbin/cfgfs ] && { cfgfs setup; mount -o remount,ro /;} || mount -o remount,rw / [ -f /etc/fstab ] && { fsck -p >/dev/null; mount -a;} 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 |