diff --git a/README.md b/README.md index 87f6ec1..3e175cf 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,11 @@ sh -c "$(curl -ksS https://raw.githubusercontent.com/sbwml/luci-app-openlist/main/install.sh)" ``` + # install via ghproxy + ```shell + sh -c "$(curl -ksS https://raw.githubusercontent.com/sbwml/luci-app-openlist/main/install.sh)" _ gh_proxy="https://gh.cooluc.com" + ``` + -------------- ![luci-app-openlist](https://github.com/user-attachments/assets/80593704-1e02-4bcf-8290-a0c7c37012f4) diff --git a/install.sh b/install.sh index e40db17..67f7de2 100755 --- a/install.sh +++ b/install.sh @@ -9,6 +9,21 @@ RESET='\033[0m' msg_red() { printf "${RED}%s${RESET}\n" "$*"; } msg_green() { printf "${GREEN}%s${RESET}\n" "$*"; } +# Parse gh_proxy from $1 if provided, e.g. gh_proxy="https://gh-proxy.com/" +gh_proxy="" +if [ -n "$1" ]; then + case "$1" in + gh_proxy=*) + gh_proxy="${1#gh_proxy=}" + # ensure gh_proxy ends with / + [ -n "$gh_proxy" ] && case "$gh_proxy" in + */) : ;; + *) gh_proxy="$gh_proxy/" ;; + esac + ;; + esac +fi + # Check if running on OpenWrt if [ ! -f /etc/openwrt_release ]; then msg_red "Unknown OpenWrt Version" @@ -101,7 +116,12 @@ fi # Download the corresponding package archive PKG_FILE="$SDK-$DISTRIB_ARCH.tar.gz" -PKG_URL="https://github.com/sbwml/luci-app-openlist/releases/latest/download/$PKG_FILE" +BASE_URL="https://github.com/sbwml/luci-app-openlist/releases/latest/download/$PKG_FILE" +if [ -n "$gh_proxy" ]; then + PKG_URL="${gh_proxy}${BASE_URL}" +else + PKG_URL="$BASE_URL" +fi msg_green "Downloading $PKG_URL ..." if ! curl --connect-timeout 5 -m 300 -kLo "$TEMP_DIR/$PKG_FILE" "$PKG_URL"; then