From 796a925a5f5fb47c12851135c417adc14c91b2f3 Mon Sep 17 00:00:00 2001 From: Tomas M Date: Tue, 9 Oct 2012 14:47:46 -0500 Subject: [PATCH] bootinst linux boot installer --- bootfiles/bootinst.sh | 32 ++++++++++++++++++++++++++++++++ initramfs/static/update | 1 + livekitlib | 14 +++++++------- 3 files changed, 40 insertions(+), 7 deletions(-) create mode 100755 bootfiles/bootinst.sh diff --git a/bootfiles/bootinst.sh b/bootfiles/bootinst.sh new file mode 100755 index 0000000..bf94044 --- /dev/null +++ b/bootfiles/bootinst.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# Setup booting from disk (USB or harddrive) +# Requires: extlinux, fdisk, df, tail, tr, cut, cat, sed +set -e + +# change working directory to dir from which we are started +CWD="$(pwd)" +BOOT="$(dirname "$0")" +cd "$BOOT" + +# find out device and mountpoint +PART="$(df . | tail -n 1 | tr -s " " | cut -d " " -f 1)" +DEV="$(echo "$PART" | sed -r "s:[0-9]+\$::" | sed -r "s:([0-9])[a-z]+\$:\\1:i")" #" + +# install syslinux bootloader +extlinux --install $BOOT + +if [ "$DEV" != "$PART" ]; then + # Setup MBR on the first block + cat "$BOOT/mbr.bin" > "$DEV" + + # Toggle a bootable flag + PART="$(echo "$PART" | sed -r "s:.*[^0-9]::")" + ( + fdisk -l "$DEV" | fgrep "*" | fgrep "$DEV" | cut -d " " -f 1 \ + | sed -r "s:.*[^0-9]::" | xargs -I '{}' echo -ne "a\n{}\n" + echo -ne "a\n$PART\nw\n" + ) | fdisk $DEV >/dev/null 2>&1 +fi + +echo "Boot installation finished." +cd "$CWD" diff --git a/initramfs/static/update b/initramfs/static/update index e2bcf8b..b9b9eee 100755 --- a/initramfs/static/update +++ b/initramfs/static/update @@ -11,6 +11,7 @@ # - make # - find static binaries in /usr/src/buildroot-sources/output/target/bin/ etc # +# - all sources can be found at http://ftp.slax.org/Slax-7.0-development/sources/Slax-7.0-sources # Automatically determine the architecture we're building on: if [ -z "$MYARCH" ]; then diff --git a/livekitlib b/livekitlib index 48c8ff8..94810fa 100644 --- a/livekitlib +++ b/livekitlib @@ -324,29 +324,29 @@ persistent_changes() # if not, simply return back if [ $? -ne 0 ]; then - echo "* Persistent changes not writable or not used" >&2 + echo "* Persistent changes not writable or not used" return fi - echo "* Testing persistent changes for posix compatibility" >&2 + echo_green_star + echo "Testing persistent changes for posix compatibility" touch "$T1" && ln -sf "$T1" "$T2" 2>/dev/null && \ chmod +x "$T1" 2>/dev/null && test -x "$T1" && \ chmod -x "$T1" 2>/dev/null && test ! -x "$T1" && \ rm "$T1" "$T2" 2>/dev/null if [ $? -ne 0 ]; then - echo_green_star - echo "Activating dynamic sized storage for persistent changes" >&2 + echo "* Activating dynamic sized storage for persistent changes" rm "$T1" "$T2" 2>/dev/null - mount.dynsizefs "$CHANGES/changes.idx" "$CHANGES/changes.dat" "$2" + + mount.dynsizefs "$CHANGES/changes.idx" "$CHANGES/changes.dat" 4096 "$2" if [ "$(device_bestfs "$2/dynsize.fs" | tr -d " ")" = "-t" ]; then mke2fs -F "$2/dynsize.fs" >/dev/null fi mount -o loop "$2/dynsize.fs" "$2" rmdir "$2/lost+found" else - echo_green_star - echo "Activating native persistent changes" >&2 + echo "* Activating native persistent changes" mount --bind "$CHANGES" "$2" fi }