-
Notifications
You must be signed in to change notification settings - Fork 46
/
demo.sh
62 lines (49 loc) · 2 KB
/
demo.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
#!/bin/bash
function Data::isLoaded() {
Console::start "Checking is demo data loaded for ${SPRYKER_CURRENT_REGION}... "
Database::haveTables && Console::end "[LOADED]" && return "${TRUE}" || return "${FALSE}"
}
function Data::load() {
local brokerInstalled=""
local schedulerSuspended=""
local verboseOption=$([ "${VERBOSE}" == "1" ] && echo -n " -vvv" || echo -n '')
Runtime::waitFor database
Runtime::waitFor broker
Runtime::waitFor search
Runtime::waitFor key_value_store
local force=''
if [ "$1" == '--force' ]; then
force=1
shift || true
fi
for regionData in "${SPRYKER_STORES[@]}"; do
eval "${regionData}"
# shellcheck disable=SC2034
SPRYKER_CURRENT_REGION="${REGION}"
SPRYKER_CURRENT_STORE="${STORES[0]}"
if [ -z "${force}" ] && Data::isLoaded; then
continue
fi
if [ -z "${brokerInstalled}" ]; then
Service::Broker::install
brokerInstalled=1
fi
if [ -z "${schedulerSuspended}" ]; then
schedulerSuspended=1
Service::Scheduler::pause
Registry::Trap::addExitHook 'resumeScheduler' 'Service::Scheduler::unpause'
fi
Console::info "Loading demo data for ${SPRYKER_CURRENT_REGION} region."
Compose::exec "vendor/bin/install${verboseOption} -r ${SPRYKER_PIPELINE} -s clean-storage -s init-storage"
Database::init
for store in "${STORES[@]}"; do
SPRYKER_CURRENT_STORE="${store}"
Console::info "Init storages for ${SPRYKER_CURRENT_STORE} store."
Compose::exec "vendor/bin/install${verboseOption} -r ${SPRYKER_PIPELINE} -s init-storages-per-store"
done
SPRYKER_CURRENT_STORE="${STORES[0]}"
local demoDataSection=${1:-demodata}
Compose::exec "vendor/bin/install${verboseOption} -r ${SPRYKER_PIPELINE} -s init-storages-per-region -s ${demoDataSection}"
done
Registry::Trap::releaseExitHook 'resumeScheduler'
}