31
31
32
32
CURRENT_OS=" "
33
33
CURRENT_ARCH=" "
34
- YDB_BIN =" ydb"
34
+ YDB_CLI_BIN =" ydb"
35
35
SHELL_NAME=$( basename " ${SHELL} " )
36
36
37
37
CONTACT_SUPPORT_MESSAGE=" If you think that this should not be, contact support and attach this message.
38
38
System info: $( uname -a) "
39
39
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.
41
41
case ${SYSTEM} in
42
42
Linux | GNU/Linux)
43
43
CURRENT_OS=" linux"
@@ -47,15 +47,15 @@ case ${SYSTEM} in
47
47
;;
48
48
CYGWIN* | MINGW* | MSYS* | Windows_NT | WindowsNT )
49
49
CURRENT_OS=" windows"
50
- YDB_BIN =" ydb.exe"
50
+ YDB_CLI_BIN =" ydb.exe"
51
51
;;
52
52
* )
53
53
printf " '%s' system is not supported yet, or something is going wrong.\\ n" " ${SYSTEM} " , " ${CONTACT_SUPPORT_MESSAGE} "
54
54
exit 1
55
55
;;
56
56
esac
57
57
58
- MACHINE=${YDB_INSTALL_TEST_MACHINE :- $(uname -m)}
58
+ MACHINE=${YDB_CLI_INSTALL_TEST_MACHINE :- $(uname -m)}
59
59
case ${MACHINE} in
60
60
x86_64 | amd64 | i686-64)
61
61
CURRENT_ARCH=" amd64"
@@ -78,15 +78,15 @@ elif [ "${SYSTEM}" = "Darwin" ]; then
78
78
fi
79
79
80
80
DEFAULT_INSTALL_PATH=" ${HOME} /ydb"
81
- YDB_INSTALL_PATH =" ${DEFAULT_INSTALL_PATH} "
81
+ YDB_CLI_INSTALL_PATH =" ${DEFAULT_INSTALL_PATH} "
82
82
RC_PATH=
83
83
NO_RC=
84
84
AUTO_RC=
85
85
86
86
while getopts " hi:r:na" opt ; do
87
87
case " $opt " in
88
88
i)
89
- YDB_INSTALL_PATH =" ${OPTARG} "
89
+ YDB_CLI_INSTALL_PATH =" ${OPTARG} "
90
90
;;
91
91
r)
92
92
RC_PATH=" ${OPTARG} "
@@ -110,7 +110,7 @@ while getopts "hi:r:na" opt ; do
110
110
esac
111
111
done
112
112
113
- CURL_HELP=" ${YDB_TEST_CURL_HELP :- $(curl --help)} "
113
+ CURL_HELP=" ${YDB_CLI_TEST_CURL_HELP :- $(curl --help)} "
114
114
CURL_OPTIONS=(" -fS" )
115
115
function curl_has_option {
116
116
echo " ${CURL_HELP} " | grep -e " $@ " > /dev/null
@@ -131,15 +131,15 @@ function curl_with_retry {
131
131
curl " ${CURL_OPTIONS[@]} " " $@ "
132
132
}
133
133
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:])} "
136
136
137
137
if [ ! -t 0 ]; then
138
138
# stdin is not terminal - we're piped. Skip all interactivity.
139
139
AUTO_RC=yes
140
140
fi
141
141
142
- echo " Downloading ydb ${YDB_VERSION } "
142
+ echo " Downloading ydb ${YDB_CLI_VERSION } "
143
143
144
144
# Download to temp dir, check that executable is healthy, only then move to install path.
145
145
# That prevents partial download in case of download error or cancel.
@@ -151,39 +151,39 @@ function cleanup {
151
151
trap cleanup EXIT
152
152
153
153
# 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} "
156
156
157
157
chmod +x " ${TMP_YDB} "
158
158
# Check that all is ok, and print full version to stdout.
159
159
${TMP_YDB} version || echo " Installation failed. Please contact support. System info: $( uname -a) "
160
160
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"
165
165
166
166
case " ${SHELL_NAME} " in
167
167
bash | zsh)
168
168
;;
169
169
* )
170
- echo " ydb is installed to ${YDB } "
170
+ echo " ydb is installed to ${YDB_CLI } "
171
171
exit 0
172
172
;;
173
173
esac
174
174
175
- YDB_BASH_PATH =" ${YDB_INSTALL_PATH } /path.bash.inc"
175
+ YDB_CLI_BASH_PATH =" ${YDB_CLI_INSTALL_PATH } /path.bash.inc"
176
176
177
177
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"
181
181
export PATH="\$ {bin_path}:\$ {PATH}"
182
182
EOF
183
183
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"
187
187
export PATH="\$ {bin_path}:\$ {PATH}"
188
188
EOF
189
189
fi
@@ -193,11 +193,11 @@ if [ "${NO_RC}" = "yes" ]; then
193
193
fi
194
194
195
195
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
197
197
cat >> " $1 " << EOF
198
198
199
199
# 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
201
201
EOF
202
202
echo " "
203
203
echo " ydb PATH has been added to your '${1} ' profile"
@@ -234,7 +234,7 @@ function ask_for_rc_path() {
234
234
}
235
235
236
236
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."
238
238
}
239
239
240
240
if [ " ${RC_PATH} " != " " ] ; then
0 commit comments