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.
|
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
|
justRun=0
|
||||||
|
|
||||||
if [[ $# -eq 1 ]]; then
|
if [[ $# -eq 1 ]]; then # If we have just 1 argument.
|
||||||
justRun=$1
|
numbers_re='^[0-9]+$'
|
||||||
elif [[ $# -gt 1 ]]; then
|
if ! [[ $1 =~ $numbers_re ]]; then # If the first argument is not numeric.
|
||||||
echo -e "Wrong number of arguments given: ${#}\nPlease execute it like: script.sh <justInstall: 0 | 1>"; exit 1
|
echo -e "Invalid, non-numeric argument given: ${1}\nPlease execute it like: installAndRun.sh <1 | 0 (optional)>"; exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ justRun -eq 0 ]]; then
|
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
|
||||||
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
|
fi
|
||||||
|
|
||||||
if [ ! -f ~/.m2/repository-dnet45/settings-dnet45.xml ]; then
|
justRun=$1 # Assign <1> or <0>
|
||||||
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
|
fi
|
||||||
else
|
|
||||||
if [ ! -f ~/.m2/repository-dnet45/settings-dnet45.xml ]; then
|
dnet_repo=~/.m2/repository-dnet45
|
||||||
|
settings_file=settings-dnet45.xml
|
||||||
|
|
||||||
|
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
|
echo -e "The file \"~/.m2/repository-dnet45/settings-dnet45.xml\" does not exist! Exiting.." && exit 4
|
||||||
fi
|
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
|
fi
|
||||||
|
|
||||||
mvn clean install -s ~/.m2/repository-dnet45/settings-dnet45.xml
|
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
|
||||||
|
|
||||||
|
java -jar ./target/uoa-repository-manager-service.jar
|
||||||
|
|
1
pom.xml
1
pom.xml
|
@ -450,6 +450,7 @@
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
|
Loading…
Reference in New Issue