Skip to content

Commit

Permalink
#734: create doUnzip function (#737)
Browse files Browse the repository at this point in the history
  • Loading branch information
CREITZ25 authored May 3, 2022
1 parent 2cf2ff0 commit a40c9e1
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions scripts/src/main/resources/scripts/functions
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,45 @@ function doExtract() {
doEcho "Successfully extracted archive ${filename} to updates/extracted"
}

# $1: the file to unzip
# $2: target_dir
function doUnzip() {
if ! command -v unzip &> /dev/null
then
pckmngers=("apt-get" "yum" "pacman" "emerge" "zypp" "apk" "dnf" "brew")

for t in "${pckmngers[@]}"; do
command -v "${t}" > /dev/null
if [ "${?}" -eq "0" ]
then
pckmnger=${t}
fi
done
case ${pckmnger} in
apt-get) doEcho "installing unzip..."
doRunCommand "sudo ${pckmnger} install unzip";;
yum) doEcho "installing unzip..."
doRunCommand "sudo ${pckmnger} install unzip";;
pacman) doEcho "installing unzip..."
doRunCommand "sudo ${pckmnger} -S unzip";;
emerge) doEcho "installing unzip..."
doRunCommand "sudo ${pckmnger} install unzip";;
zypp) doEcho "installing unzip..."
doRunCommand "sudo ${pckmnger} install unzip";;
apk) doEcho "installing unzip..."
doRunCommand "sudo ${pckmnger} add unzip";;
dnf) doEcho "installing unzip..."
doRunCommand "sudo ${pckmnger} install unzip";;
brew) doEcho "installing unzip..."
doRunCommand "sudo ${pckmnger} install unzip";;
*) doEcho "please install unzip manually and start again"
exit;;
esac
fi
doEcho "unzip archive..."
doRunCommand "unzip -qn '${1}' -d '${target_dir}'"
}

# $1: absolute path of file or folder to move
# $2: optional target (e.g. "${DEVON_IDE_HOME}/software/")
# $3: backup path
Expand Down

0 comments on commit a40c9e1

Please sign in to comment.