Skip to content

Instantly share code, notes, and snippets.

@gonaumov
Last active September 18, 2022 10:23
Show Gist options
  • Save gonaumov/b829053c89cfa6686cd4efda68db0aec to your computer and use it in GitHub Desktop.
Save gonaumov/b829053c89cfa6686cd4efda68db0aec to your computer and use it in GitHub Desktop.
Bash script for installation of latest maven.
#!/bin/bash
set -x
declare -r apacheMavenDownloadUrl="http://apache.cbox.biz/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz"
declare -r directoryName="mvn/"
if [[ $apacheMavenDownloadUrl =~ ([^/]+)\-bin\.tar\.gz$ ]]
then
declare -r resultFileName=$BASH_REMATCH
declare -r resultDirectoryName=${BASH_REMATCH[1]}
else
printf "\nIncorrcet format of Apache Maven download url!\n"
exit 1
fi
mkdir $directoryName
cd $directoryName
wget $apacheMavenDownloadUrl
tar -zxf $resultFileName
declare -r workingDir=$(pwd)
sudo ln -s "$workingDir/$resultDirectoryName/bin/mvn" /usr/local/bin/mvn
rm -v $resultFileName
printf "\nMaven 3 is installed!\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment