-
Notifications
You must be signed in to change notification settings - Fork 3
/
step04_mage2vsf.sh
executable file
·78 lines (67 loc) · 3.05 KB
/
step04_mage2vsf.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env/bash
## ************************************************************************
# Script to configure and build 'mage2vuestorefront' app.
## ************************************************************************
# shellcheck disable=SC1090
# root directory (set before or relative to the current shell script)
DIR_ROOT=${DIR_ROOT:=$(cd "$(dirname "$0")/../" && pwd)}
# Exit immediately if a command exits with a non-zero status.
set -e -x
echo "========================================================================"
echo "Read local configuration."
echo "========================================================================"
. "${DIR_ROOT}/cfg.local.sh"
# check external vars used in this script (see cfg.[work|live].sh)
: "${ES_INDEX_NAME:?}"
: "${ES_URL:?}"
: "${MAGE_API_ACCESS_TOKEN:?}"
: "${MAGE_API_ACCESS_TOKEN_SECRET:?}"
: "${MAGE_API_CONSUMER_KEY:?}"
: "${MAGE_API_CONSUMER_SECRET:?}"
: "${MAGE_URL_REST:?}"
# local context vars
DIR_APPS="/home/${USER}"
DIR_M2V="${DIR_APPS}/mage2vuestorefront"
echo "========================================================================"
echo "Clone 'mage2vuestorefront' application."
echo "========================================================================"
git clone https://github.com/DivanteLtd/mage2vuestorefront.git "${DIR_M2V}"
cd "${DIR_M2V}" || exit 255
#git checkout "feature/es7"
echo "========================================================================"
echo "Build 'mage2vuestorefront' application."
echo "========================================================================"
yarn install
echo "========================================================================"
echo "Create launch script to run all sync tasks."
echo "========================================================================"
cat <<EOM | tee "${DIR_M2V}/replicate.sh" >/dev/null
#!/bin/bash
# Exit immediately if a command exits with a non-zero status.
set -e
ROOT=\$(cd "\$(dirname "\$0")/" && pwd)
M2V_CLI="\${ROOT}/src/cli.js"
export TIME_TO_EXIT="2000"
# Setup connection to Elasticsearch
export ELASTICSEARCH_API_VERSION="7.5"
export DATABASE_URL="${ES_URL}"
# Setup connection to Magento
export MAGENTO_CONSUMER_KEY="${MAGE_API_CONSUMER_KEY}"
export MAGENTO_CONSUMER_SECRET="${MAGE_API_CONSUMER_SECRET}"
export MAGENTO_ACCESS_TOKEN="${MAGE_API_ACCESS_TOKEN}"
export MAGENTO_ACCESS_TOKEN_SECRET="${MAGE_API_ACCESS_TOKEN_SECRET}"
export MAGENTO_URL="${MAGE_URL_REST}"
# Setup default store
export INDEX_NAME="${ES_INDEX_NAME}"
# Perform data replications
node --harmony "\${M2V_CLI}" taxrule --removeNonExistent=true
node --harmony "\${M2V_CLI}" attributes --removeNonExistent=true
node --harmony "\${M2V_CLI}" categories --removeNonExistent=true
node --harmony "\${M2V_CLI}" productcategories
node --harmony "\${M2V_CLI}" products --removeNonExistent=true
EOM
# set 'executable' permissions to the script.
chmod ug+x "${DIR_M2V}/replicate.sh"
echo "========================================================================"
echo "Process is completed."
echo "========================================================================"