Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cfd33f9

Browse files
author
Admin
committed
- Fixed typos
- Added recommend changes for consistency
1 parent d514c18 commit cfd33f9

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

install.sh

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Usage:
5555
Specifies the remote shell for remote installation. Defaults to ssh.
5656
5757
--with-terraform
58-
Installs Terraform binary from https://releases.hashicorp.com/terraform/1.3.4/ source
58+
Installs Terraform binary from https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/ source
5959
alongside coder.
6060
This is great for if you are having issues with Coder installing terraform, or if you
6161
just want it on your base system aswell.
@@ -157,7 +157,7 @@ main() {
157157
if [ "${TRACE-}" ]; then
158158
set -x
159159
fi
160-
160+
TERRAFORM_VERSION="1.3.4"
161161
unset \
162162
DRY_RUN \
163163
METHOD \
@@ -222,7 +222,7 @@ main() {
222222
exit 0
223223
;;
224224
--with-terraform)
225-
METHOD=install_terraform
225+
METHOD=with_terraform
226226
;;
227227
--)
228228
shift
@@ -253,7 +253,7 @@ main() {
253253
fi
254254

255255
METHOD="${METHOD-detect}"
256-
if [ "$METHOD" != detect ] && [ "$METHOD" != install_terraform ] && [ "$METHOD" != standalone ]; then
256+
if [ "$METHOD" != detect ] && [ "$METHOD" != with_terraform ] && [ "$METHOD" != standalone ]; then
257257
echoerr "Unknown install method \"$METHOD\""
258258
echoerr "Run with --help to see usage."
259259
exit 1
@@ -290,9 +290,9 @@ main() {
290290
exit 1
291291
fi
292292
fi
293-
if [ "$METHOD" = install_terraform ]; then
294-
# Install terraform then contine the script
295-
install_terraform
293+
if [ "$METHOD" = with_terraform ]; then
294+
# Install terraform then continue the script
295+
with_terraform
296296
fi
297297

298298
# DISTRO can be overridden for testing but shouldn't normally be used as it
@@ -369,20 +369,19 @@ fetch() {
369369
sh_c mv "$FILE.incomplete" "$FILE"
370370
}
371371

372-
install_terraform() {
372+
with_terraform() {
373373
# Check if the unzip package is installed. If not error peacefully.
374374
if !(command_exists unzip); then
375375
echoh
376376
echoerr "This script needs the unzip package to run."
377377
echoerr "Please install unzip to use this function"
378378
exit 1
379379
fi
380-
TERRAFORM_VERSION="1.3.4"
381-
echoh "Installing Terraform version $TERRAFORM_VERSION $TERRAFORM_ARCH package from Hashicorp Source."
380+
echoh "Installing Terraform version $TERRAFORM_VERSION $TERRAFORM_ARCH from the HashiCorp release repository."
382381
echoh
383382

384-
# Download from offical source and save it to cache
385-
fetch "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_1.3.4_${OS}_${TERRAFORM_ARCH}.zip" \
383+
# Download from official source and save it to cache
384+
fetch "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_${OS}_${TERRAFORM_ARCH}.zip" \
386385
"$CACHE_DIR/terraform_${TERRAFORM_VERSION}_${OS}_${TERRAFORM_ARCH}.zip"
387386

388387
sh_c mkdir -p "$TERRAFORM_INSTALL_PREFIX" 2>/dev/null || true
@@ -393,7 +392,7 @@ install_terraform() {
393392
fi
394393
# Prepare /usr/local/bin/ and the binary for copying
395394
"$sh_c" mkdir -p "$TERRAFORM_INSTALL_PREFIX/bin"
396-
"$sh_c" unzip -d "$CACHE_DIR" -o "$CACHE_DIR/terraform_1.3.4_${OS}_${ARCH}.zip"
395+
"$sh_c" unzip -d "$CACHE_DIR" -o "$CACHE_DIR/terraform_${TERRAFORM_VERSION}_${OS}_${ARCH}.zip"
397396
COPY_LOCATION="$TERRAFORM_INSTALL_PREFIX/bin/terraform"
398397

399398
# Remove the file if it already exists to
@@ -578,8 +577,8 @@ arch() {
578577
esac
579578
}
580579

581-
# The following is to change the naming, that way people with armv7 won't recieve a error
582-
# List of binaries can be found here: https://releases.hashicorp.com/terraform/1.3.4/
580+
# The following is to change the naming, that way people with armv7 won't receive a error
581+
# List of binaries can be found here: https://releases.hashicorp.com/terraform/
583582
terraform_arch() {
584583
uname_m=$(uname -m)
585584
case $uname_m in

0 commit comments

Comments
 (0)