mirror of https://git.tuxpa.in/a/code-server.git
Fixes from @code-asher's godly review
This commit is contained in:
parent
33bca2d141
commit
665ca017a1
|
@ -9,7 +9,7 @@ main() {
|
||||||
tsc --noEmit
|
tsc --noEmit
|
||||||
# See comment in ./ci/container/Dockerfile
|
# See comment in ./ci/container/Dockerfile
|
||||||
if [[ ! ${CI-} ]]; then
|
if [[ ! ${CI-} ]]; then
|
||||||
shellcheck -e SC2046,SC2164,SC2154,SC1091 $(git ls-files "*.sh")
|
shellcheck -e SC2046,SC2164,SC2154,SC1091,SC1090 $(git ls-files "*.sh")
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
16
doc/FAQ.md
16
doc/FAQ.md
|
@ -152,15 +152,13 @@ user a virtual machine instead of just a container.
|
||||||
|
|
||||||
## Docker in code-server container?
|
## Docker in code-server container?
|
||||||
|
|
||||||
If you'd like to access docker inside of code-server, we'd recommend running a `docker:dind` container
|
If you'd like to access docker inside of code-server, mount the docker socket in from `/var/run/docker.sock`.
|
||||||
and mounting in a directory to share between `dind` and the `code-server` container at `/var/run`.
|
Install the docker CLI in the code-server container and you should be able to access the daemon!
|
||||||
After, install the docker CLI in the code-server container and you should be able to access the
|
|
||||||
daemon as the socket will be shared at `/var/run/docker.sock`.
|
|
||||||
|
|
||||||
In order to make volume mounts work, mount the home directory in the code-server container and the
|
You can even make volume mounts work. Lets say you want to run a container and mount in
|
||||||
dind container at the same path. i.e you'd volume mount a directory from the host to `/home/coder`
|
`/home/coder/myproject` into it from inside the `code-server` container. You need to make sure
|
||||||
on both. This will allow any volume mounts in the home directory to work. Similar process
|
the docker daemon's `/home/coder/myproject` is the same as the one mounted inside the `code-server`
|
||||||
to make volume mounts in any other directory work.
|
container and the mount will just work.
|
||||||
|
|
||||||
## Collaboration
|
## Collaboration
|
||||||
|
|
||||||
|
@ -269,7 +267,7 @@ it is against their TOS to use the published extensions so we are unable to
|
||||||
add them to our marketplace.
|
add them to our marketplace.
|
||||||
|
|
||||||
We may reimplement them at some point.
|
We may reimplement them at some point.
|
||||||
You can follow [#1315](https://github.com/cdr/code-server/issues/1315) for updates.
|
You can subscribe to [#1315](https://github.com/cdr/code-server/issues/1315) for updates.
|
||||||
|
|
||||||
## Enterprise
|
## Enterprise
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ to avoid the slow dashboard.
|
||||||
|
|
||||||
## 2. Install code-server
|
## 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 and macOS.
|
||||||
|
|
||||||
It tries to use the system package manager if possible.
|
It tries to use the system package manager if possible.
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ curl -fsSL https://code-server.dev/install.sh | sh
|
||||||
|
|
||||||
The install script will print out how to run and start using `code-server`.
|
The install script will print out how to run and start using `code-server`.
|
||||||
|
|
||||||
Docs on the install script, manual installation and docker image are at [./doc/install.md](./doc/install.md).
|
Docs on the install script, manual installation and docker image are at [./install.md](./install.md).
|
||||||
|
|
||||||
## 3. Expose code-server
|
## 3. Expose code-server
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ the dependency on caddy.
|
||||||
### Self Signed Certificate
|
### Self Signed Certificate
|
||||||
|
|
||||||
**note:** Self signed certificates do not work with iPad and will cause a blank page. You'll
|
**note:** Self signed certificates do not work with iPad and will cause a blank page. You'll
|
||||||
have to use [Let's Encrypt](#lets-encrypt) instead. See the [FAQ](https://github.com/cdr/code-server/blob/master/doc/FAQ.md#blank-screen-on-ipad).
|
have to use [Let's Encrypt](#lets-encrypt) instead. See the [FAQ](./FAQ.md#blank-screen-on-ipad).
|
||||||
|
|
||||||
Recommended reading: https://security.stackexchange.com/a/8112.
|
Recommended reading: https://security.stackexchange.com/a/8112.
|
||||||
|
|
||||||
|
@ -255,4 +255,4 @@ systemctl --user restart code-server
|
||||||
|
|
||||||
If you're working on a web service and want to access it locally, `code-server` can proxy it for you.
|
If you're working on a web service and want to access it locally, `code-server` can proxy it for you.
|
||||||
|
|
||||||
See the [FAQ](https://github.com/cdr/code-server/blob/master/doc/FAQ.md#how-do-i-securely-access-web-services).
|
See the [FAQ](./FAQ.md#how-do-i-securely-access-web-services).
|
||||||
|
|
|
@ -20,7 +20,7 @@ various distros and operating systems.
|
||||||
|
|
||||||
## install.sh
|
## 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 and macOS.
|
||||||
|
|
||||||
It tries to use the system package manager if possible.
|
It tries to use the system package manager if possible.
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ If you believe an install script used with `curl | sh` is insecure, please give
|
||||||
[sandstorm.io](https://sandstorm.io) a read.
|
[sandstorm.io](https://sandstorm.io) a read.
|
||||||
|
|
||||||
If you'd still prefer manual installation despite the below [detect reference](#detect-reference) and `--dry-run`
|
If you'd still prefer manual installation despite the below [detect reference](#detect-reference) and `--dry-run`
|
||||||
then continue on for docs on manual installation. The [`install.sh`](./install.sh) script runs the _exact_ same
|
then continue on for docs on manual installation. The [`install.sh`](../install.sh) script runs the _exact_ same
|
||||||
commands presented in the rest of this document.
|
commands presented in the rest of this document.
|
||||||
|
|
||||||
### Flags
|
### Flags
|
||||||
|
@ -117,7 +117,7 @@ We recommend installing with `yarn` or `npm` when:
|
||||||
2. If you're on Linux with glibc < v2.17
|
2. If you're on Linux with glibc < v2.17
|
||||||
|
|
||||||
**note:** Installing via `yarn` or `npm` builds native modules on install and so requires C dependencies.
|
**note:** Installing via `yarn` or `npm` builds native modules on install and so requires C dependencies.
|
||||||
See [./doc/npm.md](./doc/npm.md) for installing these dependencies.
|
See [./npm.md](./npm.md) for installing these dependencies.
|
||||||
|
|
||||||
You will need at least node v12 installed. See [#1633](https://github.com/cdr/code-server/issues/1633).
|
You will need at least node v12 installed. See [#1633](https://github.com/cdr/code-server/issues/1633).
|
||||||
|
|
||||||
|
|
65
install.sh
65
install.sh
|
@ -95,7 +95,6 @@ main() {
|
||||||
DRY_RUN \
|
DRY_RUN \
|
||||||
METHOD \
|
METHOD \
|
||||||
ARCHIVE_INSTALL_PREFIX \
|
ARCHIVE_INSTALL_PREFIX \
|
||||||
SKIP_ECHO \
|
|
||||||
VERSION \
|
VERSION \
|
||||||
OPTIONAL
|
OPTIONAL
|
||||||
|
|
||||||
|
@ -199,7 +198,9 @@ main() {
|
||||||
parse_arg() {
|
parse_arg() {
|
||||||
case "$1" in
|
case "$1" in
|
||||||
*=*)
|
*=*)
|
||||||
opt="${1#=*}"
|
# Remove everything after first equal sign.
|
||||||
|
opt="${1%%=*}"
|
||||||
|
# Remove everything before first equal sign.
|
||||||
optarg="${1#*=}"
|
optarg="${1#*=}"
|
||||||
if [ ! "$optarg" ] && [ ! "${OPTIONAL-}" ]; then
|
if [ ! "$optarg" ] && [ ! "${OPTIONAL-}" ]; then
|
||||||
echoerr "$opt requires an argument"
|
echoerr "$opt requires an argument"
|
||||||
|
@ -230,23 +231,17 @@ fetch() {
|
||||||
URL="$1"
|
URL="$1"
|
||||||
FILE="$2"
|
FILE="$2"
|
||||||
|
|
||||||
echo "+ Downloading $URL"
|
|
||||||
|
|
||||||
if [ -e "$FILE" ]; then
|
if [ -e "$FILE" ]; then
|
||||||
echo "+ Using cached $FILE"
|
echo "+ Reusing $CACHE_DIR/${URL##*/}"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SKIP_ECHO=1
|
|
||||||
sh_c curl \
|
sh_c curl \
|
||||||
-#fL \
|
-#fL \
|
||||||
-o "$FILE.incomplete" \
|
-o "$FILE.incomplete" \
|
||||||
-C - \
|
-C - \
|
||||||
"$URL"
|
"$URL"
|
||||||
sh_c mv "$FILE.incomplete" "$FILE"
|
sh_c mv "$FILE.incomplete" "$FILE"
|
||||||
unset SKIP_ECHO
|
|
||||||
|
|
||||||
echo "+ Downloaded into $FILE"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
install_macos() {
|
install_macos() {
|
||||||
|
@ -290,19 +285,21 @@ install_aur() {
|
||||||
echo "Installing from the AUR."
|
echo "Installing from the AUR."
|
||||||
echo
|
echo
|
||||||
|
|
||||||
prev_dir="$PWD"
|
|
||||||
tmp_dir="$(mktemp -d)"
|
tmp_dir="$(mktemp -d)"
|
||||||
cd "$tmp_dir"
|
|
||||||
|
|
||||||
echo "+ Downloading PKGBUILD from https://aur.archlinux.org/cgit/aur.git/snapshot/code-server.tar.gz"
|
echo "+ Downloading PKGBUILD into $tmp_dir from https://aur.archlinux.org/cgit/aur.git/snapshot/code-server.tar.gz"
|
||||||
SKIP_ECHO=1 sh_c 'curl -fsSL https://aur.archlinux.org/cgit/aur.git/snapshot/code-server.tar.gz | tar -xz --strip-components 1'
|
curl -fsSL https://aur.archlinux.org/cgit/aur.git/snapshot/code-server.tar.gz | tar -xzC "$tmp_dir"
|
||||||
unset SKIP_ECHO
|
VERSION="$(. "$tmp_dir/code-server/PKGBUILD" && echo "$pkgver")"
|
||||||
echo "+ Downloaded into $tmp_dir"
|
rm -R "$tmp_dir"
|
||||||
|
|
||||||
|
mkdir -p "$CACHE_DIR/code-server-$VERSION-aur"
|
||||||
|
sh_c cp -a "$tmp_dir/code-server/*" "$CACHE_DIR/code-server-$VERSION-aur"
|
||||||
|
|
||||||
|
echo "+ Installing $CACHE_DIR/code-server-$VERSION-aur"
|
||||||
|
|
||||||
|
cd "$CACHE_DIR/code-server-$VERSION-aur"
|
||||||
sh_c makepkg -si
|
sh_c makepkg -si
|
||||||
|
|
||||||
cd "$prev_dir"
|
|
||||||
rm -Rf "$tmp_dir"
|
|
||||||
|
|
||||||
echo_systemd_postinstall
|
echo_systemd_postinstall
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,15 +315,14 @@ install_archive() {
|
||||||
sh_c="sudo_sh_c"
|
sh_c="sudo_sh_c"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SKIP_ECHO=1 sh_c mkdir -p "$ARCHIVE_INSTALL_PREFIX/lib" "$ARCHIVE_INSTALL_PREFIX/bin"
|
|
||||||
unset SKIP_ECHO
|
|
||||||
|
|
||||||
if [ -e "$ARCHIVE_INSTALL_PREFIX/lib/code-server-$VERSION" ]; then
|
if [ -e "$ARCHIVE_INSTALL_PREFIX/lib/code-server-$VERSION" ]; then
|
||||||
echo
|
echo
|
||||||
echo "code-server-$VERSION is already installed at $ARCHIVE_INSTALL_PREFIX/lib/code-server-$VERSION"
|
echo "code-server-$VERSION is already installed at $ARCHIVE_INSTALL_PREFIX/lib/code-server-$VERSION"
|
||||||
echo "Remove it to reinstall."
|
echo "Remove it to reinstall."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
"$sh_c" mkdir -p "$ARCHIVE_INSTALL_PREFIX/lib" "$ARCHIVE_INSTALL_PREFIX/bin"
|
||||||
"$sh_c" tar -C "$ARCHIVE_INSTALL_PREFIX/lib" -xzf "$CACHE_DIR/code-server-$VERSION-$OS-$ARCH.tar.gz"
|
"$sh_c" tar -C "$ARCHIVE_INSTALL_PREFIX/lib" -xzf "$CACHE_DIR/code-server-$VERSION-$OS-$ARCH.tar.gz"
|
||||||
"$sh_c" mv -f "$ARCHIVE_INSTALL_PREFIX/lib/code-server-$VERSION-$OS-$ARCH" "$ARCHIVE_INSTALL_PREFIX/lib/code-server-$VERSION"
|
"$sh_c" mv -f "$ARCHIVE_INSTALL_PREFIX/lib/code-server-$VERSION-$OS-$ARCH" "$ARCHIVE_INSTALL_PREFIX/lib/code-server-$VERSION"
|
||||||
"$sh_c" ln -fs "$ARCHIVE_INSTALL_PREFIX/lib/code-server-$VERSION/bin/code-server" "$ARCHIVE_INSTALL_PREFIX/bin/code-server"
|
"$sh_c" ln -fs "$ARCHIVE_INSTALL_PREFIX/lib/code-server-$VERSION/bin/code-server" "$ARCHIVE_INSTALL_PREFIX/bin/code-server"
|
||||||
|
@ -336,14 +332,22 @@ install_archive() {
|
||||||
|
|
||||||
install_npm() {
|
install_npm() {
|
||||||
if command_exists yarn; then
|
if command_exists yarn; then
|
||||||
|
sh_c="sh_c"
|
||||||
|
if [ ! -w "$(yarn global bin)" ]; then
|
||||||
|
sh_c="sudo_sh_c"
|
||||||
|
fi
|
||||||
echo "Installing with yarn."
|
echo "Installing with yarn."
|
||||||
echo
|
echo
|
||||||
sh_c yarn global add code-server --unsafe-perm
|
"$sh_c" yarn global add code-server --unsafe-perm
|
||||||
return
|
return
|
||||||
elif command_exists npm; then
|
elif command_exists npm; then
|
||||||
|
sh_c="sh_c"
|
||||||
|
if [ ! -w "$(npm config get prefix)" ]; then
|
||||||
|
sh_c="sudo_sh_c"
|
||||||
|
fi
|
||||||
echo "Installing with npm."
|
echo "Installing with npm."
|
||||||
echo
|
echo
|
||||||
sh_c npm install -g code-server --unsafe-perm
|
"$sh_c" npm install -g code-server --unsafe-perm
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
echo
|
echo
|
||||||
|
@ -431,9 +435,7 @@ command_exists() {
|
||||||
}
|
}
|
||||||
|
|
||||||
sh_c() {
|
sh_c() {
|
||||||
if [ ! "${SKIP_ECHO-}" ]; then
|
|
||||||
echo "+ $*"
|
echo "+ $*"
|
||||||
fi
|
|
||||||
if [ ! "${DRY_RUN-}" ]; then
|
if [ ! "${DRY_RUN-}" ]; then
|
||||||
sh -c "$*"
|
sh -c "$*"
|
||||||
fi
|
fi
|
||||||
|
@ -465,8 +467,21 @@ echo_cache_dir() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo() {
|
||||||
|
builtin echo "$@" | humanpath
|
||||||
|
}
|
||||||
|
|
||||||
|
cat() {
|
||||||
|
humanpath
|
||||||
|
}
|
||||||
|
|
||||||
echoerr() {
|
echoerr() {
|
||||||
echo "$@" >&2
|
echo "$@" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# humanpath replaces all occurances of $HOME with ~
|
||||||
|
humanpath() {
|
||||||
|
sed "s#$HOME#~#g"
|
||||||
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|
Loading…
Reference in New Issue