This repository has been archived by the owner on Mar 5, 2019. It is now read-only.
/
environment.sh
115 lines (87 loc) · 3.5 KB
/
environment.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/usr/bin/env bash
setup_environment_file ()
{
local envFile="${CORE_DATA}/.env"
if [[ ! -e "${envFile}" ]]; then
mkdir -p "${HOME}/.ark"
touch "${envFile}"
fi
if ! grep -q "ARK_LOG_LEVEL" "${envFile}"; then
echo "ARK_LOG_LEVEL=debug" >> "$envFile" 2>&1
fi
if ! grep -q "ARK_DB_HOST" "${envFile}"; then
echo "ARK_DB_HOST=localhost" >> "$envFile" 2>&1
fi
if ! grep -q "ARK_DB_PORT" "${envFile}"; then
echo "ARK_DB_PORT=5432" >> "$envFile" 2>&1
fi
if ! grep -q "ARK_DB_USERNAME" "${envFile}"; then
echo "ARK_DB_USERNAME=${USER}" >> "$envFile" 2>&1
fi
if ! grep -q "ARK_DB_PASSWORD" "${envFile}"; then
echo "ARK_DB_PASSWORD=password" >> "$envFile" 2>&1
fi
if ! grep -q "ARK_DB_DATABASE" "${envFile}"; then
echo "ARK_DB_DATABASE=ark_${CORE_NETWORK}" >> "$envFile" 2>&1
fi
. "${envFile}"
}
setup_environment ()
{
set_locale
if [[ ! -f "$commander_config" ]]; then
ascii
install_base_dependencies
install_program_dependencies
install_nodejs_dependencies
install_system_updates
# create ~/.commander
touch "$commander_config"
echo "CORE_REPO=https://github.com/ArkEcosystem/core" >> "$commander_config" 2>&1
echo "CORE_BRANCH=master" >> "$commander_config" 2>&1
echo "CORE_DIR=${HOME}/ark-core" >> "$commander_config" 2>&1
echo "CORE_DATA=${HOME}/.ark" >> "$commander_config" 2>&1
echo "CORE_CONFIG=${HOME}/.ark/config" >> "$commander_config" 2>&1
echo "CORE_TOKEN=ark" >> "$commander_config" 2>&1
echo "CORE_NETWORK=mainnet" >> "$commander_config" 2>&1
echo "EXPLORER_REPO=https://github.com/ArkEcosystem/explorer" >> "$commander_config" 2>&1
echo "EXPLORER_DIR=${HOME}/ark-explorer" >> "$commander_config" 2>&1
. "$commander_config"
# create ~/.ark/.env
setup_environment_file
success "All system dependencies have been installed!"
check_and_recommend_reboot
press_to_continue
fi
if [[ -e "$commander_config" ]]; then
if ! grep -q "CORE_REPO" "${commander_config}"; then
echo "CORE_REPO=https://github.com/ArkEcosystem/core" >> "$commander_config" 2>&1
fi
if ! grep -q "CORE_BRANCH" "${commander_config}"; then
echo "CORE_BRANCH=master" >> "$commander_config" 2>&1
fi
if ! grep -q "CORE_DIR" "${commander_config}"; then
echo "CORE_DIR=${HOME}/ark-core" >> "$commander_config" 2>&1
fi
if ! grep -q "CORE_DATA" "${commander_config}"; then
echo "CORE_DATA=${HOME}/.ark" >> "$commander_config" 2>&1
fi
if ! grep -q "CORE_CONFIG" "${commander_config}"; then
echo "CORE_CONFIG=${HOME}/.ark/config" >> "$commander_config" 2>&1
fi
if ! grep -q "CORE_TOKEN" "${commander_config}"; then
echo "CORE_TOKEN=ark" >> "$commander_config" 2>&1
fi
if ! grep -q "CORE_NETWORK" "${commander_config}"; then
echo "CORE_NETWORK=mainnet" >> "$commander_config" 2>&1
fi
if ! grep -q "EXPLORER_REPO" "${commander_config}"; then
echo "EXPLORER_REPO=https://github.com/ArkEcosystem/explorer" >> "$commander_config" 2>&1
fi
if ! grep -q "EXPLORER_DIR" "${commander_config}"; then
echo "EXPLORER_DIR=${HOME}/ark-explorer" >> "$commander_config" 2>&1
fi
. "$commander_config"
setup_environment_file
fi
}