#!/bin/bash
BASEDIR=$(dirname "$0")
export ACCOUNT_ID=XXX
export IB_PASSWORD=XXX
export BKLIST_PATH=/data/tmp/tmp
cd ${BASEDIR}
. ./profile

################################
export BKLIST_NAME=bank_list.txt
export BKBOOK_NAME=bank_book.txt
do_flg=ON
st_file=${BKLIST_PATH}/status.txt
err_file=${BKLIST_PATH}/error.txt
log_file=${BKLIST_PATH}/status.log
history_file=${BKLIST_PATH}/status_history.txt
if [ -f "${st_file}" ]; then
	flg=`cat ${st_file} | grep ok`
	if [[ "${flg}" == "ok" ]]; then
		do_flg=OFF
	fi
fi

if [[ "${do_flg}" == "ON" ]]; then
	if [ -f "${log_file}" ]; then
		cat ${log_file} >> $history_file
		rm -f ${log_file}
	fi
	if [ -f "${err_file}" ]; then
		cat ${err_file} >> $history_file
		rm -f ${err_file}
	fi
	##cd /data/tmp/source/MUFJ
	cd ${BASEDIR}
	python3 mufg2.py 1>$log_file 2>&1
fi
