From b5aec2875df7c46b12695eabd8437d9aa6df616f Mon Sep 17 00:00:00 2001 From: Fazilov Kamil Date: Wed, 15 Apr 2026 12:12:47 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D1=83=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=BA=D1=83=20sing-b?= =?UTF-8?q?ox=20=D1=87=D0=B5=D1=80=D0=B5=D0=B7=20ipk=20=D1=84=D0=B0=D0=B9?= =?UTF-8?q?=D0=BB=20=D0=B5=D1=81=D0=BB=D0=B8=20=D0=BD=D0=B5=D1=82=20=D0=B4?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D1=83=D0=BF=D0=B0=20=D0=B4=D0=BE=20=D1=80?= =?UTF-8?q?=D0=B5=D0=BF=D0=BE=D0=B7=D0=B8=D1=82=D0=BE=D1=80=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- getconfig.sh | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/getconfig.sh b/getconfig.sh index 597c061..900075d 100644 --- a/getconfig.sh +++ b/getconfig.sh @@ -26,11 +26,45 @@ echo "" echo "Updating sing-box to version 1.11.15-1..." SINGBOX_TARGET_VERSION="1.11.15-1" SINGBOX_CURRENT_VERSION=$(opkg list-installed sing-box 2>/dev/null | awk '{print $3}') + if [ "$SINGBOX_CURRENT_VERSION" = "$SINGBOX_TARGET_VERSION" ]; then echo "sing-box already at $SINGBOX_TARGET_VERSION, skipping." else echo "Current: ${SINGBOX_CURRENT_VERSION:-not installed}. Upgrading..." - opkg update && opkg upgrade sing-box + + SINGBOX_UPGRADED=0 + + # Primary method: opkg + if opkg update && opkg upgrade sing-box; then + SINGBOX_UPGRADED=1 + echo "sing-box upgraded via opkg." + else + echo "opkg failed. Trying direct ipk download..." + fi + + # Fallback: direct ipk download + if [ "$SINGBOX_UPGRADED" = "0" ]; then + OPENWRT_ARCH=$(opkg print-architecture | grep -v ' all' | grep -v ' noarch' | awk 'NR==1{print $2}') + OPENWRT_RELEASE=$(grep DISTRIB_RELEASE /etc/openwrt_release 2>/dev/null | cut -d"'" -f2) + if echo "$OPENWRT_RELEASE" | grep -qi "snapshot"; then + SINGBOX_IPK_URL="https://downloads.openwrt.org/snapshots/packages/${OPENWRT_ARCH}/packages/sing-box_${SINGBOX_TARGET_VERSION}_${OPENWRT_ARCH}.ipk" + else + SINGBOX_IPK_URL="https://downloads.openwrt.org/releases/${OPENWRT_RELEASE}/packages/${OPENWRT_ARCH}/packages/sing-box_${SINGBOX_TARGET_VERSION}_${OPENWRT_ARCH}.ipk" + fi + SINGBOX_IPK_TMP="/tmp/sing-box_${SINGBOX_TARGET_VERSION}.ipk" + + echo "Detected arch: ${OPENWRT_ARCH}, release: ${OPENWRT_RELEASE}" + echo "Downloading: ${SINGBOX_IPK_URL}" + + if wget -O "$SINGBOX_IPK_TMP" "$SINGBOX_IPK_URL"; then + opkg install --force-reinstall "$SINGBOX_IPK_TMP" + rm -f "$SINGBOX_IPK_TMP" + SINGBOX_UPGRADED=1 + echo "sing-box installed from direct ipk." + else + echo "ERROR: Failed to download sing-box ipk. Manual installation may be required." + fi + fi fi echo "" echo "Configuring sing-box service (user=root)..."