-
Achraf Achkari authoredAchraf Achkari authored
eHDSIGeneration.sh 2.89 KiB
#!/bin/bash
#Colors definitions for terminal
RED='\033[0;31m'
GREEN='\033[0;32m'
ORANGE='\033[0;33m'
NC='\033[0m'
# Try to get the jar of GOC automatically
jarPath=`ls -l | grep -oh -e "[^ ]*-jar-with-dependencies\.jar"`
if [ -z $jarPath ]; then
echo -e "${RED}Could not detect the JAR of GOC, please provide the path manually"
read -r jarPath
else
absJarPath=`realpath $jarPath`
echo -e "${NC}A GOC JAR has been detected at: (${jarPath}) want you to use it?"
printf "hit enter for yes, enter an other path to change it: "
read -r newJarPath
if [ ! -z $newJarPath ]; then
isAbsPath=`echo "${newJarPath}" | grep ^/.* | wc -l`
if [ $isAbsPath -eq 0 ]; then
echo -e "${RED}[ ${newJarPath} ] is not an absolute path"
exit 0
fi
absJarPath=$newJarPath
fi
fi
#Try to get maven path automatically
mavenPath=`mvn -v | sed -n 2p | grep -oh -e "/.*"`
if [ -z $mavenPath ];then
echo -e "${NC}Could not detect a maven installation, please enter the absolute to the binary file of maven: "
read -r mavenPath
testMaven=`${mavenPath} -v`
if [ -z $testMaven ];then
echo -e "${NC}Wrong maven executable..."
exit 1
fi
else
mavenPath="${mavenPath}/bin/mvn"
fi
echo -e "${NC}Using maven at: ${mavenPath}"
printf "Please enter a path to your BBR (Absolute Path) : "
read -r bbrPath
echo -e $bbrPath
isAbsPath=`echo "${bbrPath}" | grep ^/.* | wc -l`
if [ $isAbsPath -eq 0 ]; then
echo -e "${RED}[ ${bbrPath} ] is not an absolute path"
exit 0
fi
if [ ! -f $bbrPath ]; then
echo -e "${RED}[ ${bbrPath} ] is not a file or doesn't exist !"
exit 0
fi
printf "Please choose the kind of validator you want to generate: \n"
printf "\t 1- Pivot (L3)\n"
printf "\t 2- Scanned (L1)\n"
printf "\t 3- Friendly\n"
printf "your choice: "
read -r choice
if [ $choice -gt 3 -o $choice -lt 1 ]; then
echo "Wrong choice, please repeat and choose between 1 and 3"
exit 0
fi
case $choice in
1)
echo "generating pivot"
validator="pivot"
;;
2)
echo "generation scanned"
validator="scanned"
;;
3)
echo "generation friendly"
validator="friendly"
;;
esac
printf "Please enter when you want to generate the validator: "
read -r workspaceDir
if [ ! -d $workspaceDir ]; then
echo "${RED}The provided workspace is not a valid directory"
exit 0
fi
isAbsPath=`echo "${workspaceDir}" | grep ^/.* | wc -l`
if [ $isAbsPath -eq 0 ]; then
echo -e "${RED}[ ${workspaceDir} ] is not an absolute path"
exit 0
fi
_currDate=`date +%Y-%m-%d-%H-%M-%S`
printf "Please enter the folder name of your validator: (output-${validator}-${_currDate})?"
read -r folderName
if [ -z $folderName ]; then
folderName="output-${validator}-${_currDate}"
fi;
echo "your validator will be generated in: ${workspaceDir}/${folderName}"
java -jar $jarPath -bbr $bbrPath -out "${workspaceDir}/${folderName}" -mvn $mavenPath -serviceName $validator -HL7TEMP_CDACONFFOLDERNAME cdaepsos