Skip to content

Commit

Permalink
Merge branch 'thingos' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ccrisan committed Feb 22, 2018
2 parents 313edd6 + 6911636 commit e518b8a
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions writeimage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fi
if [[ $(id -u) -ne 0 ]]; then echo "please run as root"; exit 1; fi

function msg() {
echo ":: $1"
echo " * $1"
}

while getopts "a:d:f:h:i:lm:n:o:p:s:w" o; do
Expand Down Expand Up @@ -76,12 +76,25 @@ if ! [ -f $DISK_IMG ]; then
exit 1
fi

gunzip=$(which unpigz 2> /dev/null || which gunzip 2> /dev/null)
gunzip=$(which unpigz 2> /dev/null || which gunzip 2> /dev/null || true)
unxz=$(which unxz 2> /dev/null || true)

if [[ $DISK_IMG == *.gz ]]; then
msg "decompressing the gzipped image"
if [ -z "$gunzip" ]; then
msg "make sure you have the gzip package installed"
exit 1
fi
msg "decompressing the .gz compressed image"
$gunzip -c $DISK_IMG > ${DISK_IMG%???}
DISK_IMG=${DISK_IMG%???}
elif [[ $DISK_IMG == *.xz ]]; then
if [ -z "$unxz" ]; then
msg "make sure you have the xz package installed"
exit 1
fi
msg "decompressing the .xz compressed image"
$unxz -T 0 -c $DISK_IMG > ${DISK_IMG%???}
DISK_IMG=${DISK_IMG%???}
fi

umount ${SDCARD_DEV}* 2>/dev/null || true
Expand Down

0 comments on commit e518b8a

Please sign in to comment.