Skip to content
This repository was archived by the owner on Mar 29, 2023. It is now read-only.

Commit 99b284d

Browse files
committed
Refactor couchbase installer to better deal with fallback url logic
1 parent 1dea000 commit 99b284d

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

modules/install-couchbase-server/install-couchbase-server

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,11 @@ function install_couchbase_on_ubuntu {
6565
local readonly version="$2"
6666
local readonly checksum="$3"
6767
local readonly checksum_type="$4"
68+
local readonly ubuntu_version="$(lsb_release -r -s)"
69+
local readonly dpkg_name="couchbase-server.deb"
6870

69-
log_info "Installing Couchbase $version ($edition edition) on Ubuntu"
71+
log_info "Installing Couchbase $version ($edition edition) on Ubuntu $ubuntu_version"
7072

71-
local readonly ubuntu_version="$(lsb_release -r -s)"
7273
local readonly filepath="couchbase-server-${edition}_${version}-ubuntu${ubuntu_version}_amd64.deb"
7374
local readonly url="https://packages.couchbase.com/releases/$version/$filepath"
7475

@@ -83,23 +84,21 @@ function install_couchbase_on_ubuntu {
8384
sudo apt-get install -y python-httplib2
8485

8586
log_info "Downloading Couchbase from $url to $filepath"
86-
if curl --location --silent --fail --show-error -O "$url"; then
87-
os_validate_checksum "$filepath" "$checksum" "$checksum_type"
88-
else
87+
if ! curl --location --silent --fail --show-error -o "$dpkg_name" "$url"; then
8988
log_warn "Failed to get Couchbase from $url. Trying $fallback_url."
90-
curl --location --silent --fail --show-error -O "$fallback_url"
91-
os_validate_checksum "$fallback_filepath" "$checksum" "$checksum_type"
89+
curl --location --silent --fail --show-error -o "$dpkg_name" "$fallback_url"
9290
fi
9391

92+
os_validate_checksum "$dpkg_name" "$checksum" "$checksum_type"
9493

9594
# Install Couchbase, but configure it to NOT start on boot. This allows the run-couchbase-server script to configure
9695
# Couchbase, including what ports to use, and THEN boot it up.
97-
log_info "Installing Couchbase from $filepath"
98-
sudo INSTALL_DONT_START_SERVER=1 dpkg -i "$filepath"
96+
log_info "Installing Couchbase from $dpkg_name"
97+
sudo INSTALL_DONT_START_SERVER=1 dpkg -i "$dpkg_name"
9998
sudo systemctl disable couchbase-server
10099

101-
log_info "Cleaning up $filepath"
102-
rm -f "$filepath"
100+
log_info "Cleaning up $dpkg_name"
101+
rm -f "$dpkg_name"
103102
}
104103

105104
function install_couchbase_on_amazon_linux {

0 commit comments

Comments
 (0)