#!/bin/sh -e
<%text>############################################################</%text>
#
# overnight automation for Theo
#
<%text>############################################################</%text>

if [ "$1" = "--verbose" ]; then
    VERBOSE='--verbose'
    PROGRESS='--progress'
else
    VERBOSE=
    PROGRESS=
fi

cd ${envroot}

RATTAIL="bin/rattail --config=app/cron.conf $PROGRESS"


<%text>##############################</%text>
# sync data
<%text>##############################</%text>

% if env.theo_integrates_with == 'corepos':
# CORE-POS -> Theo
$RATTAIL --runas corepos import-corepos-api --delete
% elif env.theo_integrates_with == 'catapult':
# Catapult -> Theo
$RATTAIL --runas catapult import-catapult --delete
% elif env.theo_integrates_with == 'locsms':
# LOC SMS -> Theo
$RATTAIL --runas locsms import-locsms --delete
% endif

# make sure version data is correct
$RATTAIL --runas theo import-versions --delete --dry-run --warnings