Skip to content

Commit 665ca01

Browse files
committed
Fixes from @code-asher's godly review
1 parent 33bca2d commit 665ca01

File tree

6 files changed

+59
-46
lines changed

6 files changed

+59
-46
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ It tries to use the system package manager if possible.
2525
First run to print out the install process:
2626

2727
```bash
28-
curl -fsSL https://code-server.dev/install.sh | sh -s -- --dry-run
28+
curl -fsSL https://code-server.dev/install.sh | sh -s -- --dry-run
2929
```
3030

3131
Now to actually install:

ci/dev/lint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ main() {
99
tsc --noEmit
1010
# See comment in ./ci/container/Dockerfile
1111
if [[ ! ${CI-} ]]; then
12-
shellcheck -e SC2046,SC2164,SC2154,SC1091 $(git ls-files "*.sh")
12+
shellcheck -e SC2046,SC2164,SC2154,SC1091,SC1090 $(git ls-files "*.sh")
1313
fi
1414
}
1515

doc/FAQ.md

+7-9
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,13 @@ user a virtual machine instead of just a container.
152152

153153
## Docker in code-server container?
154154

155-
If you'd like to access docker inside of code-server, we'd recommend running a `docker:dind` container
156-
and mounting in a directory to share between `dind` and the `code-server` container at `/var/run`.
157-
After, install the docker CLI in the code-server container and you should be able to access the
158-
daemon as the socket will be shared at `/var/run/docker.sock`.
155+
If you'd like to access docker inside of code-server, mount the docker socket in from `/var/run/docker.sock`.
156+
Install the docker CLI in the code-server container and you should be able to access the daemon!
159157

160-
In order to make volume mounts work, mount the home directory in the code-server container and the
161-
dind container at the same path. i.e you'd volume mount a directory from the host to `/home/coder`
162-
on both. This will allow any volume mounts in the home directory to work. Similar process
163-
to make volume mounts in any other directory work.
158+
You can even make volume mounts work. Lets say you want to run a container and mount in
159+
`/home/coder/myproject` into it from inside the `code-server` container. You need to make sure
160+
the docker daemon's `/home/coder/myproject` is the same as the one mounted inside the `code-server`
161+
container and the mount will just work.
164162

165163
## Collaboration
166164

@@ -269,7 +267,7 @@ it is against their TOS to use the published extensions so we are unable to
269267
add them to our marketplace.
270268

271269
We may reimplement them at some point.
272-
You can follow [#1315](https://github.com/cdr/code-server/issues/1315) for updates.
270+
You can subscribe to [#1315](https://github.com/cdr/code-server/issues/1315) for updates.
273271

274272
## Enterprise
275273

doc/guide.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ to avoid the slow dashboard.
7878

7979
## 2. Install code-server
8080

81-
We have a [script](./install.sh) to install `code-server` for Linux and macOS.
81+
We have a [script](../install.sh) to install `code-server` for Linux and macOS.
8282

8383
It tries to use the system package manager if possible.
8484

8585
First run to print out the install process:
8686

8787
```bash
88-
curl -fsSL https://code-server.dev/install.sh | sh -s -- --dry-run
88+
curl -fsSL https://code-server.dev/install.sh | sh -s -- --dry-run
8989
```
9090

9191
Now to actually install:
@@ -96,7 +96,7 @@ curl -fsSL https://code-server.dev/install.sh | sh
9696

9797
The install script will print out how to run and start using `code-server`.
9898

99-
Docs on the install script, manual installation and docker image are at [./doc/install.md](./doc/install.md).
99+
Docs on the install script, manual installation and docker image are at [./install.md](./install.md).
100100

101101
## 3. Expose code-server
102102

@@ -205,7 +205,7 @@ the dependency on caddy.
205205
### Self Signed Certificate
206206

207207
**note:** Self signed certificates do not work with iPad and will cause a blank page. You'll
208-
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).
208+
have to use [Let's Encrypt](#lets-encrypt) instead. See the [FAQ](./FAQ.md#blank-screen-on-ipad).
209209

210210
Recommended reading: https://security.stackexchange.com/a/8112.
211211

@@ -255,4 +255,4 @@ systemctl --user restart code-server
255255

256256
If you're working on a web service and want to access it locally, `code-server` can proxy it for you.
257257

258-
See the [FAQ](https://github.com/cdr/code-server/blob/master/doc/FAQ.md#how-do-i-securely-access-web-services).
258+
See the [FAQ](./FAQ.md#how-do-i-securely-access-web-services).

doc/install.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ 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 and macOS.
2424

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

2727
First run to print out the install process:
2828

2929
```bash
30-
curl -fsSL https://code-server.dev/install.sh | sh -s -- --dry-run
30+
curl -fsSL https://code-server.dev/install.sh | sh -s -- --dry-run
3131
```
3232

3333
Now to actually install:
@@ -43,7 +43,7 @@ If you believe an install script used with `curl | sh` is insecure, please give
4343
[sandstorm.io](https://sandstorm.io) a read.
4444

4545
If you'd still prefer manual installation despite the below [detect reference](#detect-reference) and `--dry-run`
46-
then continue on for docs on manual installation. The [`install.sh`](./install.sh) script runs the _exact_ same
46+
then continue on for docs on manual installation. The [`install.sh`](../install.sh) script runs the _exact_ same
4747
commands presented in the rest of this document.
4848

4949
### Flags
@@ -117,7 +117,7 @@ We recommend installing with `yarn` or `npm` when:
117117
2. If you're on Linux with glibc < v2.17
118118

119119
**note:** Installing via `yarn` or `npm` builds native modules on install and so requires C dependencies.
120-
See [./doc/npm.md](./doc/npm.md) for installing these dependencies.
120+
See [./npm.md](./npm.md) for installing these dependencies.
121121

122122
You will need at least node v12 installed. See [#1633](https://github.com/cdr/code-server/issues/1633).
123123

install.sh

+41-26
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ main() {
9595
DRY_RUN \
9696
METHOD \
9797
ARCHIVE_INSTALL_PREFIX \
98-
SKIP_ECHO \
9998
VERSION \
10099
OPTIONAL
101100

@@ -199,7 +198,9 @@ main() {
199198
parse_arg() {
200199
case "$1" in
201200
*=*)
202-
opt="${1#=*}"
201+
# Remove everything after first equal sign.
202+
opt="${1%%=*}"
203+
# Remove everything before first equal sign.
203204
optarg="${1#*=}"
204205
if [ ! "$optarg" ] && [ ! "${OPTIONAL-}" ]; then
205206
echoerr "$opt requires an argument"
@@ -230,23 +231,17 @@ fetch() {
230231
URL="$1"
231232
FILE="$2"
232233

233-
echo "+ Downloading $URL"
234-
235234
if [ -e "$FILE" ]; then
236-
echo "+ Using cached $FILE"
235+
echo "+ Reusing $CACHE_DIR/${URL##*/}"
237236
return
238237
fi
239238

240-
SKIP_ECHO=1
241239
sh_c curl \
242240
-#fL \
243241
-o "$FILE.incomplete" \
244242
-C - \
245243
"$URL"
246244
sh_c mv "$FILE.incomplete" "$FILE"
247-
unset SKIP_ECHO
248-
249-
echo "+ Downloaded into $FILE"
250245
}
251246

252247
install_macos() {
@@ -290,18 +285,20 @@ install_aur() {
290285
echo "Installing from the AUR."
291286
echo
292287

293-
prev_dir="$PWD"
294288
tmp_dir="$(mktemp -d)"
295-
cd "$tmp_dir"
296289

297-
echo "+ Downloading PKGBUILD from https://aur.archlinux.org/cgit/aur.git/snapshot/code-server.tar.gz"
298-
SKIP_ECHO=1 sh_c 'curl -fsSL https://aur.archlinux.org/cgit/aur.git/snapshot/code-server.tar.gz | tar -xz --strip-components 1'
299-
unset SKIP_ECHO
300-
echo "+ Downloaded into $tmp_dir"
301-
sh_c makepkg -si
290+
echo "+ Downloading PKGBUILD into $tmp_dir from https://aur.archlinux.org/cgit/aur.git/snapshot/code-server.tar.gz"
291+
curl -fsSL https://aur.archlinux.org/cgit/aur.git/snapshot/code-server.tar.gz | tar -xzC "$tmp_dir"
292+
VERSION="$(. "$tmp_dir/code-server/PKGBUILD" && echo "$pkgver")"
293+
rm -R "$tmp_dir"
302294

303-
cd "$prev_dir"
304-
rm -Rf "$tmp_dir"
295+
mkdir -p "$CACHE_DIR/code-server-$VERSION-aur"
296+
sh_c cp -a "$tmp_dir/code-server/*" "$CACHE_DIR/code-server-$VERSION-aur"
297+
298+
echo "+ Installing $CACHE_DIR/code-server-$VERSION-aur"
299+
300+
cd "$CACHE_DIR/code-server-$VERSION-aur"
301+
sh_c makepkg -si
305302

306303
echo_systemd_postinstall
307304
}
@@ -318,15 +315,14 @@ install_archive() {
318315
sh_c="sudo_sh_c"
319316
fi
320317

321-
SKIP_ECHO=1 sh_c mkdir -p "$ARCHIVE_INSTALL_PREFIX/lib" "$ARCHIVE_INSTALL_PREFIX/bin"
322-
unset SKIP_ECHO
323-
324318
if [ -e "$ARCHIVE_INSTALL_PREFIX/lib/code-server-$VERSION" ]; then
325319
echo
326320
echo "code-server-$VERSION is already installed at $ARCHIVE_INSTALL_PREFIX/lib/code-server-$VERSION"
327321
echo "Remove it to reinstall."
328322
exit 0
329323
fi
324+
325+
"$sh_c" mkdir -p "$ARCHIVE_INSTALL_PREFIX/lib" "$ARCHIVE_INSTALL_PREFIX/bin"
330326
"$sh_c" tar -C "$ARCHIVE_INSTALL_PREFIX/lib" -xzf "$CACHE_DIR/code-server-$VERSION-$OS-$ARCH.tar.gz"
331327
"$sh_c" mv -f "$ARCHIVE_INSTALL_PREFIX/lib/code-server-$VERSION-$OS-$ARCH" "$ARCHIVE_INSTALL_PREFIX/lib/code-server-$VERSION"
332328
"$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() {
336332

337333
install_npm() {
338334
if command_exists yarn; then
335+
sh_c="sh_c"
336+
if [ ! -w "$(yarn global bin)" ]; then
337+
sh_c="sudo_sh_c"
338+
fi
339339
echo "Installing with yarn."
340340
echo
341-
sh_c yarn global add code-server --unsafe-perm
341+
"$sh_c" yarn global add code-server --unsafe-perm
342342
return
343343
elif command_exists npm; then
344+
sh_c="sh_c"
345+
if [ ! -w "$(npm config get prefix)" ]; then
346+
sh_c="sudo_sh_c"
347+
fi
344348
echo "Installing with npm."
345349
echo
346-
sh_c npm install -g code-server --unsafe-perm
350+
"$sh_c" npm install -g code-server --unsafe-perm
347351
return
348352
fi
349353
echo
@@ -431,9 +435,7 @@ command_exists() {
431435
}
432436

433437
sh_c() {
434-
if [ ! "${SKIP_ECHO-}" ]; then
435-
echo "+ $*"
436-
fi
438+
echo "+ $*"
437439
if [ ! "${DRY_RUN-}" ]; then
438440
sh -c "$*"
439441
fi
@@ -465,8 +467,21 @@ echo_cache_dir() {
465467
fi
466468
}
467469

470+
echo() {
471+
builtin echo "$@" | humanpath
472+
}
473+
474+
cat() {
475+
humanpath
476+
}
477+
468478
echoerr() {
469479
echo "$@" >&2
470480
}
471481

482+
# humanpath replaces all occurances of $HOME with ~
483+
humanpath() {
484+
sed "s#$HOME#~#g"
485+
}
486+
472487
main "$@"

0 commit comments

Comments
 (0)