#!/bin/bash
# limit open files
# ulimit -n 12345
# limit resident size to 5 GB, which is plenty
# ulimit -m 5000000
exec 2>&1
if [ -x /opt/logjam/bin/logjam-importer ]; then
    importer=/opt/logjam/bin/logjam-importer
elif [ -x /usr/local/bin/logjam-importer ]; then
    importer=/usr/local/bin/logjam-importer
elif [ "$(which logjam-importer)" != "" ]; then
    importer=logjam-importer
else
  echo "ERROR: no logjam-importer binary found"
  sleep 10
  exit 1
fi

if test -f /etc/default/logjam; then
    set -a; source /etc/default/logjam; set +a
    LOGJAM_URI=${LOGJAM_URI:-LOGJAM_URL}
else
    LOGJAM_URI=LOGJAM_URL
fi

exec $importer -c LOGJAM_SERVICE_TARGET_DIR/importer.conf -L "$LOGJAM_URI" "$@"
