#!/bin/sh -e PROG=mkinitfs Fatal() { echo "$PROG: $*" >&2 exit 1 } TEMP= exit_handler() { local rc=$? trap - EXIT [ -z "$TEMP" ] || rm -f -- "$TEMP" [ $rc -eq 0 ] || rm -f -- "$OUT" exit $rc } [ -n "$1" ] || Fatal "Usage: mkinitfs outfile" OUT="$1"; shift trap exit_handler HUP PIPE INT TERM QUIT EXIT TEMP=`mktemp -t mkinitfs.XXXXXXXXXX` || Fatal "Failed to create temporary file." udevd="/lib/mkinitrd/udev/sbin/udevd" [ -x "$udevd" ] && { udev_version="$($udevd --version 2>/dev/null)" printf '%s\n' "${udev_version:-105}" > udev_version } || { Fatal "$udevd doesn't exists or not executable" } ( cat < "$TEMP" gzip -c < "$TEMP" > "$OUT"