@@ -16,11 +16,21 @@ echo_failed_command() {
16
16
}
17
17
trap echo_failed_command EXIT
18
18
19
+ clear
20
+ echo " "
21
+ echo " █████╗ ███████╗████████╗██████╗ █████╗ ███████╗██╗ ██╗███████╗██╗ ██╗"
22
+ echo " ██╔══██╗██╔════╝╚══██╔══╝██╔══██╗██╔══██╗ ██╔════╝██║ ██║██╔════╝██║ ██║ "
23
+ echo " ███████║███████╗ ██║ ██████╔╝███████║ ███████╗███████║█████╗ ██║ ██║ "
24
+ echo " ██╔══██║╚════██║ ██║ ██╔══██╗██╔══██║ ╚════██║██╔══██║██╔══╝ ██║ ██║"
25
+ echo " ██║ ██║███████║ ██║ ██║ ██║██║ ██║ ███████║██║ ██║███████╗███████╗███████╗"
26
+ echo " ╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚══════╝╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝"
27
+ echo " "
28
+
29
+ echo " Installing Astra Cli, please wait... "
19
30
# Global variables
20
31
ASTRA_CLI_VERSION=" 0.3.2-alpha1"
21
32
ASTRA_CLI_PLATFORM=$( uname)
22
33
ASTRA_CLI_DIR=" $HOME /.astra/cli"
23
- ASTRA_CLI_DIR_RAW=' $HOME/.astra/cli'
24
34
25
35
# Local variables
26
36
astra_tmp_folder=" $HOME /.astra/tmp"
@@ -33,9 +43,9 @@ astra_profile="${HOME}/.profile"
33
43
astra_bashrc=" ${HOME} /.bashrc"
34
44
astra_zshrc=" ${ZDOTDIR:- ${HOME} } /.zshrc"
35
45
astra_init_snippet=$( cat << EOF
36
- #THIS MUST BE AT THE END OF THE FILE FOR ASTRA TO WORK!!!
37
- export ASTRADIR="$ASTRA_CLI_DIR_RAW "
38
- [[ -s "${ASTRADIR } /astra-init.sh" ]] && source "${ASTRADIR } /astra-init.sh"
46
+ #THIS MUST BE AT THE END OF THE FILE FOR ASTRA_CLI TO WORK!!!
47
+ export ASTRADIR="$ASTRA_CLI_DIR "
48
+ [[ -s "${ASTRA_CLI_DIR } /astra-init.sh" ]] && source "${ASTRA_CLI_DIR } /astra-init.sh"
39
49
EOF
40
50
)
41
51
@@ -59,8 +69,9 @@ case "$(uname)" in
59
69
esac
60
70
61
71
# Sanity checks
72
+ echo " "
73
+ echo " Checking prerequisites:"
62
74
63
- echo " Looking for a previous installation of SDKMAN..."
64
75
if [ -d " $ASTRA_DIR " ]; then
65
76
echo " ASTRA-CLI found."
66
77
echo " "
@@ -75,8 +86,8 @@ if [ -d "$ASTRA_DIR" ]; then
75
86
echo " "
76
87
exit 0
77
88
fi
89
+ echo " $( tput setaf 2) [OK]$( tput setaf 7) - No previous installation detected."
78
90
79
- echo " Looking for unzip..."
80
91
if ! command -v unzip > /dev/null; then
81
92
echo " Not found."
82
93
echo " ======================================================================================================"
@@ -87,8 +98,8 @@ if ! command -v unzip > /dev/null; then
87
98
echo " "
88
99
exit 1
89
100
fi
101
+ echo " $( tput setaf 2) [OK]$( tput setaf 7) - unzip command is available"
90
102
91
- echo " Looking for zip..."
92
103
if ! command -v zip > /dev/null; then
93
104
echo " Not found."
94
105
echo " ======================================================================================================"
@@ -99,8 +110,8 @@ if ! command -v zip > /dev/null; then
99
110
echo " "
100
111
exit 1
101
112
fi
113
+ echo " $( tput setaf 2) [OK]$( tput setaf 7) - zip command is available"
102
114
103
- echo " Looking for curl..."
104
115
if ! command -v curl > /dev/null; then
105
116
echo " Not found."
106
117
echo " "
@@ -112,55 +123,27 @@ if ! command -v curl > /dev/null; then
112
123
echo " "
113
124
exit 1
114
125
fi
126
+ echo " $( tput setaf 2) [OK]$( tput setaf 7) - curl command is available"
115
127
116
- if [[ " $solaris " == true ]]; then
117
- echo " Looking for gsed..."
118
- if [ -z $( which gsed) ]; then
119
- echo " Not found."
120
- echo " "
121
- echo " ======================================================================================================"
122
- echo " Please install gsed on your solaris system."
123
- echo " "
124
- echo " SDKMAN uses gsed extensively."
125
- echo " "
126
- echo " Restart after installing gsed."
127
- echo " ======================================================================================================"
128
- echo " "
129
- exit 1
130
- fi
131
- else
132
- echo " Looking for sed..."
133
- if [ -z $( command -v sed) ]; then
134
- echo " Not found."
135
- echo " "
136
- echo " ======================================================================================================"
137
- echo " Please install sed on your system using your favourite package manager."
138
- echo " "
139
- echo " Restart after installing sed."
140
- echo " ======================================================================================================"
141
- echo " "
142
- exit 1
143
- fi
144
- fi
145
-
146
- echo " Installing Astra Cli scripts..."
147
-
148
- # Create directory structure
149
-
150
- echo " Create distribution directories..."
128
+ echo " "
129
+ echo " Preparing directories:"
151
130
mkdir -p " $astra_tmp_folder "
152
- mkdir -p " $ASTRA_CLI_DIR_RAW "
131
+ echo " $( tput setaf 2) [OK]$( tput setaf 7) - Created $astra_tmp_folder "
132
+ mkdir -p " $ASTRA_CLI_DIR "
133
+ echo " $( tput setaf 2) [OK]$( tput setaf 7) - Created $ASTRA_CLI_DIR "
153
134
154
- # script cli distribution
155
- echo " Installing script cli archive..."
156
- # fetch distribution
157
- download_url=" ${ASTRA_SERVICE} /...."
158
- astra_zip_file=" ${astra_tmp_folder} /astra-cli-${ASTRAVERSION} .zip"
159
- echo " * Downloading..."
160
- curl --fail --location --progress-bar " $download_url " > " $astra_zip_file "
135
+ echo " "
136
+ echo " Downloading archive:"
137
+ download_url=" https://github.com/datastaxdevs/datastaxdevs.github.io/raw/master/cli/${ASTRA_CLI_VERSION} .zip"
138
+ astra_zip_file=" ${astra_tmp_folder} /astra-cli-${ASTRA_CLI_VERSION} .zip"
139
+ if [ -f " $astra_zip_file " ]; then
140
+ echo " $( tput setaf 2) [OK]$( tput setaf 7) - Archive is already there"
141
+ else
142
+ curl --fail --location --progress-bar " $download_url " > " $astra_zip_file "
143
+ echo " $( tput setaf 2) [OK]$( tput setaf 7) - File downloaded"
144
+ fi
161
145
162
146
# check integrity
163
- echo " * Checking archive integrity..."
164
147
ARCHIVE_OK=$( unzip -qt " $astra_zip_file " | grep ' No errors detected in compressed data' )
165
148
if [[ -z " $ARCHIVE_OK " ]]; then
166
149
echo " Downloaded zip archive corrupt. Are you connected to the internet?"
@@ -170,52 +153,49 @@ if [[ -z "$ARCHIVE_OK" ]]; then
170
153
echo " * report on channel: https://sdkman.slack.com/app_redirect?channel=user-issues"
171
154
exit
172
155
fi
156
+ echo " $( tput setaf 2) [OK]$( tput setaf 7) - Integrity of the archive checked"
157
+
173
158
174
- # extract
175
- echo " * Extracting archive..."
176
159
if [[ " $cygwin " == ' true' ]]; then
177
- astratmp_folder=$( cygpath -w " $astratmp_folder " )
178
- astrazip_file=$( cygpath -w " $astrazip_file " )
179
- astrazip_base_folder=$( cygpath -w " $astrazip_base_folder " )
160
+ astra_tmp_folder=$( cygpath -w " $astra_tmp_folder " )
161
+ astra_zip_file=$( cygpath -w " $astra_zip_file " )
180
162
fi
181
- unzip -qo " $astrazip_file " -d " $astratmp_folder "
182
-
183
- # copy in place
184
163
185
- echo " * Copying archive contents..."
186
- cp -rf " ${astrazip_base_folder} /" * " $ASTRA_DIR "
164
+ echo " "
165
+ echo " Extracting and installation:"
166
+ unzip -qo " $astra_zip_file " -d " $astra_tmp_folder "
167
+ echo " $( tput setaf 2) [OK]$( tput setaf 7) - Extraction is successful"
187
168
188
- # clean up
189
- echo " * Cleaning up..."
190
- rm -rf " $astra_zip_base_folder "
191
169
rm -rf " $astra_zip_file "
170
+ cp -rf " ${astra_tmp_folder} /" * " $ASTRA_CLI_DIR "
171
+ echo " $( tput setaf 2) [OK]$( tput setaf 7) - File moved to $ASTRA_CLI_DIR "
192
172
193
- echo " "
173
+ rm -rf " ${astra_tmp_folder} "
174
+ echo " $( tput setaf 2) [OK]$( tput setaf 7) - Installation cleaned up"
194
175
176
+ echo $astra_init_snippet
195
177
196
- echo " Set version to $ASTRA_CLI_VERSION ..."
197
- echo " $ASTRA_CLI_VERSION " > " ${ASTRA_CLI_DIR} /var/version"
198
178
199
179
if [[ $darwin == true ]]; then
180
+ # Adding on MAC OS
200
181
touch " $astra_bash_profile "
201
- echo " Attempt update of login bash profile on OSX..."
202
182
if [[ -z $( grep ' astra-init.sh' " $astra_bash_profile " ) ]]; then
203
183
echo -e " \n$astra_init_snippet " >> " $astra_bash_profile "
204
- echo " Added astra init snippet to $astra_bash_profile "
184
+ echo " $( tput setaf 2 ) [OK] $( tput setaf 7 ) - astra added to ${ astra_bash_profile} "
205
185
fi
206
186
else
207
- echo " Attempt update of interactive bash profile on regular UNIX... "
187
+ # Attempt update of interactive bash profile on regular UNIX
208
188
touch " ${astra_bashrc} "
209
189
if [[ -z $( grep ' astra-init.sh' " $astra_bashrc " ) ]]; then
210
190
echo -e " \n$astra_init_snippet " >> " $astra_bashrc "
211
- echo " Added astra init snippet to $astra_bashrc "
191
+ echo " $( tput setaf 2 ) [OK] $( tput setaf 7 ) - astra added to ${ astra_bashrc} "
212
192
fi
213
193
fi
214
194
215
- echo " Attempt update of zsh profile..."
216
195
touch " $astra_zshrc "
217
196
if [[ -z $( grep ' astra-init.sh' " $astra_zshrc " ) ]]; then
218
197
echo -e " \n$astra_init_snippet " >> " $astra_zshrc "
198
+ echo " $( tput setaf 2) [OK]$( tput setaf 7) - astra added to ${astra_zshrc} "
219
199
echo " Updated existing ${astra_zshrc} "
220
200
fi
221
201
0 commit comments