tar-xz-loading-initramfs/scripts/mkinitramfs

21 lines
562 B
Bash
Executable File

#!/bin/sh
die() {
echo "${2}"
echo "Usage: ${0} <path to directory> <output file>"
exit $1
}
[[ $# -eq 2 ]] || die 22 "Invalid number of arguments"
[[ -d "${1}" ]] || die 20 "${1} is not a directory"
[[ -e "${2}" ]] && [[ ! -f "$(readlink -f "${2}")" ]] && die 17 "${2} exists and is not a file"
[[ -f "${1}/pv" ]] || die 2 "${1}/pv does not exist. Read README!"
[[ -f "${1}/busybox" ]] || die 2 "${1}/busybox does not exist. Read README!"
file=$(readlink -f ${2})
cd "${1}"
find . -print0 | cpio --null -ov --format=newc | gzip -9 > "${file}"