#!/usr/bin/env bash
#
# Copyright (c) Cognitect, Inc.
# All rights reserved.
set -e

if [ -f /opt/datomic.app.deploy/bin/export-environment ]; then
  . /opt/datomic.app.deploy/bin/export-environment
fi

# In smaller memory configurations, don't run sync libs while Datomic is running
if [[ $(awk '/^MemTotal:/{print $2}' /proc/meminfo) -le 4000000 ]]; then
  exit 0
fi

echo "Syncing libs"
cd `dirname $0`/..
bash sync-libs