feat(install): Default to gh.beszel.dev GitHub proxy for mainland China

- also removes CHINA_MAINLAND variable
This commit is contained in:
Henry Dollman
2025-01-21 20:20:36 -05:00
parent cfda7d0740
commit 0943e01b71

View File

@@ -23,13 +23,12 @@ ensure_trailing_slash() {
# Define default values # Define default values
PORT=45876 PORT=45876
UNINSTALL=false UNINSTALL=false
CHINA_MAINLAND=false
GITHUB_URL="https://github.com" GITHUB_URL="https://github.com"
GITHUB_API_URL="https://api.github.com" GITHUB_API_URL="https://api.github.com" # not blocked in China currently
GITHUB_PROXY_URL="https://ghfast.top/" # Default proxy URL GITHUB_PROXY_URL=""
KEY="" KEY=""
# Check for help flag first # Check for help flag
case "$1" in case "$1" in
-h | --help) -h | --help)
printf "Beszel Agent installation script\n\n" printf "Beszel Agent installation script\n\n"
@@ -38,8 +37,8 @@ case "$1" in
printf " -k : SSH key (required, or interactive if not provided)\n" printf " -k : SSH key (required, or interactive if not provided)\n"
printf " -p : Port (default: $PORT)\n" printf " -p : Port (default: $PORT)\n"
printf " -u : Uninstall Beszel Agent\n" printf " -u : Uninstall Beszel Agent\n"
printf " --china-mirrors [URL] : Using GitHub mirror sources to resolve network timeout issues in mainland China\n" printf " --china-mirrors [URL] : Use GitHub proxy (gh.beszel.dev) to resolve network timeout issues in mainland China\n"
printf " (optional: specify a custom proxy URL, e.g., https://ghfast.top/)\n" printf " optional: specify a custom proxy URL, e.g., \"https://ghfast.top\"\n"
printf " -h, --help : Display this help message\n" printf " -h, --help : Display this help message\n"
exit 0 exit 0
;; ;;
@@ -86,10 +85,14 @@ while [ $# -gt 0 ]; do
UNINSTALL=true UNINSTALL=true
;; ;;
--china-mirrors) --china-mirrors)
CHINA_MAINLAND=true
if [ "$2" != "" ] && ! echo "$2" | grep -q '^-'; then if [ "$2" != "" ] && ! echo "$2" | grep -q '^-'; then
GITHUB_PROXY_URL=$(ensure_trailing_slash "$2") # use cstom proxy URL if provided
GITHUB_PROXY_URL="$2"
GITHUB_URL="$(ensure_trailing_slash "$2")https://github.com"
shift shift
else
GITHUB_PROXY_URL="https://gh.beszel.dev"
GITHUB_URL="$GITHUB_PROXY_URL"
fi fi
;; ;;
*) *)
@@ -164,15 +167,15 @@ if [ "$UNINSTALL" = true ]; then
exit 0 exit 0
fi fi
if [ "$CHINA_MAINLAND" = true ]; then # Confirm the use of GitHub mirrors for downloads
printf "\nConfirmed to use GitHub mirrors (%s) for download beszel-agent?\nThis helps to install Agent properly in mainland China. (Y/n): " "$GITHUB_PROXY_URL" if [ -n "$GITHUB_PROXY_URL" ]; then
printf "\nConfirm use of GitHub mirror (%s) for downloading beszel-agent?\nThis helps to install properly in mainland China. (Y/n): " "$GITHUB_PROXY_URL"
read USE_MIRROR read USE_MIRROR
USE_MIRROR=${USE_MIRROR:-Y} USE_MIRROR=${USE_MIRROR:-Y}
if [ "$USE_MIRROR" = "Y" ] || [ "$USE_MIRROR" = "y" ]; then if [ "$USE_MIRROR" = "Y" ] || [ "$USE_MIRROR" = "y" ]; then
GITHUB_URL="${GITHUB_PROXY_URL}https://github.com"
echo "Using GitHub Mirror ($GITHUB_PROXY_URL) for downloads..." echo "Using GitHub Mirror ($GITHUB_PROXY_URL) for downloads..."
else else
echo "GitHub mirrors will not be used for installation." GITHUB_URL="https://github.com"
fi fi
fi fi