diff --git a/path/wdvn-initrd-create b/path/wdvn-initrd-create new file mode 100755 index 0000000..6527c13 --- /dev/null +++ b/path/wdvn-initrd-create @@ -0,0 +1,6 @@ +#!/bin/bash +set -e +INPUT="$1" +OUTPUT="$2" +cd "$INPUT" +find . | cpio -H newc -o | gzip -9 > "$OUTPUT" \ No newline at end of file diff --git a/path/wdvn-initrd-extract b/path/wdvn-initrd-extract new file mode 100755 index 0000000..3cd3546 --- /dev/null +++ b/path/wdvn-initrd-extract @@ -0,0 +1,25 @@ +#!/bin/bash +set -e +OLDPWD="$PWD" +INPUT="$1" +OUTPUT="$2" +TEMP="$2.tmp" +TYPE="$(file -b -L "$INPUT")" + +mkdir -p "$TEMP/basic" + +if [[ "$TYPE" == *"cpio archive"* ]]; then + mkdir -p "$TEMP/microcode" + cd "$TEMP/microcode" + BLOCKS="$(cpio -i <"$INPUT" 2>&1 >/dev/null | tail -1)" + BLOCKS="${BLOCKS%% *}" + dd if="$INPUT" of="$TEMP/initrd.img" bs=512 skip=$BLOCKS + cd "$TEMP/basic" + zcat "$TEMP/initrd.img" | cpio -i + rm "$TEMP/initrd.img" +else + cd "$TEMP/basic" + zcat "$INPUT" | cpio -i +fi + +mv "$TEMP" "$OUTPUT" \ No newline at end of file