Skip to content
Snippets Groups Projects
Commit bf20e717 authored by Renzo Frigato's avatar Renzo Frigato
Browse files

add env variable SCITRAN_SITE_API_URL to config

parent a678f4a2
No related branches found
No related tags found
No related merge requests found
......@@ -31,7 +31,7 @@ DEFAULT_CONFIG = {
'site': {
'id': 'local',
'name': 'Local',
'url': 'https://localhost/api',
'api_url': 'https://localhost/api',
'central_url': 'https://sdmc.scitran.io/api',
'registered': False,
'ssl_cert': None,
......@@ -49,7 +49,7 @@ DEFAULT_CONFIG = {
'data_path': os.path.join(os.path.dirname(__file__), '../persistent/data'),
'schema_path': 'api/schemas',
'elasticsearch_host': 'localhost:9200',
}
},
}
__config = copy.deepcopy(DEFAULT_CONFIG)
......@@ -162,7 +162,7 @@ def initialize_db():
now = datetime.datetime.utcnow()
db.groups.update_one({'_id': 'unknown'}, {'$setOnInsert': { 'created': now, 'modified': now, 'name': 'Unknown', 'roles': []}}, upsert=True)
db.sites.replace_one({'_id': __config['site']['id']}, {'name': __config['site']['name'], 'site_url': __config['site']['url']}, upsert=True)
db.sites.replace_one({'_id': __config['site']['id']}, {'name': __config['site']['name'], 'site_url': __config['site']['api_url']}, upsert=True)
def get_config():
......
......@@ -32,6 +32,9 @@ SCITRAN_PERSISTENT_DB_PATH=${SCITRAN_PERSISTENT_DB_PATH:-"$SCITRAN_PERSISTENT_PA
SCITRAN_PERSISTENT_DB_PORT=${SCITRAN_PERSISTENT_DB_PORT:-"9001"}
SCITRAN_PERSISTENT_DB_URI=${SCITRAN_PERSISTENT_DB_URI:-"mongodb://localhost:$SCITRAN_PERSISTENT_DB_PORT/scitran"}
[ -z "$SCITRAN_RUNTIME_SSL_PEM" ] && SCITRAN_SITE_API_URL="http" || SCITRAN_SITE_API_URL="https"
SCITRAN_SITE_API_URL="$SCITRAN_SITE_API_URL://$SCITRAN_RUNTIME_HOST:$SCITRAN_RUNTIME_PORT/api"
set +o allexport
......@@ -154,15 +157,13 @@ trap "{
sleep 1
# Set API URL
[ -z "$SCITRAN_RUNTIME_SSL_PEM" ] && API_URL="http" || API_URL="https"
API_URL="$API_URL://$SCITRAN_RUNTIME_HOST:$SCITRAN_RUNTIME_PORT/api"
# Boostrap users and groups
if [ $BOOTSTRAP_USERS -eq 1 ]; then
echo "Bootstrapping users"
bin/bootstrap.py --insecure --secret "$SCITRAN_CORE_DRONE_SECRET" $API_URL "$SCITRAN_RUNTIME_BOOTSTRAP"
bin/bootstrap.py --insecure --secret "$SCITRAN_CORE_DRONE_SECRET" $SCITRAN_SITE_API_URL "$SCITRAN_RUNTIME_BOOTSTRAP"
echo "Bootstrapped users"
else
echo "Database exists at $SCITRAN_PERSISTENT_PATH/db. Not bootstrapping users."
......@@ -183,7 +184,7 @@ if [ -f "$SCITRAN_PERSISTENT_DATA_PATH/.bootstrapped" ]; then
echo "Persistence store exists at $SCITRAN_PERSISTENT_PATH/data. Not bootstrapping data. Remove to re-bootstrap."
else
echo "Bootstrapping testdata"
folder_reaper --insecure --secret "$SCITRAN_CORE_DRONE_SECRET" $API_URL "$SCITRAN_PERSISTENT_PATH/testdata"
folder_reaper --insecure --secret "$SCITRAN_CORE_DRONE_SECRET" $SCITRAN_SITE_API_URL "$SCITRAN_PERSISTENT_PATH/testdata"
echo "Bootstrapped testdata"
touch "$SCITRAN_PERSISTENT_DATA_PATH/.bootstrapped"
fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment