#!/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 larger memory configurations, sync libs runs before stopping Datomic
if [[ $(awk '/^MemTotal:/{print $2}' /proc/meminfo) -gt 4000000 ]]; then
  exit 0
fi

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