cd "${0%/*}" || (echo "Could not change-dir to this script's dir!" && exit) # Change the working directory to the script's directory, when running from other location. justRun=0 if [[ $# -eq 1 ]]; then justRun=$1 elif [[ $# -gt 1 ]]; then echo -e "Wrong number of arguments given: ${#}\nPlease execute it like: script.sh "; exit 1 fi if [[ justRun -eq 0 ]]; then if [ ! -d ~/.m2/repository-dnet45/ ]; then mkdir ~/.m2/repository-dnet45/ || (echo -e "The directory \"~/.m2/repository-dnet45/\" could not be created! Exiting.." && exit 2) fi if [ ! -f ~/.m2/repository-dnet45/settings-dnet45.xml ]; then cp ./settings-dnet45.xml ~/.m2/repository-dnet45/ || (echo -e "The file \"settings-dnet45.xml\" could not be copied in directory \"~/.m2/repository-dnet45\"! Exiting.." && exit 3) fi else if [ ! -f ~/.m2/repository-dnet45/settings-dnet45.xml ]; then echo -e "The file \"~/.m2/repository-dnet45/settings-dnet45.xml\" does not exist! Exiting.." && exit 4 fi fi mvn clean install -s ~/.m2/repository-dnet45/settings-dnet45.xml