#----------------------------------- # Start of user-changeable variables #----------------------------------- # # Define the client ID and name # CLIENTID=__CLIENTID__ NAME=__NAME__ LOWER_NAME=$(shell echo ${NAME} | tr A-Z a-z) DBNAME=C_${NAME} # # Define the database connection info # DBUSER=__DBUSER__ DBPASS=__DBPASS__ DBHOST=__DBHOST__ DBCONNECT=-u${DBUSER} -p${DBPASS} -h${DBHOST} # # TABLES - tables that may be affected by the import # DUMPFILE - the name of the backup file # TABLES=publisher publisher_account finance_account pending_transaction affiliate DUMPFILE=bk_before_${LOWER_NAME}.sql RPSMISC=/app/tools/rps/bin/misc STYLEHOME=/app/tools/support/lib/Support/DataImport/StyleTemplates DATE=__TIMESTAMP__ # # The name of the publisher template # INPUT="__INPUTFILE__" #--------------------------------- # End of user-changeable variables #--------------------------------- TDTOXL=${RPSMISC}/tdtoxl_v2 STYLE=${STYLEHOME}/publisher_upload_exceptions.fmt # PROG=${RPSMISC}/run_import.pl IMPORT_ARGS=__IMPORTID__ POSTIMPORT=${RPSMISC}/post_import.pl POST_ARGS=__POSTARGS__ LOG_RO=debug_ro.txt LOG=debug.txt BASENAME=report_${LOWER_NAME}_us_publisher_payee REPORT=${BASENAME}_import_${DATE}.txt EXCEPTIONS=${BASENAME}_exceptions_${DATE}.txt EXCEPTIONS_EXCEL=${BASENAME}_exceptions_${DATE}.xls default: $(warning $(DBUSER)) @echo "make backup|restore|test|import|report" backup: mysqldump ${DBCONNECT} ${DBNAME} ${TABLES} > ${DUMPFILE} grep -i "create table" ${DUMPFILE} restore: mysql ${DBCONNECT} ${DBNAME} < ${DUMPFILE} test: perl ${PROG} -c ${CLIENTID} -f ${INPUT} ${IMPORT_ARGS} > ${LOG_RO} import: perl ${PROG} -c ${CLIENTID} -f ${INPUT} -e ${IMPORT_ARGS} > ${LOG} # Generate the import status report grep "^STATUS" ${LOG} | sed "s/^STATUS:\t//" > ${REPORT} # Generate the exception report grep "^STATUS" ${LOG} | head -1 | sed "s/^STATUS:\t//" > ${EXCEPTIONS} grep "^STATUS" ${LOG} | grep "__FAIL__" | grep -v "publisher\-name" | sed "s/^STATUS:\t//" >> ${EXCEPTIONS} cat ${EXCEPTIONS} | ${TDTOXL} -o ${EXCEPTIONS_EXCEL} -s ${STYLE} #zip ${EXCEPTIONS_EXCEL}.zip ${EXCEPTIONS_EXCEL} nice perl ${POSTIMPORT} -c ${CLIENTID} -f ${EXCEPTIONS_EXCEL} -l ${LOG} ${POST_ARGS} find . -type f -not -name ${EXCEPTIONS_EXCEL} -exec gzip {} \;