]> Frank Brehm's Git Trees - scripts/root-bin.git/commitdiff
Added additionally scripts
authorFrank Brehm <frank@brehm-online.com>
Fri, 28 Oct 2011 07:40:15 +0000 (09:40 +0200)
committerFrank Brehm <frank@brehm-online.com>
Fri, 28 Oct 2011 07:40:15 +0000 (09:40 +0200)
add-session-on-the-fly.sh [new file with mode: 0755]
create_initramfs.sh [new file with mode: 0755]
new-session-on-the-fly.sh [new file with mode: 0755]

diff --git a/add-session-on-the-fly.sh b/add-session-on-the-fly.sh
new file mode 100755 (executable)
index 0000000..17e63c4
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/bash
+if ! type -p mkisofs >/dev/null; then
+    echo "mkisofs not found." >&2
+    exit 2
+fi
+
+if ! type -p cdrecord >/dev/null; then
+    echo "cdrecord not found." >&2
+    exit 2
+fi
+
+if [ ! -d "$1" ]; then
+    echo "you have to specify a directory to burn on the cd" >&2
+    exit 1
+fi
+
+mkisofs -J -R -C $( cdrecord -msinfo) -M ATAPI:0,0,0 $* | cdrecord -v -multi -data -
+
diff --git a/create_initramfs.sh b/create_initramfs.sh
new file mode 100755 (executable)
index 0000000..1e006fd
--- /dev/null
@@ -0,0 +1,81 @@
+#!/bin/bash
+
+echo_action() {
+    action="$1"
+    shift
+    printf "  %-8s %s\n" "$action" "$*"
+}
+
+KERNEL_VERSION=$1
+if [ -z "${KERNEL_VERSION}" ] ; then
+    KERNEL_VERSION=$( uname -r )
+fi
+
+case $KERNEL_VERSION in
+    *-gentoo*)
+        TARG="-gentoo"
+        ;;
+    *)
+        TARG=""
+        ;;
+esac
+
+TARG_CUR=${TARG}-cur
+TARG_LAST=${TARG}-last
+
+SRC_INIT_SCRIPT="/root/work/initramfs-init-$(hostname).sh"
+if [ ! -f "${SRC_INIT_SCRIPT}" ] ; then
+    echo "File '${SRC_INIT_SCRIPT}' doesn't exists." >&2
+    exit 3
+fi
+if [ ! -x "${SRC_INIT_SCRIPT}" ] ; then
+    echo "File '${SRC_INIT_SCRIPT}' is not executable." >&2
+    exit 3
+fi
+
+for bin in /bin/busybox /sbin/lvm.static; do
+    if [ ! -x "${bin}" ] ; then
+        echo "Binary '${bin}' doesn't exists." >&2
+        exit 3
+    fi
+done
+
+exit 0
+
+echo
+echo "Creating initramfs ..."
+if [ -d /usr/src/initramfs ] ; then
+    echo_action 'RM' '/usr/src/initramfs'
+    rm -rf /usr/src/initramfs
+fi
+echo_action 'MKDIR' '/usr/src/initramfs'
+mkdir -p /usr/src/initramfs
+cd /usr/src/initramfs || exit 5
+
+echo_action 'MKDIR' 'baselayout'
+mkdir -p bin lib dev etc mnt/root proc root sbin sys
+echo_action 'CP' 'devices'
+cp -a /dev/{null,zero,console,tty,sd}* dev/
+echo_action 'CP' 'busybox'
+cp -a /bin/busybox bin/busybox
+echo_action 'CP' 'init'
+cp -p "${SRC_INIT_SCRIPT}" ./init
+chmod +x ./init
+
+echo_action 'LN' 'mdev'
+ln -s ../bin/busybox sbin/mdev
+
+echo_action 'CP' 'lvm.static'
+cp -a /sbin/lvm.static sbin/
+
+i=0
+IMAGE=$( printf "/boot/initramfs.%s.%02d.cpio.gz" "${KERNEL_VERSION}" $i )
+while [ -f "${IMAGE}" ] ; do
+    i=$(( i + 1 ))
+    IMAGE=$( printf "/boot/initramfs.%s.%02d.cpio.gz" "${KERNEL_VERSION}" $i )
+done
+
+echo_action "CPIO" "${IMAGE}"
+find . -print0 | cpio --null -o --format=newc | gzip -9 >"${IMAGE}"
+
+# vim: ts=4 expandtab
diff --git a/new-session-on-the-fly.sh b/new-session-on-the-fly.sh
new file mode 100755 (executable)
index 0000000..3d51248
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/bash
+if ! type -p mkisofs >/dev/null; then
+    echo "mkisofs not found." >&2
+    exit 2
+fi
+
+if ! type -p cdrecord >/dev/null; then
+    echo "cdrecord not found." >&2
+    exit 2
+fi
+
+if [ ! -d "$1" ]; then
+    echo "you have to specify a directory to burn on the cd" >&2
+    exit 1
+fi
+
+mkisofs -J -R $* | cdrecord -v -multi -data -
+