45
45
Sets the prefix used by standalone release archives. Defaults to /usr/local
46
46
and the binary is copied into /usr/local/bin
47
47
To install in \$ HOME, pass ---prefix=\$ HOME/.local
48
-
48
+
49
49
--binary-name <name>
50
50
Sets the name for the CLI in standalone release archives. Defaults to "coder"
51
51
To use the CLI as coder2, pass --binary-name=coder2
@@ -54,6 +54,15 @@ Usage:
54
54
--rsh <bin>
55
55
Specifies the remote shell for remote installation. Defaults to ssh.
56
56
57
+ --install-terraform
58
+ Installs Terraform binary from https://releases.hashicorp.com/terraform/1.3.4/ source
59
+ alongside coder.
60
+ This is great for if you are having issues with Coder installing terraform, or if you
61
+ just want it on your base system aswell.
62
+ This supports most systems, however if you are unsure yours is supported you can check
63
+ the link above.
64
+
65
+
57
66
The detection method works as follows:
58
67
- Debian, Ubuntu, Raspbian: install the deb package from GitHub.
59
68
- Fedora, CentOS, RHEL, openSUSE: install the rpm package from GitHub.
@@ -212,6 +221,9 @@ main() {
212
221
usage
213
222
exit 0
214
223
;;
224
+ --install-terraform)
225
+ METHOD=install_terraform
226
+ ;;
215
227
--)
216
228
shift
217
229
# We remove the -- added above.
@@ -241,7 +253,7 @@ main() {
241
253
fi
242
254
243
255
METHOD=" ${METHOD-detect} "
244
- if [ " $METHOD " != detect ] && [ " $METHOD " != standalone ]; then
256
+ if [ " $METHOD " != detect ] && [ " $METHOD " != install_terraform ] && [ " $METHOD " != standalone ]; then
245
257
echoerr " Unknown install method \" $METHOD \" "
246
258
echoerr " Run with --help to see usage."
247
259
exit 1
@@ -251,12 +263,14 @@ main() {
251
263
# releases in order to download and unpack the right release.
252
264
CACHE_DIR=$( echo_cache_dir)
253
265
STANDALONE_INSTALL_PREFIX=${STANDALONE_INSTALL_PREFIX:-/ usr/ local}
266
+ TERRAFORM_INSTALL_PREFIX=${TERRAFORM_INSTALL_PREFIX:-/ usr/ local}
254
267
STANDALONE_BINARY_NAME=${STANDALONE_BINARY_NAME:- coder}
255
268
VERSION=${VERSION:- $(echo_latest_version)}
256
269
# These can be overridden for testing but shouldn't normally be used as it can
257
270
# result in a broken coder.
258
271
OS=${OS:- $(os)}
259
272
ARCH=${ARCH:- $(arch)}
273
+ TERRA_ARCH=${TERRA_ARCH:- $(terra_arch)}
260
274
261
275
distro_name
262
276
@@ -276,6 +290,10 @@ main() {
276
290
exit 1
277
291
fi
278
292
fi
293
+ if [ " $METHOD " = install_terraform ]; then
294
+ # Install terraform then contine the script
295
+ install_terraform
296
+ fi
279
297
280
298
# DISTRO can be overridden for testing but shouldn't normally be used as it
281
299
# can result in a broken coder.
@@ -351,6 +369,43 @@ fetch() {
351
369
sh_c mv " $FILE .incomplete" " $FILE "
352
370
}
353
371
372
+ install_terraform () {
373
+ # Check if the unzip package is installed. If not error peacefully.
374
+ if ! (command_exists unzip); then
375
+ echoh
376
+ echoerr " This script needs the unzip package to run."
377
+ echoerr " Please install unzip to use this function"
378
+ exit 1
379
+ fi
380
+
381
+ echoh " Installing Terraform version 1.3.4 $TERRA_ARCH package from Hashicorp Source."
382
+ echoh
383
+
384
+ # Download from offical source and save it to cache
385
+ fetch " https://releases.hashicorp.com/terraform/1.3.4/terraform_1.3.4_${OS} _${TERRA_ARCH} .zip" \
386
+ " $CACHE_DIR /terraform_1.3.4_${OS} _${TERRA_ARCH} .zip"
387
+
388
+ sh_c mkdir -p " $TERRAFORM_INSTALL_PREFIX " 2> /dev/null || true
389
+
390
+ sh_c=" sh_c"
391
+ if [ ! -w " $TERRAFORM_INSTALL_PREFIX " ]; then
392
+ sh_c=" sudo_sh_c"
393
+ fi
394
+ # Prepare /usr/local/bin/ and the binary for copying
395
+ " $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"
397
+ COPY_LOCATION=" $TERRAFORM_INSTALL_PREFIX /bin/terraform"
398
+
399
+ # Remove the file if it already exists to
400
+ # avoid https://github.com/coder/coder/issues/2086
401
+ if [ -f " $COPY_LOCATION " ]; then
402
+ " $sh_c " rm " $COPY_LOCATION "
403
+ fi
404
+
405
+ # Copy the binary to the correct location.
406
+ " $sh_c " cp " $CACHE_DIR /terraform" " $COPY_LOCATION "
407
+ }
408
+
354
409
install_deb () {
355
410
echoh " Installing v$VERSION of the $ARCH deb package from GitHub."
356
411
echoh
@@ -385,6 +440,13 @@ install_apk() {
385
440
}
386
441
387
442
install_standalone () {
443
+ # Check if the unzip package is installed. If not error peacefully.
444
+ if ! (command_exists unzip); then
445
+ echoh
446
+ echoerr " This script needs the unzip package to run."
447
+ echoerr " Please install unzip to use this function"
448
+ exit 1
449
+ fi
388
450
echoh " Installing v$VERSION of the $ARCH release from GitHub."
389
451
echoh
390
452
@@ -431,7 +493,7 @@ install_standalone() {
431
493
has_standalone () {
432
494
case $ARCH in
433
495
amd64) return 0 ;;
434
- ard64 ) return 0 ;;
496
+ arm64 ) return 0 ;;
435
497
armv7)
436
498
[ " $( distro) " != darwin ]
437
499
return
@@ -516,6 +578,18 @@ arch() {
516
578
esac
517
579
}
518
580
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/
583
+ terra_arch () {
584
+ uname_m=$( uname -m)
585
+ case $uname_m in
586
+ aarch64) echo arm64 ;;
587
+ x86_64) echo amd64 ;;
588
+ armv7l) echo arm ;;
589
+ * ) echo " $uname_m " ;;
590
+ esac
591
+ }
592
+
519
593
command_exists () {
520
594
if [ ! " $1 " ]; then return 1; fi
521
595
command -v " $@ " > /dev/null
0 commit comments