# created by Urchlay

#!/bin/sh

if [ -z "$HOME" ]; then
  echo "$0: \$HOME not set in the environment, aborting" 1>&2
  exit 1
fi

DBDIR="$HOME/.local/var/mathics/"

# In case of multiple installs, SCRIPT prefers /usr/lib64 to /usr/lib,
# and higher-numbered python versions to lower-numbered. But this is
# just paranoia, there shouldn't be multiple mathics installations.
SCRIPT=$( /bin/ls -d /usr/lib*/python2.*/site-packages/mathics/manage.py | tac | head -1 )

echo "Initializing mathics SQLite databases in $DBDIR"
mkdir -p $DBDIR
exec python $SCRIPT syncdb --noinput