#!/bin/sh
if [ ! "$#" = "2" ]; then
  echo "unpack an initrd in /tmp/initrd-<suffix>
  usage: ./unpack_initrd.sh <path/to/initrd> <suffix>"
  exit
fi
if [ ! $UID -eq 0 ]; then
  gettext "Please execute this script as root."
  echo
  exit
fi  
TMP=/tmp/initrd-$2
if [ -e $TMP ]; then
  echo "$TMP already exists."
  exit
fi
mkdir $TMP
(
cd $TMP
xz -cd < $1 | \
cpio -i -d -m -H newc --no-absolute-filenames
) 1>>${TMP}/log.txt 2>>${TMP}/log.txt
chown -R didier:users $TMP
