1
1
#! /usr/bin/env sh
2
2
# This is consul-download.sh at https://github.com/wilsonmar/mac-setup/blob/main/scripts/consul-download.sh
3
3
# This automates manual instructions at https://learn.hashicorp.com/tutorials/consul/deployment-guide?in=consul/production-deploy
4
+
5
+ # Copy and paste this:
6
+ # sh -c "$(curl -fsSL https://raw.githubusercontent.com/wilsonmar/mac-setup/master/consul-download.sh)"
7
+
4
8
# This downloads and installs "safely" - verifying that what is downloaded has NOT been altered.
5
9
# 1. The fingerprint used here matches what the author saved in Keybase.
6
10
# 2. The author's hash of the downloaded file matches the hash created by the author.
9
13
# Techniques for shell scripting used here are explained at https://wilsonmar.github.io/shell-scripts
10
14
# Explainer: https://serverfault.com/questions/896228/how-to-verify-a-file-using-an-asc-signature-file
11
15
12
- # This is gas "v1.10 unzip just consul file "
16
+ # This is git commit "v1.11 add -vers parm "
13
17
# Kermit TODO: The expires: date above must be in the future ..."
14
18
# Kermit? TODO: Change file name with time stamp instead of removing.
15
- # TODO: Add install of more utilities # To be hashi-agents-install .sh
19
+ # TODO: Add install of more utilities # To be consul-download .sh
16
20
# TODO: Add install of more HashiCorp programs: terraform, vault, consul-k8s, etc.
17
21
# TODO: Add processing on other OS/Platforms.
18
22
@@ -37,15 +41,17 @@ args_prompt() {
37
41
echo " -q -quiet headings for each step"
38
42
echo " -ni -no install of utilities brew, gpg2, jq, etc. (default is install)"
39
43
echo " "
44
+ echo " -vers list versions and stop"
40
45
echo " -oss Install Open Source Sofware edition instead of default Enterprise edition"
41
46
echo " -consul \" 1.13.1\" Version of Consul"
42
47
echo " -installdir \" /usr/local/bin\" target folder"
43
48
echo " "
44
49
echo " # USAGE EXAMPLES:"
45
- echo " chmod +x hashi-agents-install.sh # (one time) change permissions"
46
- echo " ./hashi-agents-install.sh # assumes -ent and lates version available"
47
- echo " ./hashi-agents-install.sh -v -oss"
48
- echo " ./hashi-agents-install.sh -v -consul 1.13.1 # specific version"
50
+ echo " chmod +x consul-download.sh # (one time) change permissions"
51
+ echo " ./consul-download.sh -vers # just list versions and stop"
52
+ echo " ./consul-download.sh # assumes -ent and lates version available"
53
+ echo " ./consul-download.sh -v -oss"
54
+ echo " ./consul-download.sh -v -consul 1.13.1 # specific version"
49
55
} # args_prompt()
50
56
# if [ $# -eq 0 ]; then # display if no parameters are provided:
51
57
# args_prompt
@@ -56,6 +62,7 @@ args_prompt() {
56
62
# Normal:
57
63
CONTINUE_ON_ERR=false # -cont
58
64
RUN_VERBOSE=false # -v
65
+ LIST_VERSIONS=false # -vers
59
66
RUN_DEBUG=false # -vv
60
67
SET_TRACE=false # -x
61
68
RUN_QUIET=false # -q
@@ -141,6 +148,10 @@ while test $# -gt 0; do
141
148
export RUN_DEBUG=true
142
149
shift
143
150
;;
151
+ -vers)
152
+ export LIST_VERSIONS=true
153
+ shift
154
+ ;;
144
155
-v)
145
156
export RUN_VERBOSE=true
146
157
shift
214
225
215
226
# ## 07. Verify parameters vs. exports defined on Terminal before invoking this:
216
227
228
+ if [ " ${LIST_VERSIONS} " = true ]; then
229
+ # Just the version codes:
230
+ CONSUL_VER_LIST=" https://releases.hashicorp.com/consul"
231
+ open " ${CONSUL_VER_LIST} "
232
+
233
+ if [ " ${RUN_VERBOSE} " = true ]; then # -v
234
+ # show website with description of each release:
235
+ CONSUL_VER_LIST=" https://github.com/hashicorp/consul/releases"
236
+ open " ${CONSUL_VER_LIST} "
237
+ fi
238
+ exit
239
+ fi
240
+
217
241
# Instead of obtaining manually: https://docs.github.com/en/repositories/releasing-projects-on-github/linking-to-releases
218
242
CONSUL_LATEST_VERSION=$( curl -sL " https://api.github.com/repos/hashicorp/consul/releases/latest" | jq -r " .tag_name" | cut -c2- )
219
243
@@ -364,7 +388,7 @@ if ! command -v gpg ; then
364
388
# Install gpg if needed: see https://wilsonmar.github.io/git-signing
365
389
echo " *** brew install gnupg2 (gpg)..."
366
390
brew install gnupg2
367
- chmod 700 ~ /.gnupg
391
+ # TODO: chmod 700 ~/.gnupg
368
392
fi
369
393
h2 " gpg import hashicorp.asc ..."
370
394
# No Using gpg --list-keys @34365D9472D7468F to check if asc file is already been imported into keychain (a one-time process)
0 commit comments