--- /dev/null
+#!/bin/sh
+
+###
+### This script is distributed in the terms of GNU GPL v3.0+
+### (c) Andrew Sichevoi, http://thekondor.net
+###
+### Name: initrd-extract-here
+### Description: Helper script to extract initramfs image contents to the current directory
+### Notes: By default initramfs for current kernel version is extracted.
+###
+### Arguments:
+### name : %kernel_version%
+### type : string
+### required: optional
+### default : $(uname -r)
+###
+
+
+### TODO: move C&P code to a common place
+
+PREFIX=/boot/initrd.img-
+CURRENT_VERSION=$(uname -r)
+VERSION=${CURRENT_VERSION}
+
+if [ x"current" = x"$1" -o -z "$1" ]; then
+ VERSION=${CURRENT_VERSION}
+else
+ VERSION=$1
+fi
+
+INITRD_FILENAME=${PREFIX}${VERSION}
+if [ ! -e ${INITRD_FILENAME} ]; then
+ echo "Error: '${INITRD_FILENAME}' is not existent"
+ exit 1
+fi
+
+echo "Initrd to extract: '${INITRD_FILENAME}'"
+
+cat ${INITRD_FILENAME} | gzip -d - | cpio -i
--- /dev/null
+#!/bin/sh
+
+###
+### This script is distributed in the terms of GNU GPL v3.0+
+### (c) Andrew Sichevoi, http://thekondor.net
+###
+### Name: initrd-pack-here
+### Description: Helper script to create initramfs image from current the directory
+### Notes: By default an initramfs image is created in the parent directory
+###
+### Arguments
+### name : replace
+### desc : specifies that initramfs image must be replaced in /boot directory
+### The next following argument must specify kernel version.
+### type : keyword
+### required: optional
+### default : -
+###
+### name : current
+### desc : used with a combination of 'replace' only. Synonym for $(uname -r)
+### type : keyword
+### required: required
+### default : -
+###
+
+if [ ! -e init -o ! -d scripts ]; then
+ echo "Error: current directory is not contents of initrd"
+ exit 1
+fi
+
+PREFIX=/boot/initrd.img-
+INITRD_FILENAME=
+if [ x"replace" = x"$1" ]; then
+ if [ x"current" = x"$2" ]; then
+ VERSION=$(uname -r)
+ INITRD_FILENAME=${PREFIX}${VERSION}
+ else
+ INITRD_FILENAME=$2
+ fi
+else
+ INITRD_FILENAME=../initrd.img-$(date +"%R-%F")
+fi
+
+if [ -z "${INITRD_FILENAME}" ]; then
+ echo "Error: Filename of initrd image is not specified"
+ exit 1
+fi
+
+echo "Packing initrd to '${INITRD_FILENAME}'"
+
+find ./ | cpio -H newc --no-absolute-filenames -o | gzip - > ${INITRD_FILENAME}
--- /dev/null
+#!/bin/sh
+
+###
+### This script is distributed in the terms of GNU GPL v3.0+
+### (c) Andrew Sichevoi, http://thekondor.net
+###
+### Name: initrd-tool
+### Description: wrapper over initrd image packing and extracting scripts
+### Notes: depends on ``initrd-extract-here'', ``initrd-pack-here''
+###
+### Arguments:
+### <see usage>
+###
+
+show_usage()
+{
+ echo 'Usage:'
+ echo ' <x-here|extract-here> [<current>|<kernel-version>]'
+ echo ' <p-here|pack-here> [<replace current|filename>]'
+}
+
+INITRD_EXTRACT_TOOL="initrd-extract-here"
+INITRD_PACK_TOOL="initrd-pack-here"
+
+command=$1
+tool=
+case "${command}" in
+ extract-here | x-here)
+ tool=${INITRD_EXTRACT_TOOL}
+ break
+ ;;
+ pack-here | p-here)
+ tool=${INITRD_PACK_TOOL}
+ break
+ ;;
+esac
+
+if [ ! -z "${tool}" ]; then
+ [ ! 0 -eq $# ] && shift
+ ${tool} $@
+ exit $?
+fi
+
+show_usage
+exit 1