Skip to content

Commit 3568085

Browse files
committed
fix for MacOS
1 parent 26ab867 commit 3568085

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

install.sh

+23-17
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ echo_latest_version() {
8181

8282
echo_standalone_postinstall() {
8383
echoh
84-
cath << EOF
85-
Standalone release has been installed into $STANDALONE_INSTALL_PREFIX/lib/coder-$VERSION
84+
cath <<EOF
85+
Standalone release has been installed into $STANDALONE_INSTALL_PREFIX/bin/coder
8686
8787
Extend your path to use Coder:
8888
PATH="$STANDALONE_INSTALL_PREFIX/bin:\$PATH"
@@ -98,7 +98,7 @@ EOF
9898

9999
echo_systemd_postinstall() {
100100
echoh
101-
cath << EOF
101+
cath <<EOF
102102
$1 package has been installed.
103103
104104
To run Coder as a system service:
@@ -347,8 +347,15 @@ install_standalone() {
347347
echoh "Installing v$VERSION of the $ARCH release from GitHub."
348348
echoh
349349

350-
fetch "https://github.com/coder/coder/releases/download/v$VERSION/coder_${VERSION}_${OS}_${ARCH}.tar.gz" \
351-
"$CACHE_DIR/coder_${VERSION}_${OS}_${ARCH}.tar"
350+
# MacOS and Windows releases are packaged as .zip
351+
case $OS in
352+
darwin) STANDALONE_ARCHIVE_FORMAT=zip ;;
353+
windows) STANDALONE_ARCHIVE_FORMAT=zip ;;
354+
*) STANDALONE_ARCHIVE_FORMAT=tar.gz ;;
355+
esac
356+
357+
fetch "https://github.com/coder/coder/releases/download/v$VERSION/coder_${VERSION}_${OS}_${ARCH}.$STANDALONE_ARCHIVE_FORMAT" \
358+
"$CACHE_DIR/coder_${VERSION}_${OS}_${ARCH}.$STANDALONE_ARCHIVE_FORMAT"
352359

353360
# -w only works if the directory exists so try creating it first. If this
354361
# fails we can ignore the error as the -w check will then swap us to sudo.
@@ -359,27 +366,26 @@ install_standalone() {
359366
sh_c="sudo_sh_c"
360367
fi
361368

362-
if [ -e "$STANDALONE_INSTALL_PREFIX/lib/coder_$VERSION" ]; then
363-
echoh
364-
echoh "coder_$VERSION is already installed at $STANDALONE_INSTALL_PREFIX/lib/coder_$VERSION"
365-
echoh "Remove it to reinstall."
366-
exit 0
369+
"$sh_c" mkdir -p "$STANDALONE_INSTALL_PREFIX/bin"
370+
if [ "$STANDALONE_ARCHIVE_FORMAT" == tar.gz ]; then
371+
"$sh_c" tar -C "$CACHE_DIR" -xzf "$CACHE_DIR/coder_${VERSION}_${OS}_${ARCH}.tar.gz"
372+
else
373+
"$sh_c" unzip -d "$CACHE_DIR" -o "$CACHE_DIR/coder_${VERSION}_${OS}_${ARCH}.zip"
367374
fi
368375

369-
"$sh_c" mkdir -p "$STANDALONE_INSTALL_PREFIX/lib" "$STANDALONE_INSTALL_PREFIX/bin"
370-
"$sh_c" tar -C "$STANDALONE_INSTALL_PREFIX/lib" -xzf "$CACHE_DIR/coder_${VERSION}_${OS}_${ARCH}.tar"
371-
"$sh_c" ln -fs "$STANDALONE_INSTALL_PREFIX/lib/coder/bin/coder" "$STANDALONE_INSTALL_PREFIX/bin/coder"
376+
"$sh_c" cp "$CACHE_DIR/coder" "$STANDALONE_INSTALL_PREFIX/bin/coder"
372377

373378
echo_standalone_postinstall
374379
}
375380

376381
# Determine if we have standalone releases on GitHub for the system's arch.
382+
# TODO: fix for Coder v2
377383
has_standalone() {
378384
case $ARCH in
379385
amd64) return 0 ;;
380386
# We only have amd64 for macOS.
381387
arm64)
382-
[ "$(distro)" != macos ]
388+
[ "$(distro)" != darwin ]
383389
return
384390
;;
385391
*) return 1 ;;
@@ -390,7 +396,7 @@ os() {
390396
uname="$(uname)"
391397
case $uname in
392398
Linux) echo linux ;;
393-
Darwin) echo macos ;;
399+
Darwin) echo darwin ;;
394400
FreeBSD) echo freebsd ;;
395401
*) echo "$uname" ;;
396402
esac
@@ -399,7 +405,7 @@ os() {
399405
# Print the detected Linux distro, otherwise print the OS name.
400406
#
401407
# Example outputs:
402-
# - macos -> macos
408+
# - darwin -> darwin
403409
# - freebsd -> freebsd
404410
# - ubuntu, raspbian, debian ... -> debian
405411
# - amzn, centos, rhel, fedora, ... -> fedora
@@ -409,7 +415,7 @@ os() {
409415
#
410416
# Inspired by https://github.com/docker/docker-install/blob/26ff363bcf3b3f5a00498ac43694bf1c7d9ce16c/install.sh#L111-L120.
411417
distro() {
412-
if [ "$OS" = "macos" ] || [ "$OS" = "freebsd" ]; then
418+
if [ "$OS" = "darwin" ] || [ "$OS" = "freebsd" ]; then
413419
echo "$OS"
414420
return
415421
fi

0 commit comments

Comments
 (0)