Improve the "installAndRun.sh" script:
- Add the "java -jar" run command. - Add more sanity checks for cmd-args. - Code polishing.
This commit is contained in:
parent
f41a5c8985
commit
83c77670ab
|
@ -1,26 +1,43 @@
|
|||
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.
|
||||
|
||||
if [[ $# -gt 1 ]]; then
|
||||
echo -e "Wrong number of arguments given: ${#}\nPlease execute it like: installAndRun.sh <1 | 0 (optional)>"; exit 1
|
||||
fi
|
||||
|
||||
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 <justInstall: 0 | 1>"; exit 1
|
||||
if [[ $# -eq 1 ]]; then # If we have just 1 argument.
|
||||
numbers_re='^[0-9]+$'
|
||||
if ! [[ $1 =~ $numbers_re ]]; then # If the first argument is not numeric.
|
||||
echo -e "Invalid, non-numeric argument given: ${1}\nPlease execute it like: installAndRun.sh <1 | 0 (optional)>"; exit 2
|
||||
fi
|
||||
|
||||
if [[ $1 -ne 0 && $1 -ne 1 ]]; then # If the 1st argument does NOT equal to < 0 > or < 1 >.
|
||||
echo -e "Invalid argument given: ${1}\nPlease execute it like: installAndRun.sh <1 | 0 (optional)>"; exit 3
|
||||
fi
|
||||
|
||||
justRun=$1 # Assign <1> or <0>
|
||||
fi
|
||||
|
||||
if [[ justRun -eq 0 ]]; then
|
||||
dnet_repo=~/.m2/repository-dnet45
|
||||
settings_file=settings-dnet45.xml
|
||||
|
||||
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
|
||||
if [[ justRun -eq 1 ]]; then
|
||||
if [ ! -f ${dnet_repo}"/"${settings_file} ]; then
|
||||
echo -e "The file \"~/.m2/repository-dnet45/settings-dnet45.xml\" does not exist! Exiting.." && exit 4
|
||||
fi
|
||||
else
|
||||
if [ ! -d ${dnet_repo} ]; then
|
||||
mkdir ${dnet_repo} || (echo -e "The directory \"~/.m2/repository-dnet45/\" could not be created! Exiting.." && exit 5)
|
||||
echo "Created the \"dnet_repo\": ${dnet_repo}"
|
||||
fi
|
||||
|
||||
if [ ! -f ${dnet_repo}"/"${settings_file} ]; then
|
||||
cp ${settings_file} ${dnet_repo}"/"${settings_file} || (echo -e "The file \"settings-dnet45.xml\" could not be copied in directory \"~/.m2/repository-dnet45\"! Exiting.." && exit 6)
|
||||
echo "Copied the \"settings_file\" to: ${dnet_repo}/${settings_file}"
|
||||
fi
|
||||
|
||||
mvn clean install -s ${dnet_repo}"/"${settings_file}
|
||||
fi
|
||||
|
||||
mvn clean install -s ~/.m2/repository-dnet45/settings-dnet45.xml
|
||||
java -jar ./target/uoa-repository-manager-service.jar
|
||||
|
|
Loading…
Reference in New Issue