Skip to content

Commit 2a9b7a4

Browse files
authored
Merge pull request #1806 from cdr/bsd
Add FreeBSD support to install script
2 parents 264abed + 3d9e3b8 commit 2a9b7a4

File tree

4 files changed

+29
-7
lines changed

4 files changed

+29
-7
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ For a full setup and walkthrough, please see [./doc/guide.md](./doc/guide.md).
2020

2121
### Quick Install
2222

23-
We have a [script](./install.sh) to install code-server for Linux and macOS.
23+
We have a [script](./install.sh) to install code-server for Linux, macOS and FreeBSD.
2424

2525
It tries to use the system package manager if possible.
2626

doc/guide.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ to avoid the slow dashboard.
8080

8181
## 2. Install code-server
8282

83-
We have a [script](../install.sh) to install `code-server` for Linux and macOS.
83+
We have a [script](../install.sh) to install `code-server` for Linux, macOS and FreeBSD.
8484

8585
It tries to use the system package manager if possible.
8686

doc/install.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ various distros and operating systems.
2020

2121
## install.sh
2222

23-
We have a [script](../install.sh) to install code-server for Linux and macOS.
23+
We have a [script](../install.sh) to install code-server for Linux, macOS and FreeBSD.
2424

2525
It tries to use the system package manager if possible.
2626

@@ -70,6 +70,8 @@ commands presented in the rest of this document.
7070
- If Homebrew is not installed it will install the latest standalone release into `~/.local`.
7171
- Add `~/.local/bin` to your `$PATH` to run code-server.
7272

73+
- For FreeBSD, it will install the [npm package](#yarn-npm) with `yarn` or `npm`.
74+
7375
- If ran on an architecture with no releases, it will install the [npm package](#yarn-npm) with `yarn` or `npm`.
7476
- We only have releases for amd64 and arm64 presently.
7577
- The [npm package](#yarn-npm) builds the native modules on postinstall.

install.sh

+24-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ usage() {
1414
fi
1515

1616
cath << EOF
17-
Installs code-server for Linux and macOS.
17+
Installs code-server for Linux, macOS and FreeBSD.
1818
It tries to use the system package manager if possible.
1919
After successful installation it explains how to start using code-server.
2020
${not_curl_usage-}
@@ -48,6 +48,8 @@ Usage:
4848
- If Homebrew is not installed it will install the latest standalone release
4949
into ~/.local
5050
51+
- For FreeBSD, it will install the npm package with yarn or npm.
52+
5153
- If ran on an architecture with no releases, it will install the
5254
npm package with yarn or npm.
5355
- We only have releases for amd64 and arm64 presently.
@@ -160,7 +162,7 @@ main() {
160162
ARCH="$(arch)"
161163
if [ ! "$ARCH" ]; then
162164
if [ "$METHOD" = standalone ]; then
163-
echoerr "No releases available for the architecture $(uname -m)."
165+
echoerr "No precompiled releases for $(uname -m)."
164166
echoerr 'Please rerun without the "--method standalone" flag to install from npm.'
165167
exit 1
166168
fi
@@ -169,6 +171,17 @@ main() {
169171
return
170172
fi
171173

174+
if [ "$OS" = "freebsd" ]; then
175+
if [ "$METHOD" = standalone ]; then
176+
echoerr "No precompiled releases available for $OS."
177+
echoerr 'Please rerun without the "--method standalone" flag to install from npm.'
178+
exit 1
179+
fi
180+
echoh "No precompiled releases available for $OS."
181+
install_npm
182+
return
183+
fi
184+
172185
CACHE_DIR="$(echo_cache_dir)"
173186

174187
if [ "$METHOD" = standalone ]; then
@@ -360,6 +373,9 @@ os() {
360373
Darwin)
361374
echo macos
362375
;;
376+
FreeBSD)
377+
echo freebsd
378+
;;
363379
esac
364380
}
365381

@@ -371,11 +387,12 @@ os() {
371387
# - centos, fedora, rhel, opensuse
372388
# - alpine
373389
# - arch
390+
# - freebsd
374391
#
375392
# Inspired by https://github.com/docker/docker-install/blob/26ff363bcf3b3f5a00498ac43694bf1c7d9ce16c/install.sh#L111-L120.
376393
distro() {
377-
if [ "$(uname)" = "Darwin" ]; then
378-
echo "macos"
394+
if [ "$OS" = "macos" ] || [ "$OS" = "freebsd" ]; then
395+
echo "$OS"
379396
return
380397
fi
381398

@@ -422,6 +439,9 @@ arch() {
422439
x86_64)
423440
echo amd64
424441
;;
442+
amd64) # FreeBSD.
443+
echo amd64
444+
;;
425445
esac
426446
}
427447

0 commit comments

Comments
 (0)