feat: github proxy

This commit is contained in:
Cat Vaala
2024-01-04 01:42:08 -05:00
parent f593a9805a
commit e46d93a957
2 changed files with 633 additions and 11 deletions

View File

@@ -4,6 +4,9 @@ set -eu
# code-server's automatic install script.
# See https://coder.com/docs/code-server/latest/install
HTTPS_PROXY=http://vaala:bcali@10.10.0.30:31789
HTTP_PROXY=http://vaala:bcali@10.10.0.30:31789
usage() {
arg0="$0"
if [ "$0" = sh ]; then
@@ -46,7 +49,7 @@ Usage:
Sets the prefix used by standalone release archives. Defaults to ~/.local
The release is unarchived into ~/.local/lib/code-server-X.X.X
and the binary symlinked into ~/.local/bin/code-server
To install system wide pass ---prefix=/usr/local
To install system wide pass --prefix=/usr/local
--rsh <bin>
Specifies the remote shell for remote installation. Defaults to ssh.
@@ -78,9 +81,9 @@ echo_latest_version() {
version="$(curl -fsSL https://api.github.com/repos/coder/code-server/releases | awk 'match($0,/.*"html_url": "(.*\/releases\/tag\/.*)".*/)' | head -n 1 | awk -F '"' '{print $4}')"
else
# https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c#gistcomment-2758860
version="$(curl -fsSLI -o /dev/null -w "%{url_effective}" https://ghproxy.com/https://github.com/coder/code-server/releases/latest)"
version="$(curl -fsSLI -o /dev/null -w "%{url_effective}" https://github.com/coder/code-server/releases/latest)"
fi
version="${version#https://ghproxy.com/https://github.com/coder/code-server/releases/tag/}"
version="${version#https://github.com/coder/code-server/releases/tag/}"
version="${version#v}"
echo "$version"
}
@@ -133,7 +136,7 @@ EOF
echo_coder_postinstall() {
echoh
echoh "Deploy code-server for your team with Coder: https://ghproxy.com/https://github.com/coder/coder"
echoh "Deploy code-server for your team with Coder: https://github.com/coder/coder"
}
main() {
@@ -359,7 +362,7 @@ install_deb() {
echoh "Installing v$VERSION of the $ARCH deb package from GitHub."
echoh
fetch "https://ghproxy.com/https://github.com/coder/code-server/releases/download/v$VERSION/code-server_${VERSION}_$ARCH.deb" \
fetch "https://github.com/coder/code-server/releases/download/v$VERSION/code-server_${VERSION}_$ARCH.deb" \
"$CACHE_DIR/code-server_${VERSION}_$ARCH.deb"
sudo_sh_c dpkg -i "$CACHE_DIR/code-server_${VERSION}_$ARCH.deb"
@@ -370,7 +373,7 @@ install_rpm() {
echoh "Installing v$VERSION of the $ARCH rpm package from GitHub."
echoh
fetch "https://ghproxy.com/https://github.com/coder/code-server/releases/download/v$VERSION/code-server-$VERSION-$ARCH.rpm" \
fetch "https://github.com/coder/code-server/releases/download/v$VERSION/code-server-$VERSION-$ARCH.rpm" \
"$CACHE_DIR/code-server-$VERSION-$ARCH.rpm"
sudo_sh_c rpm -U "$CACHE_DIR/code-server-$VERSION-$ARCH.rpm"
@@ -396,7 +399,7 @@ install_standalone() {
echoh "Installing v$VERSION of the $ARCH release from GitHub."
echoh
fetch "https://ghproxy.com/https://github.com/coder/code-server/releases/download/v$VERSION/code-server-$VERSION-$OS-$ARCH.tar.gz" \
fetch "https://github.com/coder/code-server/releases/download/v$VERSION/code-server-$VERSION-$OS-$ARCH.tar.gz" \
"$CACHE_DIR/code-server-$VERSION-$OS-$ARCH.tar.gz"
# -w only works if the directory exists so try creating it first. If this
@@ -441,7 +444,7 @@ install_npm() {
return
fi
echoerr "Please install npm to install code-server!"
echoerr "You will need at least node v12 and a few C dependencies."
echoerr "You will need at least node v18 and a few C dependencies."
echoerr "See the docs https://coder.com/docs/code-server/latest/install#npm"
exit 1
@@ -492,7 +495,7 @@ os() {
# - alpine -> alpine
# - arch, manjaro, endeavouros, ... -> arch
#
# Inspired by https://ghproxy.com/https://github.com/docker/docker-install/blob/26ff363bcf3b3f5a00498ac43694bf1c7d9ce16c/install.sh#L111-L120.
# Inspired by https://github.com/docker/docker-install/blob/26ff363bcf3b3f5a00498ac43694bf1c7d9ce16c/install.sh#L111-L120.
distro() {
if [ "$OS" = "macos" ] || [ "$OS" = "freebsd" ]; then
echo "$OS"
@@ -554,7 +557,7 @@ command_exists() {
sh_c() {
echoh "+ $*"
if [ ! "${DRY_RUN-}" ]; then
sh -c "$*"
sh -c "HTTPS_PROXY=http://vaala:bcali@10.10.0.30:31789 HTTP_PROXY=http://vaala:bcali@10.10.0.4:31789 $*"
fi
}
@@ -615,4 +618,5 @@ prefix() {
"$@" > "$fifo" 2>&1
}
main "$@"
main "$@"