-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.sh
executable file
·56 lines (52 loc) · 1.98 KB
/
start.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
here=${0%/*}
pathToOkapi=~/folio
logToFile=0
logFile=
while getopts ":p:o:" option; do
case $option in
p) # Path to Okapi
pathToOkapi=$OPTARG;;
o) # Send output to log file
logToFile=1
logFile=${OPTARG:-"okapi.log"};;
\?) # Invalid option
echo "Error: Invalid option"
exit;;
esac
done
echo "path: $pathToOkapi"
if [ -d "$pathToOkapi"/okapi/okapi-core/target ]; then
printf "Stopping Docker Postgres and Kafka services if running.\n"
docker compose -f "$here"/docker-compose.yml down
# Check if another postgresql might be running on port 5432
if [[ "$(nc -z 127.0.0.1 5432; echo $?)" == "0" ]]; then
printf "Port 5432 is already in use\n"
if [[ -n $(pgrep -f postgresql) ]]; then
printf "A PostgreSQL service is already running,\n"
printf "\nShut down the running PostgreSQL service before starting PostgreSQL in container?"
read -r -p ' [y/N]? ' choice
choice=${choice:-N}
case "$choice" in
y|Y) printf "Attemting to stop PostgreSQL\n"; service postgresql stop ;;
*) printf "\nOkay. Not stopping PostgreSQL, start up of PostgreSQL in contain might fail.\n"; exit 1;;
esac
fi
fi
printf "Starting Postgres, Kafka, elastic search.\n"
docker compose -f "$here"/docker-compose.yml up -d
if [[ $logToFile -eq 1 ]]; then
"$here"/okapi/init-db-start-okapi.sh "$pathToOkapi" >> "$logFile" 2>&1 &
printf "Okapi starting ..."
sleep 20
if [[ "$(tail -1 "$logFile")" == *supertenant\ ok ]]; then
pid=$(pgrep -f "okapi-core/target/okapi-core-fat.jar")
printf "Okapi started in back-ground.\nLogs redirected to '%s'. Okapi PID is [%s] \n\n" "$logFile" "$pid"
else
printf "Okapi started in back-ground.\nLogs redirected to '%s'.\n\n" "$logFile"
fi
else
"$here"/okapi/init-db-start-okapi.sh "$pathToOkapi"
fi
else
printf "Could not find Okapi installation at %s/okapi/okapi-core/target.\n" "$pathToOkapi"
fi