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:
Lampros Smyrnaios 2022-11-17 15:01:27 +02:00
parent f41a5c8985
commit 83c77670ab
2 changed files with 34 additions and 16 deletions

View File

@ -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
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 fi
if [[ justRun -eq 0 ]]; then dnet_repo=~/.m2/repository-dnet45
settings_file=settings-dnet45.xml
if [ ! -d ~/.m2/repository-dnet45/ ]; then if [[ justRun -eq 1 ]]; then
mkdir ~/.m2/repository-dnet45/ || (echo -e "The directory \"~/.m2/repository-dnet45/\" could not be created! Exiting.." && exit 2) if [ ! -f ${dnet_repo}"/"${settings_file} ]; then
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 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
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 fi
mvn clean install -s ~/.m2/repository-dnet45/settings-dnet45.xml java -jar ./target/uoa-repository-manager-service.jar

View File

@ -450,7 +450,8 @@
</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>
</plugin> </plugin>