Skip to content

Add auto install script #1701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
May 28, 2020
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
96eeb9f
Fix install instructions for SUSE
nhooyr May 20, 2020
3b11733
Add auto install script
nhooyr May 20, 2020
0129e00
Add install.sh into README.md
nhooyr May 20, 2020
510d848
install.sh: Add our own flag parser
nhooyr May 21, 2020
c80b274
install.sh: Fixes from @code-asher's review
nhooyr May 21, 2020
e0172d0
Minor fixes for install.sh and bundle in libstdc++
nhooyr May 21, 2020
a40dabb
Add install script to docs
nhooyr May 21, 2020
f117475
install.md: Add https://github.com/linuxserver/docker-code-server
nhooyr May 21, 2020
ac9b57c
Properly bundle in libstdc++
nhooyr May 21, 2020
e55d3e4
Bundle in libicu on macOS
nhooyr May 22, 2020
15cd727
Replace gif with screenshot
nhooyr May 22, 2020
7dcfde7
Documentation fixes
nhooyr May 22, 2020
42b5152
Further documentation cleanup
nhooyr May 22, 2020
7ef82d8
Improved install.sh flags
nhooyr May 22, 2020
e9101a2
Improve formatting
nhooyr May 27, 2020
c51d94d
Document PWA
nhooyr May 27, 2020
eb17a29
Document Microsoft's Remote extensions
nhooyr May 27, 2020
33bca2d
Adjust nfpm config for bindir removal
nhooyr May 27, 2020
665ca01
Fixes from @code-asher's godly review
nhooyr May 27, 2020
fa45fd0
Rename static releases to binary releases
nhooyr May 27, 2020
06c26a2
Improve aur installation clarity
nhooyr May 27, 2020
f71d887
Rename binary release to standalone
nhooyr May 27, 2020
29e5c4a
Clarify npm docs in install.md
nhooyr May 27, 2020
af398c4
Workaround lack of builtin in /bin/sh
nhooyr May 27, 2020
30e9c51
Further improve AUR installation
nhooyr May 27, 2020
fbd8564
Fix CI
nhooyr May 27, 2020
69ad529
v3.4.0
nhooyr May 27, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Workaround lack of builtin in /bin/sh
  • Loading branch information
nhooyr committed May 27, 2020
commit af398c49fd652bf99705ba92e0a5fb34375ace52
71 changes: 36 additions & 35 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ usage() {
"
fi

cat << EOF
cath << EOF
Installs code-server for Linux and macOS.
It tries to use the system package manager if possible.
After successful installation it explains how to start using code-server.
Expand Down Expand Up @@ -67,8 +67,8 @@ echo_latest_version() {
}

echo_standalone_postinstall() {
echo
cat << EOF
echoh
cath << EOF
Standalone release has been installed into $STANDALONE_INSTALL_PREFIX/lib/code-server-$VERSION
Please extend your path to use code-server:
PATH="$STANDALONE_INSTALL_PREFIX/bin:\$PATH"
Expand All @@ -78,8 +78,8 @@ EOF
}

echo_systemd_postinstall() {
echo
cat << EOF
echoh
cath << EOF
To have systemd start code-server now and restart on boot:
systemctl --user enable --now code-server
Or, if you don't want/need a background service you can run:
Expand Down Expand Up @@ -163,7 +163,7 @@ main() {
echoerr 'Please rerun without the "--method standalone" flag to install from npm.'
exit 1
fi
echo "No precompiled releases for $(uname -m)."
echoh "No precompiled releases for $(uname -m)."
install_npm
return
fi
Expand All @@ -190,7 +190,7 @@ main() {
install_aur
;;
*)
echo "Unsupported package manager."
echoh "Unsupported package manager."
install_standalone
;;
esac
Expand Down Expand Up @@ -233,7 +233,7 @@ fetch() {
FILE="$2"

if [ -e "$FILE" ]; then
echo "+ Reusing $CACHE_DIR/${URL##*/}"
echoh "+ Reusing $CACHE_DIR/${URL##*/}"
return
fi

Expand All @@ -247,22 +247,22 @@ fetch() {

install_macos() {
if command_exists brew; then
echo "Installing from Homebrew."
echo
echoh "Installing from Homebrew."
echoh

sh_c brew install code-server

return
fi

echo "Homebrew not installed."
echoh "Homebrew not installed."

install_standalone
}

install_deb() {
echo "Installing v$VERSION deb package from GitHub releases."
echo
echoh "Installing v$VERSION deb package from GitHub releases."
echoh

fetch "https://github.com/cdr/code-server/releases/download/v$VERSION/code-server_${VERSION}_$ARCH.deb" \
"$CACHE_DIR/code-server_${VERSION}_$ARCH.deb"
Expand All @@ -272,8 +272,8 @@ install_deb() {
}

install_rpm() {
echo "Installing v$VERSION rpm package from GitHub releases."
echo
echoh "Installing v$VERSION rpm package from GitHub releases."
echoh

fetch "https://github.com/cdr/code-server/releases/download/v$VERSION/code-server-$VERSION-$ARCH.rpm" \
"$CACHE_DIR/code-server-$VERSION-$ARCH.rpm"
Expand All @@ -283,27 +283,28 @@ install_rpm() {
}

install_aur() {
echo "Installing from the AUR."
echo
echoh "Installing from the AUR."
echoh

tmp_dir="$(mktemp -d)"

echo "+ Downloading PKGBUILD into $tmp_dir from https://aur.archlinux.org/cgit/aur.git/snapshot/code-server.tar.gz"
echoh "+ Downloading PKGBUILD into $tmp_dir from https://aur.archlinux.org/cgit/aur.git/snapshot/code-server.tar.gz"
curl -fsSL https://aur.archlinux.org/cgit/aur.git/snapshot/code-server.tar.gz | tar -xzC "$tmp_dir"
VERSION="$(. "$tmp_dir/code-server/PKGBUILD" && echo "$pkgver")"
rm -R "$tmp_dir"

sh_c mkdir -p "$CACHE_DIR/code-server-$VERSION-aur"
sh_c cp -a "$tmp_dir/code-server/*" "$CACHE_DIR/code-server-$VERSION-aur"
sh_c cd "$CACHE_DIR/code-server-$VERSION-aur"
sh_c makepkg -si

rm -R "$tmp_dir"

echo_systemd_postinstall
}

install_standalone() {
echo "Installing standalone release archive v$VERSION"
echo
echoh "Installing standalone release archive v$VERSION"
echoh

fetch "https://github.com/cdr/code-server/releases/download/v$VERSION/code-server-$VERSION-$OS-$ARCH.tar.gz" \
"$CACHE_DIR/code-server-$VERSION-$OS-$ARCH.tar.gz"
Expand All @@ -314,9 +315,9 @@ install_standalone() {
fi

if [ -e "$STANDALONE_INSTALL_PREFIX/lib/code-server-$VERSION" ]; then
echo
echo "code-server-$VERSION is already installed at $STANDALONE_INSTALL_PREFIX/lib/code-server-$VERSION"
echo "Remove it to reinstall."
echoh
echoh "code-server-$VERSION is already installed at $STANDALONE_INSTALL_PREFIX/lib/code-server-$VERSION"
echoh "Remove it to reinstall."
exit 0
fi

Expand All @@ -334,21 +335,21 @@ install_npm() {
if [ ! -w "$(yarn global bin)" ]; then
sh_c="sudo_sh_c"
fi
echo "Installing with yarn."
echo
echoh "Installing with yarn."
echoh
"$sh_c" yarn global add code-server --unsafe-perm
return
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
echoh "Installing with npm."
echoh
"$sh_c" npm install -g code-server --unsafe-perm
return
fi
echo
echoh
echoerr "Please install npm or yarn to install code-server!"
echoerr "You will need at least node v12 and a few C dependencies."
echoerr "See the docs https://github.com/cdr/code-server#yarn-npm"
Expand Down Expand Up @@ -433,7 +434,7 @@ command_exists() {
}

sh_c() {
echo "+ $*"
echoh "+ $*"
if [ ! "${DRY_RUN-}" ]; then
sh -c "$*"
fi
Expand All @@ -447,7 +448,7 @@ sudo_sh_c() {
elif command_exists su; then
sh_c "su -c '$*'"
else
echo
echoh
echoerr "This script needs to run the following command as root."
echoerr " $*"
echoerr "Please install sudo or su."
Expand All @@ -465,16 +466,16 @@ echo_cache_dir() {
fi
}

echo() {
builtin echo "$@" | humanpath
echoh() {
echo "$@" | humanpath
}

cat() {
cath() {
humanpath
}

echoerr() {
echo "$@" >&2
echoh "$@" >&2
}

# humanpath replaces all occurances of $HOME with ~
Expand Down