Add gzip option
This commit is contained in:
parent
97b9a5db39
commit
20ae97d2bc
14
pishrink.sh
14
pishrink.sh
|
@ -72,10 +72,11 @@ EOM
|
||||||
}
|
}
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "Usage: $0 [-sdrph] imagefile.img [newimagefile.img]"
|
echo "Usage: $0 [-sdrpzh] imagefile.img [newimagefile.img]"
|
||||||
echo "-s: Skip autoexpand"
|
echo "-s: Skip autoexpand"
|
||||||
echo "-d: Debug mode on"
|
echo "-d: Debug mode on"
|
||||||
echo "-r: Use advanced repair options"
|
echo "-r: Use advanced repair options"
|
||||||
|
echo "-z: Gzip compress image after shrinking"
|
||||||
echo "-h: display help text"
|
echo "-h: display help text"
|
||||||
exit -1
|
exit -1
|
||||||
}
|
}
|
||||||
|
@ -83,12 +84,14 @@ usage() {
|
||||||
should_skip_autoexpand=false
|
should_skip_autoexpand=false
|
||||||
debug=false
|
debug=false
|
||||||
repair=false
|
repair=false
|
||||||
|
gzip_compress=false
|
||||||
|
|
||||||
while getopts ":sdrh" opt; do
|
while getopts ":sdrzh" opt; do
|
||||||
case "${opt}" in
|
case "${opt}" in
|
||||||
s) should_skip_autoexpand=true ;;
|
s) should_skip_autoexpand=true ;;
|
||||||
d) debug=true;;
|
d) debug=true;;
|
||||||
r) repair=true;;
|
r) repair=true;;
|
||||||
|
z) gzip_compress=true;;
|
||||||
h) help;;
|
h) help;;
|
||||||
*) usage ;;
|
*) usage ;;
|
||||||
esac
|
esac
|
||||||
|
@ -306,6 +309,13 @@ if ! truncate -s "$endresult" "$img"; then
|
||||||
exit -16
|
exit -16
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ $gzip_compress == true ]]; then
|
||||||
|
info "Gzipping the shrunk image"
|
||||||
|
if [[ ! $(gzip -f9 "$img") ]]; then
|
||||||
|
img=$img.gz
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
aftersize=$(ls -lh "$img" | cut -d ' ' -f 5)
|
aftersize=$(ls -lh "$img" | cut -d ' ' -f 5)
|
||||||
logVariables $LINENO aftersize
|
logVariables $LINENO aftersize
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue