Merge pull request #139 from framps/fix_toolcheck

Fixed two minor issues
This commit is contained in:
Drew Bonasera 2020-06-13 14:59:02 -04:00 committed by GitHub
commit 071799b926
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 6 deletions

View File

@ -91,7 +91,6 @@ parallel=false
verbose=false verbose=false
prep=false prep=false
ziptool="" ziptool=""
required_tools="$REQUIRED_TOOLS"
while getopts ":adhprsvzZ" opt; do while getopts ":adhprsvzZ" opt; do
case "${opt}" in case "${opt}" in
@ -142,7 +141,7 @@ if [[ -n $ziptool ]]; then
error $LINENO "$ziptool is an unsupported ziptool." error $LINENO "$ziptool is an unsupported ziptool."
exit -17 exit -17
else else
if [[ $parallel == true && ziptool == "gzip" ]]; then if [[ $parallel == true && $ziptool == "gzip" ]]; then
REQUIRED_TOOLS="$REQUIRED_TOOLS pigz" REQUIRED_TOOLS="$REQUIRED_TOOLS pigz"
else else
REQUIRED_TOOLS="$REQUIRED_TOOLS $ziptool" REQUIRED_TOOLS="$REQUIRED_TOOLS $ziptool"
@ -161,15 +160,19 @@ done
#Copy to new file if requested #Copy to new file if requested
if [ -n "$2" ]; then if [ -n "$2" ]; then
info "Copying $1 to $2..." f="$2"
cp --reflink=auto --sparse=always "$1" "$2" if [[ -n $ziptool && "${f##*.}" == ${ZIPEXTENSIONS[$ziptool]} ]]; then # remove zip extension if zip requested because zip tool will complain about extension
f="${f%.*}"
fi
info "Copying $1 to $f..."
cp --reflink=auto --sparse=always "$1" "$f"
if (( $? != 0 )); then if (( $? != 0 )); then
error $LINENO "Could not copy file..." error $LINENO "Could not copy file..."
exit -5 exit -5
fi fi
old_owner=$(stat -c %u:%g "$1") old_owner=$(stat -c %u:%g "$1")
chown "$old_owner" "$2" chown "$old_owner" "$f"
img="$2" img="$f"
fi fi
# cleanup at script exit # cleanup at script exit