forked from ontoportal/ontoportal_docker
-
Notifications
You must be signed in to change notification settings - Fork 1
/
run
executable file
·91 lines (74 loc) · 2.76 KB
/
run
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env bash
# Default values
API_URL="https://data.bioontology.org"
STARTER_ONTOLOGY="STY"
IMAGE_REPOSITORY="bioportal"
IMAGE_TAG="latest"
PROVISION=true # Set the default value to true
# Function to display help message
display_help() {
echo "Start an empty Ontoportal API with only admin user and the STY ontology. Mostly used for the UI tests."
echo "This script is deprecated and will be removed. Use instead ./ontoportal --help"
echo "Usage: $0 [-k API_KEY] [-u API_URL] [-r IMAGE_REPOSITORY] [-t IMAGE_TAG] [-s STARTER_ONTOLOGY] [--no-provision]"
exit 0
}
# Parse command line options
while getopts ":k:u:r:t:s:-:h" opt; do
case $opt in
k) API_KEY="$OPTARG" ;;
u) API_URL="$OPTARG" ;;
r) IMAGE_REPOSITORY="$OPTARG" ;;
t) IMAGE_TAG="$OPTARG" ;;
s) STARTER_ONTOLOGY="$OPTARG" ;;
h) display_help ;;
-) case "${OPTARG}" in
no-provision) PROVISION=false ;;
help) display_help ;;
esac ;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
# Check if required arguments are provided
if [ -z "$API_KEY" ]; then
echo "Error: Missing required argument. Please provide API_KEY."
echo "See help using -h, --help"
exit 1
fi
echo "Running the Ontoportal API and CRON Setup..."
# Copy .env.sample to .env
if ! cp .env.sample .env; then
echo "Error: Failed to copy .env.sample to .env."
exit 1
fi
env_file_path="./.env"
# Read the content of .env file
env_content=$(<"$env_file_path")
# Export bioportal APIKEY, update OP_APIKEY and OP_API_URL in .env file
echo "Exporting bioportal APIKEY..."
env_content="${env_content//OP_APIKEY=<YOUR ONTOPORTAL API KEY>/OP_APIKEY=$API_KEY}"
# Update OP_API_URL in .env file with provided API_URL argument
echo "Updating OP_API_URL in .env file..."
env_content="${env_content//OP_API_URL=\"https:\/\/data.bioontology.org\"/OP_API_URL=$API_URL}"
# Update STARTER_ONTOLOGY in .env file with provided STARTER_ONTOLOGY argument
echo "Updating STARTER_ONTOLOGY in .env file..."
env_content="${env_content//STARTER_ONTOLOGY=\"STY\"/STARTER_ONTOLOGY=$STARTER_ONTOLOGY}"
# Update IMAGE_REPOSITORY in .env file with provided IMAGE_REPOSITORY argument
echo "Updating IMAGE_REPOSITORY in .env file..."
env_content="${env_content//IMAGE_REPOSITORY=bioportal/IMAGE_REPOSITORY=$IMAGE_REPOSITORY}"
# Update IMAGE_TAG in .env file with provided IMAGE_TAG argument
echo "Updating IMAGE_TAG in .env file..."
env_content="${env_content//IMAGE_TAG=latest/IMAGE_TAG=$IMAGE_TAG}"
# Write the modified content back to the .env file
echo "$env_content" >"$env_file_path"
if [ "$PROVISION" = false ]; then
bin/run_api.sh start --no-provision
else
bin/run_api.sh start
fi