Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error handling for last install step of install.sh script #515

Merged
merged 2 commits into from
Jun 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ install_cloudtruth() {
local target_name
local package_dir
local package
local status
# alpine, macos - no package format yet, use generic binary
if [ "${PKG}" = "apk" ] || [ "${PKG}" = "macos" ]; then
# normalize CPU arch
Expand Down Expand Up @@ -219,8 +220,10 @@ install_cloudtruth() {
tar xzf "${package}" || fail "Couldn't unpack release archive: ${package}"
if [ -n "${CT_DRY_RUN}" ]; then
echo "[dry-run] skipping install of ${package_dir}/cloudtruth"
status=0
else
install -m 755 -o root "${package_dir}/cloudtruth" /usr/local/bin
status=$?
fi
fi

Expand All @@ -233,8 +236,10 @@ install_cloudtruth() {
download_asset "${package}"|| fail "Couldn't download release package: ${package}"
if [ -n "${CT_DRY_RUN}" ]; then
echo "[dry-run] skipping install of ${package}"
status=0
else
dpkg -i "${package}"
status=$?
fi
fi

Expand All @@ -244,14 +249,18 @@ install_cloudtruth() {
download_asset "${package}"|| fail "Couldn't download release package: ${package}"
if [ -n "${CT_DRY_RUN}" ]; then
echo "[dry-run] skipping install of ${package}"
status=0
else
rpm -i "${package}"
status=$?
fi
fi

if [ -z "${CT_DRY_RUN}" ]; then
if [ "${status}" -ne 0 ]; then
fail "Couldn't install CloudTruth CLI"
elif [ -z "${CT_DRY_RUN}" ]; then
echo "[cloudtruth] installed: $(cloudtruth --version)"
fi

}

### Download CloudTruth CLI
Expand Down