<commit_before>#!/bin/bash

if [ $# -ne 5 ]; then
	echo "Usage: $0 SRC_ATLAS_CONNECTION TARGET_ATLAS_CONNECTION PREV_DATA_RELEASE ADMIN_PWD ERROR_NOTIFICATION_EMAILADDRESS"
	exit;
fi

SRC_ATLAS_CONNECTION=$1
TARGET_ATLAS_CONNECTION=$2
PREV_DATA_RELEASE=$3
ADMIN_PWD=$4
ERROR_NOTIFICATION_EMAILADDRESS=$5

MICROARRAY_HOME=/ebi/microarray/home
RELEASES_HOME=${MICROARRAY_HOME}/atlas-production/releases
TARGET_ATLAS_USER=`echo ${TARGET_ATLAS_CONNECTION} | awk -F'/' '{print $1}'`
DATA_RELEASE=`date +'%y.%m'`

log="/tmp/release_db."`eval date +%Y%m%d`".log"

echo "Beginning processing..."  > $log
cd /nfs/ma/home/gxa/release/gxa/sql
pushd flat-array-src
./make_flat_array.sh
cp flat_array ../
cp flat_array.pc ../
popd

echo "Packaging source DB..."  >> $log
./package_db.sh ${SRC_ATLAS_CONNECTION} atlas-data-relcan  2>&1 > atlas-data-relcan-package.log
echo "Finished packaging source DB - log:" >> $log
cat atlas-data-relcan-package.log >> $log
mv atlas-data-relcan-package.log atlas-data-relcan

echo "Installing into target DB..."  >> $log
cd atlas-data-relcan
chmod 744 install.sh
./install.sh ${TARGET_ATLAS_CONNECTION} ${TARGET_ATLAS_USER}_DATA Data 2>&1 > atlas-data-relcan-install.log
echo "Finished installing into target DB - errors  (if any):" >> $log
grep error install.log  | egrep -v '0 Rows not loaded due to data errors' >> $log
grep ERROR install.log >> $log
grep -ir error atlas-data-relcan-install.log >> $log
echo "Installation into target DB log :" >> $log
grep error atlas-data-relcan-install.log >> $log

export DATA_RELEASE=${DATA_RELEASE}
export PREV_DATA_RELEASE=${PREV_DATA_RELEASE}
export ADMIN_PWD=${<PASSWORD>}
awk '{while(match($0,"[$]{[^}]*}")) {var=substr($0,RSTART+2,RLENGTH -3);gsub("[$]{"var"}",ENVIRON[var])}}1' < default_db_config.sql.template > default_db_config.sql

echo "Installing into target DB the following default DB config:"  >> $log
cat default_db_config.sql >> $log
sqlplus -L -S ${TARGET_ATLAS_CONNECTION} @default_db_config.sql
rm -rf default_db_config.sql
echo "Installed the default DB config successfully"  >> $log

echo "Removing local data release directory"  >> $log
cd ..
cp -r atlas-data-relcan $RELEASES_HOME
rm -rf atlas-data-relcan
echo "Removed local data release directory successfully"  >> $log

# Send error notification email
err_msg="Release DB status for: "`date +'%d-%m-%Y'`
mailx -s "$err_msg" ${ERROR_NOTIFICATION_EMAILADDRESS} < $log

echo "Done"  >> $log<commit_msg>Ticket #2868 - Modified email message<commit_after>#!/bin/bash

if [ $# -ne 5 ]; then
	echo "Usage: $0 SRC_ATLAS_CONNECTION TARGET_ATLAS_CONNECTION PREV_DATA_RELEASE ADMIN_PWD ERROR_NOTIFICATION_EMAILADDRESS"
	exit;
fi

SRC_ATLAS_CONNECTION=$1
TARGET_ATLAS_CONNECTION=$2
PREV_DATA_RELEASE=$3
ADMIN_PWD=$4
ERROR_NOTIFICATION_EMAILADDRESS=$5

MICROARRAY_HOME=/ebi/microarray/home
RELEASES_HOME=${MICROARRAY_HOME}/atlas-production/releases
TARGET_ATLAS_USER=`echo ${TARGET_ATLAS_CONNECTION} | awk -F'/' '{print $1}'`
DATA_RELEASE=`date +'%y.%m'`

log="/tmp/release_db."`eval date +%Y%m%d`".log"

echo "Beginning processing..."  > $log
cd /nfs/ma/home/gxa/release/gxa/sql
pushd flat-array-src
./make_flat_array.sh
cp flat_array ../
cp flat_array.pc ../
popd

echo "Packaging source DB..."  >> $log
./package_db.sh ${SRC_ATLAS_CONNECTION} atlas-data-relcan  2>&1 > atlas-data-relcan-package.log
echo "Finished packaging source DB - log:" >> $log
cat atlas-data-relcan-package.log >> $log
mv atlas-data-relcan-package.log atlas-data-relcan

echo "Installing into target DB..."  >> $log
cd atlas-data-relcan
chmod 744 install.sh
./install.sh ${TARGET_ATLAS_CONNECTION} ${TARGET_ATLAS_USER}_DATA Data 2>&1 > atlas-data-relcan-install.log
echo "Finished installing into target DB - errors  (if any):" >> $log
grep error install.log  | egrep -v '0 Rows not loaded due to data errors' >> $log
grep ERROR install.log >> $log
grep -ir error atlas-data-relcan-install.log >> $log
echo "Installation into target DB log :" >> $log
grep error atlas-data-relcan-install.log >> $log

export DATA_RELEASE=${DATA_RELEASE}
export PREV_DATA_RELEASE=${PREV_DATA_RELEASE}
export ADMIN_PWD=${<PASSWORD>}
awk '{while(match($0,"[$]{[^}]*}")) {var=substr($0,RSTART+2,RLENGTH -3);gsub("[$]{"var"}",ENVIRON[var])}}1' < default_db_config.sql.template > default_db_config.sql

echo "Installing into target DB the following default DB config:"  >> $log
cat default_db_config.sql >> $log
sqlplus -L -S ${TARGET_ATLAS_CONNECTION} @default_db_config.sql
rm -rf default_db_config.sql
echo "Installed the default DB config successfully"  >> $log

echo "Removing local data release directory"  >> $log
cd ..
cp -r atlas-data-relcan $RELEASES_HOME
rm -rf atlas-data-relcan
echo "Removed local data release directory successfully"  >> $log

# Send error notification email
err_msg="[gxa/cron] Release DB status for: "`date +'%d-%m-%Y'`
mailx -s "$err_msg" ${ERROR_NOTIFICATION_EMAILADDRESS} < $log

echo "Done"  >> $log
{'fraction_non_alphanumeric': 0.14535474689977637, 'fraction_numerical': 0.00935149420613946, 'mean_word_length': 5.3979193758127435, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 81, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1308830', 'n_tokens_mistral': 1875, 'n_tokens_neox': 1795, 'n_words': 432}