From 3d9e3b87172bdde2650cffbb12688d2f2d9e9d74 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sat, 13 Jun 2020 10:56:50 -0400 Subject: [PATCH] Add FreeBSD support to install script --- README.md | 2 +- doc/guide.md | 2 +- doc/install.md | 4 +++- install.sh | 28 ++++++++++++++++++++++++---- 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 65045330..5f0d38e2 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ For a full setup and walkthrough, please see [./doc/guide.md](./doc/guide.md). ### Quick Install -We have a [script](./install.sh) to install code-server for Linux and macOS. +We have a [script](./install.sh) to install code-server for Linux, macOS and FreeBSD. It tries to use the system package manager if possible. diff --git a/doc/guide.md b/doc/guide.md index 8ca2b757..0b7b3423 100644 --- a/doc/guide.md +++ b/doc/guide.md @@ -80,7 +80,7 @@ to avoid the slow dashboard. ## 2. Install code-server -We have a [script](../install.sh) to install `code-server` for Linux and macOS. +We have a [script](../install.sh) to install `code-server` for Linux, macOS and FreeBSD. It tries to use the system package manager if possible. diff --git a/doc/install.md b/doc/install.md index 055973f1..b8ec54a8 100644 --- a/doc/install.md +++ b/doc/install.md @@ -20,7 +20,7 @@ various distros and operating systems. ## install.sh -We have a [script](../install.sh) to install code-server for Linux and macOS. +We have a [script](../install.sh) to install code-server for Linux, macOS and FreeBSD. It tries to use the system package manager if possible. @@ -70,6 +70,8 @@ commands presented in the rest of this document. - If Homebrew is not installed it will install the latest standalone release into `~/.local`. - Add `~/.local/bin` to your `$PATH` to run code-server. +- For FreeBSD, it will install the [npm package](#yarn-npm) with `yarn` or `npm`. + - If ran on an architecture with no releases, it will install the [npm package](#yarn-npm) with `yarn` or `npm`. - We only have releases for amd64 and arm64 presently. - The [npm package](#yarn-npm) builds the native modules on postinstall. diff --git a/install.sh b/install.sh index 64bac209..1038adc7 100755 --- a/install.sh +++ b/install.sh @@ -14,7 +14,7 @@ usage() { fi cath << EOF -Installs code-server for Linux and macOS. +Installs code-server for Linux, macOS and FreeBSD. It tries to use the system package manager if possible. After successful installation it explains how to start using code-server. ${not_curl_usage-} @@ -48,6 +48,8 @@ Usage: - If Homebrew is not installed it will install the latest standalone release into ~/.local +- For FreeBSD, it will install the npm package with yarn or npm. + - If ran on an architecture with no releases, it will install the npm package with yarn or npm. - We only have releases for amd64 and arm64 presently. @@ -160,7 +162,7 @@ main() { ARCH="$(arch)" if [ ! "$ARCH" ]; then if [ "$METHOD" = standalone ]; then - echoerr "No releases available for the architecture $(uname -m)." + echoerr "No precompiled releases for $(uname -m)." echoerr 'Please rerun without the "--method standalone" flag to install from npm.' exit 1 fi @@ -169,6 +171,17 @@ main() { return fi + if [ "$OS" = "freebsd" ]; then + if [ "$METHOD" = standalone ]; then + echoerr "No precompiled releases available for $OS." + echoerr 'Please rerun without the "--method standalone" flag to install from npm.' + exit 1 + fi + echoh "No precompiled releases available for $OS." + install_npm + return + fi + CACHE_DIR="$(echo_cache_dir)" if [ "$METHOD" = standalone ]; then @@ -360,6 +373,9 @@ os() { Darwin) echo macos ;; + FreeBSD) + echo freebsd + ;; esac } @@ -371,11 +387,12 @@ os() { # - centos, fedora, rhel, opensuse # - alpine # - arch +# - freebsd # # Inspired by https://github.com/docker/docker-install/blob/26ff363bcf3b3f5a00498ac43694bf1c7d9ce16c/install.sh#L111-L120. distro() { - if [ "$(uname)" = "Darwin" ]; then - echo "macos" + if [ "$OS" = "macos" ] || [ "$OS" = "freebsd" ]; then + echo "$OS" return fi @@ -422,6 +439,9 @@ arch() { x86_64) echo amd64 ;; + amd64) # FreeBSD. + echo amd64 + ;; esac }