@@ -100,22 +100,35 @@ echo_standalone_postinstall() {
100
100
101
101
cath << EOF
102
102
103
- Standalone release has been installed into $STANDALONE_INSTALL_PREFIX /bin/$STANDALONE_BINARY_NAME
103
+ Coder has been installed to
104
+
105
+ $STANDALONE_INSTALL_PREFIX /bin/$STANDALONE_BINARY_NAME
104
106
105
107
EOF
106
108
107
- if [ " $STANDALONE_INSTALL_PREFIX " != /usr/local ]; then
109
+ CODER_COMMAND=" $( command -v " $STANDALONE_BINARY_NAME " || true) "
110
+
111
+ if [ -z " ${CODER_COMMAND} " ]; then
108
112
cath << EOF
109
113
Extend your path to use Coder:
110
- PATH="$STANDALONE_INSTALL_PREFIX /bin:\$ PATH"
114
+
115
+ $ PATH="$STANDALONE_INSTALL_PREFIX /bin:\$ PATH"
111
116
112
117
EOF
113
- fi
114
- cath << EOF
115
- Run Coder:
116
- $STANDALONE_BINARY_NAME server
118
+ elif [ " $CODER_COMMAND " != " $STANDALONE_BINARY_LOCATION " ]; then
119
+ echo_path_conflict " $CODER_COMMAND "
120
+ else
121
+ cath << EOF
122
+ To run a Coder server:
123
+
124
+ $ $STANDALONE_BINARY_NAME server
125
+
126
+ To connect to a Coder deployment:
127
+
128
+ $ $STANDALONE_BINARY_NAME login <deployment url>
117
129
118
130
EOF
131
+ fi
119
132
}
120
133
121
134
echo_brew_postinstall () {
@@ -124,9 +137,23 @@ echo_brew_postinstall() {
124
137
return
125
138
fi
126
139
140
+ BREW_PREFIX=" $( brew --prefix) "
141
+
127
142
cath << EOF
128
- brew formula has been installed.
129
143
144
+ Coder has been installed to
145
+
146
+ $BREW_PREFIX /bin/coder
147
+
148
+ EOF
149
+
150
+ CODER_COMMAND=" $( command -v " coder" || true) "
151
+
152
+ if [ " $CODER_COMMAND " != " $BREW_PREFIX /bin/coder" ]; then
153
+ echo_path_conflict " $CODER_COMMAND "
154
+ fi
155
+
156
+ cath << EOF
130
157
To run a Coder server:
131
158
132
159
$ coder server
@@ -157,7 +184,6 @@ To run a Coder server:
157
184
# Or just run the server directly
158
185
$ coder server
159
186
160
- Default URL: http://127.0.0.1:3000
161
187
Configuring Coder: https://coder.com/docs/v2/latest/admin/configure
162
188
163
189
To connect to a Coder deployment:
@@ -169,28 +195,45 @@ EOF
169
195
170
196
echo_dryrun_postinstall () {
171
197
cath << EOF
172
-
173
198
Dry-run complete.
174
199
175
200
To install Coder, re-run this script without the --dry-run flag.
201
+
202
+ EOF
203
+ }
204
+
205
+ echo_path_conflict () {
206
+ cath << EOF
207
+ There is another binary in your PATH that conflicts with the binary we've installed.
208
+
209
+ $1
210
+
211
+ This is likely because of an existing installation of Coder. See our documentation for suggestions on how to resolve this.
212
+
213
+ https://coder.com/docs/v2/latest/install/install.sh#path-conflicts
214
+
176
215
EOF
177
216
}
178
217
179
218
main () {
180
219
TERRAFORM_VERSION=" 1.3.4"
220
+
181
221
if [ " ${TRACE-} " ]; then
182
222
set -x
183
223
fi
224
+
184
225
unset \
185
226
DRY_RUN \
186
227
METHOD \
187
228
OPTIONAL \
188
229
ALL_FLAGS \
189
230
RSH_ARGS \
190
231
EDGE \
191
- RSH
232
+ RSH \
233
+ WITH_TERRAFORM
192
234
193
235
ALL_FLAGS=" "
236
+
194
237
while [ " $# " -gt 0 ]; do
195
238
case " $1 " in
196
239
-* )
@@ -245,7 +288,7 @@ main() {
245
288
exit 0
246
289
;;
247
290
--with-terraform)
248
- METHOD=with_terraform
291
+ WITH_TERRAFORM=1
249
292
;;
250
293
--)
251
294
shift
@@ -275,8 +318,29 @@ main() {
275
318
return
276
319
fi
277
320
321
+ # These can be overridden for testing but shouldn't normally be used as it can
322
+ # result in a broken coder.
323
+ OS=${OS:- $(os)}
324
+ ARCH=${ARCH:- $(arch)}
325
+ TERRAFORM_ARCH=${TERRAFORM_ARCH:- $(terraform_arch)}
326
+
327
+ # We can't reasonably support installing specific versions of Coder through
328
+ # Homebrew, so if we're on macOS and the `--version` flag was set, we should
329
+ # "detect" standalone to be the appropriate installation method. This check
330
+ # needs to occur before we set `VERSION` to a default of the latest release.
331
+ if [ " $OS " = " darwin" ] && [ " ${VERSION-} " ]; then
332
+ METHOD=standalone
333
+ fi
334
+
335
+ # If we've been provided a flag which is specific to the standalone installation
336
+ # method, we should "detect" standalone to be the appropriate installation method.
337
+ # This check needs to occur before we set these variables with defaults.
338
+ if [ " ${STANDALONE_INSTALL_PREFIX-} " ] || [ " ${STANDALONE_BINARY_NAME-} " ]; then
339
+ METHOD=standalone
340
+ fi
341
+
278
342
METHOD=" ${METHOD-detect} "
279
- if [ " $METHOD " != detect ] && [ " $METHOD " != with_terraform ] && [ " $METHOD " != standalone ]; then
343
+ if [ " $METHOD " != detect ] && [ " $METHOD " != standalone ]; then
280
344
echoerr " Unknown install method \" $METHOD \" "
281
345
echoerr " Run with --help to see usage."
282
346
exit 1
@@ -285,15 +349,10 @@ main() {
285
349
# These are used by the various install_* functions that make use of GitHub
286
350
# releases in order to download and unpack the right release.
287
351
CACHE_DIR=$( echo_cache_dir)
288
- STANDALONE_INSTALL_PREFIX=${STANDALONE_INSTALL_PREFIX:-/ usr/ local}
289
352
TERRAFORM_INSTALL_PREFIX=${TERRAFORM_INSTALL_PREFIX:-/ usr/ local}
353
+ STANDALONE_INSTALL_PREFIX=${STANDALONE_INSTALL_PREFIX:-/ usr/ local}
290
354
STANDALONE_BINARY_NAME=${STANDALONE_BINARY_NAME:- coder}
291
355
VERSION=${VERSION:- $(echo_latest_version)}
292
- # These can be overridden for testing but shouldn't normally be used as it can
293
- # result in a broken coder.
294
- OS=${OS:- $(os)}
295
- ARCH=${ARCH:- $(arch)}
296
- TERRAFORM_ARCH=${TERRAFORM_ARCH:- $(terraform_arch)}
297
356
298
357
distro_name
299
358
@@ -302,6 +361,11 @@ main() {
302
361
echoh
303
362
fi
304
363
364
+ # Start by installing Terraform, if requested
365
+ if [ " ${WITH_TERRAFORM-} " = 1 ]; then
366
+ with_terraform
367
+ fi
368
+
305
369
# Standalone installs by pulling pre-built releases from GitHub.
306
370
if [ " $METHOD " = standalone ]; then
307
371
if has_standalone; then
@@ -313,10 +377,6 @@ main() {
313
377
exit 1
314
378
fi
315
379
fi
316
- if [ " $METHOD " = with_terraform ]; then
317
- # Install terraform then continue the script
318
- with_terraform
319
- fi
320
380
321
381
# DISTRO can be overridden for testing but shouldn't normally be used as it
322
382
# can result in a broken coder.
@@ -429,7 +489,7 @@ with_terraform() {
429
489
install_macos () {
430
490
# If there is no `brew` binary available, just default to installing standalone
431
491
if command_exists brew; then
432
- echoh " Installing v $VERSION of the coder formula from coder/coder."
492
+ echoh " Installing coder with Homebrew from the coder/coder tap ."
433
493
echoh
434
494
435
495
sh_c brew install coder/coder/coder
@@ -505,16 +565,16 @@ install_standalone() {
505
565
" $sh_c " unzip -d " $CACHE_DIR " -o " $CACHE_DIR /coder_${VERSION} _${OS} _${ARCH} .zip"
506
566
fi
507
567
508
- COPY_LOCATION =" $STANDALONE_INSTALL_PREFIX /bin/$STANDALONE_BINARY_NAME "
568
+ STANDALONE_BINARY_LOCATION =" $STANDALONE_INSTALL_PREFIX /bin/$STANDALONE_BINARY_NAME "
509
569
510
570
# Remove the file if it already exists to
511
571
# avoid https://github.com/coder/coder/issues/2086
512
- if [ -f " $COPY_LOCATION " ]; then
513
- " $sh_c " rm " $COPY_LOCATION "
572
+ if [ -f " $STANDALONE_BINARY_LOCATION " ]; then
573
+ " $sh_c " rm " $STANDALONE_BINARY_LOCATION "
514
574
fi
515
575
516
576
# Copy the binary to the correct location.
517
- " $sh_c " cp " $CACHE_DIR /coder" " $COPY_LOCATION "
577
+ " $sh_c " cp " $CACHE_DIR /coder" " $STANDALONE_BINARY_LOCATION "
518
578
519
579
echo_standalone_postinstall
520
580
}
0 commit comments