Skip to content

Commit 738b572

Browse files
authored
Rename YDB CLI installation script env variables (#17539)
1 parent 63874fb commit 738b572

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

ydb/apps/ydb/install/install.sh

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ fi
3131

3232
CURRENT_OS=""
3333
CURRENT_ARCH=""
34-
YDB_BIN="ydb"
34+
YDB_CLI_BIN="ydb"
3535
SHELL_NAME=$(basename "${SHELL}")
3636

3737
CONTACT_SUPPORT_MESSAGE="If you think that this should not be, contact support and attach this message.
3838
System info: $(uname -a)"
3939

40-
SYSTEM=${YDB_INSTALL_TEST_SYSTEM:-$(uname -s)} # $(uname -o) is not supported on macOS for example.
40+
SYSTEM=${YDB_CLI_INSTALL_TEST_SYSTEM:-$(uname -s)} # $(uname -o) is not supported on macOS for example.
4141
case ${SYSTEM} in
4242
Linux | GNU/Linux)
4343
CURRENT_OS="linux"
@@ -47,15 +47,15 @@ case ${SYSTEM} in
4747
;;
4848
CYGWIN* | MINGW* | MSYS* | Windows_NT | WindowsNT )
4949
CURRENT_OS="windows"
50-
YDB_BIN="ydb.exe"
50+
YDB_CLI_BIN="ydb.exe"
5151
;;
5252
*)
5353
printf "'%s' system is not supported yet, or something is going wrong.\\n" "${SYSTEM}", "${CONTACT_SUPPORT_MESSAGE}"
5454
exit 1
5555
;;
5656
esac
5757

58-
MACHINE=${YDB_INSTALL_TEST_MACHINE:-$(uname -m)}
58+
MACHINE=${YDB_CLI_INSTALL_TEST_MACHINE:-$(uname -m)}
5959
case ${MACHINE} in
6060
x86_64 | amd64 | i686-64)
6161
CURRENT_ARCH="amd64"
@@ -78,15 +78,15 @@ elif [ "${SYSTEM}" = "Darwin" ]; then
7878
fi
7979

8080
DEFAULT_INSTALL_PATH="${HOME}/ydb"
81-
YDB_INSTALL_PATH="${DEFAULT_INSTALL_PATH}"
81+
YDB_CLI_INSTALL_PATH="${DEFAULT_INSTALL_PATH}"
8282
RC_PATH=
8383
NO_RC=
8484
AUTO_RC=
8585

8686
while getopts "hi:r:na" opt ; do
8787
case "$opt" in
8888
i)
89-
YDB_INSTALL_PATH="${OPTARG}"
89+
YDB_CLI_INSTALL_PATH="${OPTARG}"
9090
;;
9191
r)
9292
RC_PATH="${OPTARG}"
@@ -110,7 +110,7 @@ while getopts "hi:r:na" opt ; do
110110
esac
111111
done
112112

113-
CURL_HELP="${YDB_TEST_CURL_HELP:-$(curl --help)}"
113+
CURL_HELP="${YDB_CLI_TEST_CURL_HELP:-$(curl --help)}"
114114
CURL_OPTIONS=("-fS")
115115
function curl_has_option {
116116
echo "${CURL_HELP}" | grep -e "$@" > /dev/null
@@ -131,15 +131,15 @@ function curl_with_retry {
131131
curl "${CURL_OPTIONS[@]}" "$@"
132132
}
133133

134-
YDB_STORAGE_URL="${YDB_STORAGE_URL:-"https://storage.yandexcloud.net/yandexcloud-ydb"}"
135-
YDB_VERSION="${YDB_VERSION:-$(curl_with_retry -s "${YDB_STORAGE_URL}/release/stable" | tr -d [:space:])}"
134+
YDB_CLI_STORAGE_URL="${YDB_CLI_STORAGE_URL:-"https://storage.yandexcloud.net/yandexcloud-ydb"}"
135+
YDB_CLI_VERSION="${YDB_CLI_VERSION:-$(curl_with_retry -s "${YDB_CLI_STORAGE_URL}/release/stable" | tr -d [:space:])}"
136136

137137
if [ ! -t 0 ]; then
138138
# stdin is not terminal - we're piped. Skip all interactivity.
139139
AUTO_RC=yes
140140
fi
141141

142-
echo "Downloading ydb ${YDB_VERSION}"
142+
echo "Downloading ydb ${YDB_CLI_VERSION}"
143143

144144
# Download to temp dir, check that executable is healthy, only then move to install path.
145145
# That prevents partial download in case of download error or cancel.
@@ -151,39 +151,39 @@ function cleanup {
151151
trap cleanup EXIT
152152

153153
# Download and show progress.
154-
TMP_YDB="${TMP_INSTALL_PATH}/${YDB_BIN}"
155-
curl_with_retry "${YDB_STORAGE_URL}/release/${YDB_VERSION}/${CURRENT_OS}/${CURRENT_ARCH}/${YDB_BIN}" -o "${TMP_YDB}"
154+
TMP_YDB="${TMP_INSTALL_PATH}/${YDB_CLI_BIN}"
155+
curl_with_retry "${YDB_CLI_STORAGE_URL}/release/${YDB_CLI_VERSION}/${CURRENT_OS}/${CURRENT_ARCH}/${YDB_CLI_BIN}" -o "${TMP_YDB}"
156156

157157
chmod +x "${TMP_YDB}"
158158
# Check that all is ok, and print full version to stdout.
159159
${TMP_YDB} version || echo "Installation failed. Please contact support. System info: $(uname -a)"
160160

161-
mkdir -p "${YDB_INSTALL_PATH}/bin"
162-
YDB="${YDB_INSTALL_PATH}/bin/${YDB_BIN}"
163-
mv -f "${TMP_YDB}" "${YDB}"
164-
mkdir -p "${YDB_INSTALL_PATH}/install"
161+
mkdir -p "${YDB_CLI_INSTALL_PATH}/bin"
162+
YDB_CLI="${YDB_CLI_INSTALL_PATH}/bin/${YDB_CLI_BIN}"
163+
mv -f "${TMP_YDB}" "${YDB_CLI}"
164+
mkdir -p "${YDB_CLI_INSTALL_PATH}/install"
165165

166166
case "${SHELL_NAME}" in
167167
bash | zsh)
168168
;;
169169
*)
170-
echo "ydb is installed to ${YDB}"
170+
echo "ydb is installed to ${YDB_CLI}"
171171
exit 0
172172
;;
173173
esac
174174

175-
YDB_BASH_PATH="${YDB_INSTALL_PATH}/path.bash.inc"
175+
YDB_CLI_BASH_PATH="${YDB_CLI_INSTALL_PATH}/path.bash.inc"
176176

177177
if [ "${SHELL_NAME}" = "bash" ]; then
178-
cat >"${YDB_BASH_PATH}" <<EOF
179-
ydb_dir="\$(cd "\$(dirname "\${BASH_SOURCE[0]}")" && pwd)"
180-
bin_path="\${ydb_dir}/bin"
178+
cat >"${YDB_CLI_BASH_PATH}" <<EOF
179+
ydb_cli_dir="\$(cd "\$(dirname "\${BASH_SOURCE[0]}")" && pwd)"
180+
bin_path="\${ydb_cli_dir}/bin"
181181
export PATH="\${bin_path}:\${PATH}"
182182
EOF
183183
else
184-
cat >"${YDB_BASH_PATH}" <<EOF
185-
ydb_dir="\$(cd "\$(dirname "\${(%):-%N}")" && pwd)"
186-
bin_path="\${ydb_dir}/bin"
184+
cat >"${YDB_CLI_BASH_PATH}" <<EOF
185+
ydb_cli_dir="\$(cd "\$(dirname "\${(%):-%N}")" && pwd)"
186+
bin_path="\${ydb_cli_dir}/bin"
187187
export PATH="\${bin_path}:\${PATH}"
188188
EOF
189189
fi
@@ -193,11 +193,11 @@ if [ "${NO_RC}" = "yes" ]; then
193193
fi
194194

195195
function modify_rc() {
196-
if ! grep -Fq "if [ -f '${YDB_BASH_PATH}' ]; then source '${YDB_BASH_PATH}'; fi" "$1"; then
196+
if ! grep -Fq "if [ -f '${YDB_CLI_BASH_PATH}' ]; then source '${YDB_CLI_BASH_PATH}'; fi" "$1"; then
197197
cat >> "$1" <<EOF
198198
199199
# The next line updates PATH for YDB CLI.
200-
if [ -f '${YDB_BASH_PATH}' ]; then source '${YDB_BASH_PATH}'; fi
200+
if [ -f '${YDB_CLI_BASH_PATH}' ]; then source '${YDB_CLI_BASH_PATH}'; fi
201201
EOF
202202
echo ""
203203
echo "ydb PATH has been added to your '${1}' profile"
@@ -234,7 +234,7 @@ function ask_for_rc_path() {
234234
}
235235

236236
function print_rc_guide() {
237-
echo "Source '${YDB_BASH_PATH}' in your profile to add the command line directory to your \$PATH."
237+
echo "Source '${YDB_CLI_BASH_PATH}' in your profile to add the command line directory to your \$PATH."
238238
}
239239

240240
if [ "${RC_PATH}" != "" ] ; then

0 commit comments

Comments
 (0)