-
-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script to download and install Backblaze CLI tool (#1748)
Related tiny-pilot/tinypilot-pro#1231 Related tiny-pilot/tinypilot-pro#1229 While working on tiny-pilot/tinypilot-pro#1246, we needed to install the Backblaze CLI tool yet again. This PR moves the download and installation of `b2` to a dedicated script. Notes: 1. We've also updated the CircleCI image to the latest version because [it comes pre-installed with the `wget` command](https://codeapprove.com/pr/tiny-pilot/tinypilot-pro/1246#thread-b6949a01-6558-4619-a0ff-47ddb4dc9597). <a data-ca-tag href="https://codeapprove.com/pr/tiny-pilot/tinypilot/1748"><img src="https://codeapprove.com/external/github-tag-allbg.png" alt="Review on CodeApprove" /></a>
- Loading branch information
1 parent
7b36179
commit 8266bdd
Showing
2 changed files
with
44 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
# | ||
# Setup and configure the Backblaze CLI tool for a Linux based system. | ||
# | ||
# This includes the download, installation, and account authorization. | ||
|
||
# Exit script on first failure. | ||
set -e | ||
|
||
# Determine if there are any account credentials available. | ||
if [[ -n "${BACKBLAZE_KEY_ID}" ]] && [[ -n "${BACKBLAZE_KEY}" ]]; then | ||
readonly HAS_CREDENTIALS='true' | ||
else | ||
readonly HAS_CREDENTIALS='false' | ||
fi | ||
|
||
# Exit on unset variable. | ||
set -u | ||
|
||
# Download and install the Backblaze CLI tool, if it doesn't already exist. | ||
if [[ ! -f ./b2 ]]; then | ||
readonly VERSION='3.4.0' | ||
wget \ | ||
"https://github.com/Backblaze/B2_Command_Line_Tool/releases/download/v${VERSION}/b2-linux" \ | ||
--output-document ./b2 \ | ||
--no-verbose | ||
chmod +x ./b2 | ||
fi | ||
|
||
# Print current version. | ||
./b2 version | ||
|
||
# Authorize the Backblaze account, if account credentials are available. | ||
if "${HAS_CREDENTIALS}"; then | ||
./b2 authorize-account "${BACKBLAZE_KEY_ID}" "${BACKBLAZE_KEY}" | ||
else | ||
echo 'No Backblaze account credentials were found.' | ||
echo 'Manually authorize your account using the following command:' | ||
echo ' ./b2 authorize-account' | ||
fi |