From c32eb0451686e1b1bc287bd1db459abc09ef819f Mon Sep 17 00:00:00 2001 From: tearmoon Date: Wed, 24 Jul 2024 23:36:15 +0700 Subject: [PATCH] [box.tool] Add option to download sing-box "Pre-release" and "Latest release" https://github.com/taamarin/box_for_magisk/issues/133 --- box/scripts/box.tool | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/box/scripts/box.tool b/box/scripts/box.tool index 0e458e0..8eb49c7 100755 --- a/box/scripts/box.tool +++ b/box/scripts/box.tool @@ -10,6 +10,7 @@ url_ghproxy="https://mirror.ghproxy.com" use_ghproxy="true" # to enable/disable download the stable mihomo kernel mihomo_stable="enable" +singbox_stable="disable" # Updating files from URLs upfile() { @@ -349,7 +350,21 @@ upkernel() { api_url="https://api.github.com/repos/SagerNet/sing-box/releases" url_down="https://github.com/SagerNet/sing-box/releases" - latest_version=$(busybox wget --no-check-certificate -qO- "${api_url}" | grep "tag_name" | busybox grep -oE "v[0-9].*" | head -1 | cut -d'"' -f1) + if [ "${singbox_stable}" = "disable" ]; then + # Pre-release + log Debug "download ${bin_name} Pre-release" + latest_version=$(busybox wget --no-check-certificate -qO- "${api_url}" | grep "tag_name" | busybox grep -oE "v[0-9].*" | head -1 | cut -d'"' -f1) + else + # Latest + log Debug "download ${bin_name} Latest-stable" + latest_version=$(busybox wget --no-check-certificate -qO- "${api_url}/latest" | grep "tag_name" | busybox grep -oE "v[0-9.]*" | head -1) + fi + + if [ -z "$latest_version" ]; then + log Error "Failed to get latest stable/beta/alpha version of sing-box" + return 1 + fi + download_link="${url_down}/download/${latest_version}/sing-box-${latest_version#v}-${platform}-${arch}.tar.gz" log Debug "download ${download_link}" upfile "${box_dir}/${file_kernel}.tar.gz" "${download_link}" && xkernel