code-server.sh 855 字节
Newer Older
A
Anmol Sethi 已提交
1
#!/bin/sh
2 3

# This script is intended to be bundled into the static releases.
A
Anmol Sethi 已提交
4
# Runs code-server with the bundled Node binary.
A
Asher 已提交
5

A
Anmol Sethi 已提交
6 7
# More complicated than readlink -f or realpath to support macOS.
# See https://github.com/cdr/code-server/issues/1537
8
bin_dir() {
A
Anmol Sethi 已提交
9 10 11
  # We read the symlink, which may be relative from $0.
  dst="$(readlink "$0")"
  # We cd into the $0 directory.
12
  cd "$(dirname "$0")" || exit 1
A
Anmol Sethi 已提交
13
  # Now we can cd into the dst directory.
14
  cd "$(dirname "$dst")" || exit 1
A
Anmol Sethi 已提交
15
  # Finally we use pwd -P to print the absolute path of the directory of $dst.
16
  pwd -P || exit 1
A
Anmol Sethi 已提交
17
}
A
Asher 已提交
18

19
BIN_DIR=$(bin_dir)
A
Anmol Sethi 已提交
20
if [ "$(uname)" = "Linux" ]; then
A
Anmol Sethi 已提交
21 22
  export LD_LIBRARY_PATH="$BIN_DIR/../lib${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}"
else
A
Anmol Sethi 已提交
23
  export DYLD_LIBRARY_PATH="$BIN_DIR/../lib${DYLD_LIBRARY_PATH+:$DYLD_LIBRARY_PATH}"
A
Anmol Sethi 已提交
24
fi
25
exec "$BIN_DIR/../lib/node" "$BIN_DIR/.." "$@"