diff --git a/.github/workflows/compile_new_ipk.yml b/.github/workflows/compile_new_ipk.yml index e2842bad6f..d75b9cef3e 100644 --- a/.github/workflows/compile_new_ipk.yml +++ b/.github/workflows/compile_new_ipk.yml @@ -35,8 +35,8 @@ jobs: - name: Current Version id: current_version run: | - echo "version=$(sed -n 1p ./${{ github.ref_name }}/version |awk -F '-' '{print $1}' |awk -F 'v' '{print $2}')" >> $GITHUB_OUTPUT - echo "Current Version: $(sed -n 1p ./${{ github.ref_name }}/version |awk -F '-' '{print $1}' |awk -F 'v' '{print $2}')" + echo "version=$(sed -n 1p ./${{ github.ref_name }}/version |awk -F 'v' '{print $2}')" >> $GITHUB_OUTPUT + echo "Current Version: $(sed -n 1p ./${{ github.ref_name }}/version |awk -F 'v' '{print $2}')" Compile: runs-on: ubuntu-latest @@ -53,7 +53,7 @@ jobs: DEBIAN_FRONTEND: noninteractive run: | sudo apt-get update - sudo apt-get -y install curl git tar + sudo apt-get -y install curl git tar zstd - name: Install OpenWrt SDK run: | @@ -63,12 +63,23 @@ jobs: cd \tmp tar xjf SDK.tar.bz2 mv "OpenWrt-SDK-15.05.1-ar71xx-generic_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64" "SDK" + + - name: Install OpenWrt SNAPSHPT SDK + run: | + cd .. + curl -SLk --connect-timeout 30 --retry 2 "https://downloads.openwrt.org/snapshots/targets/x86/64/openwrt-sdk-x86-64_gcc-13.3.0_musl.Linux-x86_64.tar.zst" -o "./tmp/SNAPSDK.tar.zst" + cd \tmp + zstd -d SNAPSDK.tar.zst + tar xf SNAPSDK.tar + mv "openwrt-sdk-x86-64_gcc-13.3.0_musl.Linux-x86_64" "SNAPSDK" - name: Copy OpenClash Source Codes run: | cd .. - mkdir tmp/SDK/package/luci-app-openclash + mkdir -p tmp/SDK/package/luci-app-openclash + mkdir -p tmp/SNAPSDK/package/luci-app-openclash cp -rf "./OpenClash/luci-app-openclash/." "./tmp/SDK/package/luci-app-openclash/" + cp -rf "./OpenClash/luci-app-openclash/." "./tmp/SNAPSDK/package/luci-app-openclash/" - name: Compile po2lmo run: | @@ -77,12 +88,24 @@ jobs: pushd luci-app-openclash/tools/po2lmo make && sudo make install popd + cd ../../.. + cd tmp/SNAPSDK/package/ + pushd luci-app-openclash/tools/po2lmo + make && sudo make install + popd - name: Compile OpenClash IPK run: | cd .. cd tmp/SDK make package/luci-app-openclash/compile V=99 + + - name: Compile OpenClash APK + run: | + cd .. + cd tmp/SNAPSDK + make defconfig + make package/luci-app-openclash/compile V=99 - name: Switch OpenClash Repository to Package uses: actions/checkout@v4 @@ -91,18 +114,19 @@ jobs: - name: Commit and Push New Version run: | - rm -rf ./${{ github.ref_name }}/luci-app-openclash_* - echo "v${{ needs.Get-Version.outputs.version }}-beta" > ./${{ github.ref_name }}/version - echo "https://img.shields.io/badge/New Release-v${{ needs.Get-Version.outputs.version }}--beta-orange.svg" >> ./${{ github.ref_name }}/version + rm -rf ./${{ github.ref_name }}/luci-app-openclash* + echo "v${{ needs.Get-Version.outputs.version }}" > ./${{ github.ref_name }}/version + echo "https://img.shields.io/badge/New Release-v${{ needs.Get-Version.outputs.version }}-orange.svg" >> ./${{ github.ref_name }}/version cd .. - cp "./tmp/SDK/bin/ar71xx/packages/base/luci-app-openclash_${{ needs.Get-Version.outputs.version }}-beta_all.ipk" "./OpenClash/${{ github.ref_name }}/luci-app-openclash_${{ needs.Get-Version.outputs.version }}-beta_all.ipk" - sed -i -E "s/OpenClash\/tree\/v(.*)-beta/OpenClash\/tree\/v${{ needs.Get-Version.outputs.version }}-beta/g" ./OpenClash/${{ github.ref_name }}/README.md - sed -i -E "s/OpenClash\/releases\/tag\/v(.*)-beta/OpenClash\/releases\/tag\/v${{ needs.Get-Version.outputs.version }}-beta/g" ./OpenClash/${{ github.ref_name }}/README.md - sed -i -E "s/source code-v(.*)--beta-green/source code-v${{ needs.Get-Version.outputs.version }}--beta-green/g" ./OpenClash/${{ github.ref_name }}/README.md - sed -i -E "s/New Release-v(.*)--beta-orange/New Release-v${{ needs.Get-Version.outputs.version }}--beta-orange/g" ./OpenClash/${{ github.ref_name }}/README.md + cp "./tmp/SDK/bin/ar71xx/packages/base/luci-app-openclash_${{ needs.Get-Version.outputs.version }}_all.ipk" "./OpenClash/${{ github.ref_name }}/luci-app-openclash_${{ needs.Get-Version.outputs.version }}_all.ipk" + cp "./tmp/SNAPSDK/bin/packages/x86_64/base/luci-app-openclash-${{ needs.Get-Version.outputs.version }}.apk" "./OpenClash/${{ github.ref_name }}/luci-app-openclash-${{ needs.Get-Version.outputs.version }}.apk" + sed -i -E "s/OpenClash\/tree\/v(.*)/OpenClash\/tree\/v${{ needs.Get-Version.outputs.version }}/g" ./OpenClash/${{ github.ref_name }}/README.md + sed -i -E "s/OpenClash\/releases\/tag\/v(.*)/OpenClash\/releases\/tag\/v${{ needs.Get-Version.outputs.version }}/g" ./OpenClash/${{ github.ref_name }}/README.md + sed -i -E "s/source code-v(.*)-green/source code-v${{ needs.Get-Version.outputs.version }}-green/g" ./OpenClash/${{ github.ref_name }}/README.md + sed -i -E "s/New Release-v(.*)-orange/New Release-v${{ needs.Get-Version.outputs.version }}-orange/g" ./OpenClash/${{ github.ref_name }}/README.md cd \OpenClash git config user.name 'github-actions[bot]' git config user.email 'github-actions[bot]@users.noreply.github.com' git add . - git commit -m "Auto Release: v${{ needs.Get-Version.outputs.version }}-beta" + git commit -m "Auto Release: v${{ needs.Get-Version.outputs.version }}" git push diff --git a/.github/workflows/master_release_sync.yml b/.github/workflows/master_release_sync.yml index 115bd8ac74..1d4f7dc1d6 100644 --- a/.github/workflows/master_release_sync.yml +++ b/.github/workflows/master_release_sync.yml @@ -47,7 +47,7 @@ jobs: run: | if [ -n "$(diff -r ./master/ ./dev/)" ]; then rm -rf ./master/README.md - rm -rf ./master/luci-app-openclash_* + rm -rf ./master/luci-app-openclash* rm -rf ./master/version cp -rf "./dev/." "./master/" git config user.name 'github-actions[bot]' diff --git a/luci-app-openclash/Makefile b/luci-app-openclash/Makefile index 1eb71bcd1d..ff104cd5e3 100644 --- a/luci-app-openclash/Makefile +++ b/luci-app-openclash/Makefile @@ -2,7 +2,6 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-openclash PKG_VERSION:=0.46.050 -PKG_RELEASE:=beta PKG_MAINTAINER:=vernesong PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) @@ -105,7 +104,7 @@ endef define Package/$(PKG_NAME)/postinst #!/bin/sh - sed -i "s/v0.00.00-beta/v$(PKG_VERSION)-beta/g" /www/luci-static/resources/openclash/img/version.svg >/dev/null 2>&1 + sed -i "s/v0.00.00/v$(PKG_VERSION)/g" /www/luci-static/resources/openclash/img/version.svg >/dev/null 2>&1 exit 0 endef @@ -122,8 +121,10 @@ endef define Package/$(PKG_NAME)/postrm #!/bin/sh - dnsmasqconfdir="$(uci -q get dhcp.@dnsmasq[0].confdir || echo '/tmp/dnsmasq.d')" - dnsmasqconfdir="${dnsmasqconfdir%*/}" + DEFAULT_DNSMASQ_CFGID=$(uci show dhcp.@dnsmasq[0] | awk -F '.' '{print $2}' | awk -F '=' '{print $1}' | head -1) + DNSMASQ_CONF_PATH=$(grep -l "^conf-dir=" "/tmp/etc/dnsmasq.conf.${DEFAULT_DNSMASQ_CFGID}") + DNSMASQ_CONF_DIR=$(grep '^conf-dir=' "$DNSMASQ_CONF_PATH" | cut -d'=' -f2 | head -n 1) + DNSMASQ_CONF_DIR=${DNSMASQ_CONF_DIR%*/} rm -rf /etc/openclash >/dev/null 2>&1 rm -rf /tmp/openclash.log >/dev/null 2>&1 rm -rf /tmp/openclash_start.log >/dev/null 2>&1 @@ -135,9 +136,9 @@ define Package/$(PKG_NAME)/postrm rm -rf /tmp/rule_providers_name >/dev/null 2>&1 rm -rf /tmp/clash_last_version >/dev/null 2>&1 rm -rf /usr/share/openclash/backup >/dev/null 2>&1 - rm -rf ${dnsmasqconfdir}/dnsmasq_openclash_custom_domain.conf >/dev/null 2>&1 - rm -rf ${dnsmasqconfdir}/dnsmasq_openclash_chnroute_pass.conf >/dev/null 2>&1 - rm -rf ${dnsmasqconfdir}/dnsmasq_openclash_chnroute6_pass.conf >/dev/null 2>&1 + rm -rf ${DNSMASQ_CONF_DIR}/dnsmasq_openclash_custom_domain.conf >/dev/null 2>&1 + rm -rf ${DNSMASQ_CONF_DIR}/dnsmasq_openclash_chnroute_pass.conf >/dev/null 2>&1 + rm -rf ${DNSMASQ_CONF_DIR}/dnsmasq_openclash_chnroute6_pass.conf >/dev/null 2>&1 rm -rf /tmp/dler* >/dev/null 2>&1 rm -rf /tmp/etc/openclash >/dev/null 2>&1 rm -rf /tmp/openclash_edit_file_name >/dev/null 2>&1 diff --git a/luci-app-openclash/luasrc/controller/openclash.lua b/luci-app-openclash/luasrc/controller/openclash.lua index d65ad4a439..7411895996 100644 --- a/luci-app-openclash/luasrc/controller/openclash.lua +++ b/luci-app-openclash/luasrc/controller/openclash.lua @@ -104,6 +104,8 @@ local device_arh = luci.sys.exec("uname -m |tr -d '\n'") if pcall(require, "luci.model.ipkg") then opkg = require "luci.model.ipkg" +else + opkg = nil end local core_path_mode = uci:get("openclash", "config", "small_flash_memory") @@ -216,7 +218,11 @@ local function coremodel() if opkg and opkg.info("libc") and opkg.info("libc")["libc"] then return opkg.info("libc")["libc"]["Architecture"] else - return luci.sys.exec("rm -f /var/lock/opkg.lock && opkg status libc 2>/dev/null |grep 'Architecture' |awk -F ': ' '{print $2}' 2>/dev/null") + if fs.access("/bin/opkg") then + return luci.sys.exec("rm -f /var/lock/opkg.lock && opkg status libc 2>/dev/null |grep 'Architecture' |awk -F ': ' '{print $2}' 2>/dev/null") + elseif fs.access("/usr/bin/apk") then + return luci.sys.exec("apk list libc |awk '{print $2}'") + end end end @@ -246,7 +252,11 @@ local function opcv() if opkg and opkg.info("luci-app-openclash") and opkg.info("luci-app-openclash")["luci-app-openclash"] then return "v" .. opkg.info("luci-app-openclash")["luci-app-openclash"]["Version"] else - return luci.sys.exec("rm -f /var/lock/opkg.lock && opkg status luci-app-openclash 2>/dev/null |grep 'Version' |awk -F 'Version: ' '{print \"v\"$2}'") + if fs.access("/bin/opkg") then + return luci.sys.exec("rm -f /var/lock/opkg.lock && opkg status luci-app-openclash 2>/dev/null |grep 'Version' |awk -F 'Version: ' '{print \"v\"$2}'") + elseif fs.access("/usr/bin/apk") then + return "v" .. luci.sys.exec("apk list luci-app-openclash |grep 'installed' | grep -oE '\\d+(\\.\\d+)*' | head -1") + end end end diff --git a/luci-app-openclash/po/zh-cn/openclash.zh-cn.po b/luci-app-openclash/po/zh-cn/openclash.zh-cn.po index d3fcca9444..8550816e81 100644 --- a/luci-app-openclash/po/zh-cn/openclash.zh-cn.po +++ b/luci-app-openclash/po/zh-cn/openclash.zh-cn.po @@ -1620,6 +1620,9 @@ msgstr "OpenClash 更新成功,即将进行重启!" msgid "OpenClash Update Failed, The File is Saved in /tmp/openclash.ipk, Please Try to Update Manually!" msgstr "OpenClash 更新失败,文件保存在 /tmp/openclash.ipk,请尝试手动更新!" +msgid "OpenClash Update Failed, The File is Saved in /tmp/openclash.apk, Please Try to Update Manually!" +msgstr "OpenClash 更新失败,文件保存在 /tmp/openclash.apk,请尝试手动更新!" + msgid "Download Failed, Please Check The Network or Try Again Later!" msgstr "下载失败,请检查网络或稍后再试!" diff --git a/luci-app-openclash/root/etc/init.d/openclash b/luci-app-openclash/root/etc/init.d/openclash index e88a3d2b44..24a0931ff6 100644 --- a/luci-app-openclash/root/etc/init.d/openclash +++ b/luci-app-openclash/root/etc/init.d/openclash @@ -466,7 +466,7 @@ do_run_file() #Some MIPS devices file system cound not use db source "/etc/openwrt_release" - [ "$small_flash_memory" == "1" ] || [ -n "$(echo $core_version |grep mips)" ] || [ -n "$(echo $DISTRIB_ARCH |grep mips)" ] || [ -n "$(opkg status libc 2>/dev/null |grep 'Architecture' |awk -F ': ' '{print $2}' |grep mips)" ] && mkdir -p /tmp/etc/openclash && CACHE_PATH="/tmp/etc/openclash/cache.db" + [ "$small_flash_memory" == "1" ] || [ -n "$(echo $core_version |grep mips)" ] || [ -n "$(echo $DISTRIB_ARCH |grep mips)" ] || [ -n "$(opkg status libc 2>/dev/null |grep 'Architecture' |awk -F ': ' '{print $2}' |grep mips)" ] || [ -n "$(apk list libc 2>/dev/null |grep mips)" ] && mkdir -p /tmp/etc/openclash && CACHE_PATH="/tmp/etc/openclash/cache.db" [ -f "/etc/openclash/geosite.dat" ] && { mv "/etc/openclash/geosite.dat" "/etc/openclash/GeoSite.dat" 2>/dev/null diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_debug.sh b/luci-app-openclash/root/usr/share/openclash/openclash_debug.sh index 3f46783d5f..4d25dd939a 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_debug.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_debug.sh @@ -31,11 +31,11 @@ en_mode=$(uci -q get openclash.config.en_mode) RAW_CONFIG_FILE=$(uci -q get openclash.config.config_path) CONFIG_FILE="/etc/openclash/$(uci -q get openclash.config.config_path |awk -F '/' '{print $5}' 2>/dev/null)" core_model=$(uci -q get openclash.config.core_version) -cpu_model=$(opkg status libc 2>/dev/null |grep 'Architecture' |awk -F ': ' '{print $2}' 2>/dev/null) +cpu_model=$(ipk_v libc 2>/dev/null |grep 'Architecture' |awk -F ': ' '{print $2}' 2>/dev/null) core_meta_version=$(/etc/openclash/core/clash_meta -v 2>/dev/null |awk -F ' ' '{print $3}' |head -1 2>/dev/null) servers_update=$(uci -q get openclash.config.servers_update) mix_proxies=$(uci -q get openclash.config.mix_proxies) -op_version=$(opkg status luci-app-openclash 2>/dev/null |grep 'Version' |awk -F 'Version: ' '{print "v"$2}') +op_version=$(ipk_v luci-app-openclash 2>/dev/null |grep 'Version' |awk -F 'Version: ' '{print "v"$2}') china_ip_route=$(uci -q get openclash.config.china_ip_route) common_ports=$(uci -q get openclash.config.common_ports) router_self_proxy=$(uci -q get openclash.config.router_self_proxy) @@ -80,6 +80,15 @@ ts_re() fi } +ipk_v() +{ + if [ -x "/bin/opkg" ]; then + echo $(opkg status "$1" 2>/dev/null |grep 'Version' |awk -F ': ' '{print $2}' 2>/dev/null) + elif [ -x "/usr/bin/apk" ]; then + echo $(apk list "$1" |grep 'installed' | grep -oE '\d+(\.\d+)*' | head -1) + fi +} + dns_re() { if [ "$1" = "1" ]; then @@ -107,7 +116,7 @@ cat >> "$DEBUG_LOG" <<-EOF 主机型号: $(cat /tmp/sysinfo/model 2>/dev/null) 固件版本: $(cat /usr/lib/os-release 2>/dev/null |grep OPENWRT_RELEASE 2>/dev/null |awk -F '"' '{print $2}' 2>/dev/null) -LuCI版本: $(opkg status luci 2>/dev/null |grep 'Version' |awk -F ': ' '{print $2}' 2>/dev/null) +LuCI版本: $(ipk_v "luci") 内核版本: $(uname -r 2>/dev/null) 处理器架构: $cpu_model @@ -123,36 +132,38 @@ cat >> "$DEBUG_LOG" <<-EOF #===================== 依赖检查 =====================# -dnsmasq-full: $(ts_re "$(opkg status dnsmasq-full 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -coreutils: $(ts_re "$(opkg status coreutils 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -coreutils-nohup: $(ts_re "$(opkg status coreutils-nohup 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -bash: $(ts_re "$(opkg status bash 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -curl: $(ts_re "$(opkg status curl 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -ca-certificates: $(ts_re "$(opkg status ca-certificates 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -ipset: $(ts_re "$(opkg status ipset 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -ip-full: $(ts_re "$(opkg status ip-full 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -libcap: $(ts_re "$(opkg status libcap 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -libcap-bin: $(ts_re "$(opkg status libcap-bin 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -ruby: $(ts_re "$(opkg status ruby 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -ruby-yaml: $(ts_re "$(opkg status ruby-yaml 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -ruby-psych: $(ts_re "$(opkg status ruby-psych 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -ruby-pstore: $(ts_re "$(opkg status ruby-pstore 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -kmod-tun(TUN模式): $(ts_re "$(opkg status kmod-tun 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -luci-compat(Luci >= 19.07): $(ts_re "$(opkg status luci-compat 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -kmod-inet-diag(PROCESS-NAME): $(ts_re "$(opkg status kmod-inet-diag 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -unzip: $(ts_re "$(opkg status unzip 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") +dnsmasq-full: $(ts_re "$(ipk_v "dnsmasq-full")") +dnsmasq-full(ipset): $(ts_re "$(dnsmasq --version |grep -v no-ipset |grep ipset)") +dnsmasq-full(nftset): $(ts_re "$(dnsmasq --version |grep nftset)") +coreutils: $(ts_re "$(ipk_v "coreutils")") +coreutils-nohup: $(ts_re "$(ipk_v "coreutils-nohup")") +bash: $(ts_re "$(ipk_v "bash")") +curl: $(ts_re "$(ipk_v "curl")") +ca-certificates: $(ts_re "$(ipk_v "ca-certificates")") +ipset: $(ts_re "$(ipk_v "ipset")") +ip-full: $(ts_re "$(ipk_v "ip-full")") +libcap: $(ts_re "$(ipk_v "libcap")") +libcap-bin: $(ts_re "$(ipk_v "libcap-bin")") +ruby: $(ts_re "$(ipk_v "ruby")") +ruby-yaml: $(ts_re "$(ipk_v "ruby-yaml")") +ruby-psych: $(ts_re "$(ipk_v "ruby-psych")") +ruby-pstore: $(ts_re "$(ipk_v "ruby-pstore")") +kmod-tun(TUN模式): $(ts_re "$(ipk_v "kmod-tun")") +luci-compat(Luci >= 19.07): $(ts_re "$(ipk_v "luci-compat")") +kmod-inet-diag(PROCESS-NAME): $(ts_re "$(ipk_v "kmod-inet-diag")") +unzip: $(ts_re "$(ipk_v "unzip")") EOF if [ -n "$(command -v fw4)" ]; then cat >> "$DEBUG_LOG" <<-EOF -kmod-nft-tproxy: $(ts_re "$(opkg status kmod-nft-tproxy 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") +kmod-nft-tproxy: $(ts_re "$(ipk_v kmod-nft-tproxy)") EOF else cat >> "$DEBUG_LOG" <<-EOF -iptables-mod-tproxy: $(ts_re "$(opkg status iptables-mod-tproxy 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -kmod-ipt-tproxy: $(ts_re "$(opkg status kmod-ipt-tproxy 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -iptables-mod-extra: $(ts_re "$(opkg status iptables-mod-extra 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -kmod-ipt-extra: $(ts_re "$(opkg status kmod-ipt-extra 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") -kmod-ipt-nat: $(ts_re "$(opkg status kmod-ipt-nat 2>/dev/null |grep 'Status' |awk -F ': ' '{print $2}' 2>/dev/null)") +iptables-mod-tproxy: $(ts_re "$(ipk_v "iptables-mod-tproxy")") +kmod-ipt-tproxy: $(ts_re "$(ipk_v "kmod-ipt-tproxy")") +iptables-mod-extra: $(ts_re "$(ipk_v "iptables-mod-extra")") +kmod-ipt-extra: $(ts_re "$(ipk_v "kmod-ipt-extra")") +kmod-ipt-nat: $(ts_re "$(ipk_v "kmod-ipt-nat")") EOF fi diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_history_get.sh b/luci-app-openclash/root/usr/share/openclash/openclash_history_get.sh index 9ec358dd8e..04e11731b6 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_history_get.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_history_get.sh @@ -48,7 +48,7 @@ if [ -z "$CONFIG_FILE" ] || [ ! -f "$CONFIG_FILE" ]; then fi if [ -n "$(pidof clash)" ] && [ -f "$CONFIG_FILE" ]; then - if [ "$small_flash_memory" == "1" ] || [ -n "$(echo $core_version |grep mips)" ] || [ -n "$(echo $DISTRIB_ARCH |grep mips)" ] || [ -n "$(opkg status libc 2>/dev/null |grep 'Architecture' |awk -F ': ' '{print $2}' |grep mips)" ]; then + if [ "$small_flash_memory" == "1" ] || [ -n "$(echo $core_version |grep mips)" ] || [ -n "$(echo $DISTRIB_ARCH |grep mips)" ] || [ -n "$(opkg status libc 2>/dev/null |grep 'Architecture' |awk -F ': ' '{print $2}' |grep mips)" ] || [ -n "$(apk list libc 2>/dev/null |grep mips)" ]; then CACHE_PATH="/tmp/etc/openclash/cache.db" if [ -f "$CACHE_PATH" ]; then cmp -s "$CACHE_PATH" "$HISTORY_PATH" diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_update.sh b/luci-app-openclash/root/usr/share/openclash/openclash_update.sh index 2300f51295..16496085ee 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_update.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_update.sh @@ -27,8 +27,12 @@ fi LAST_OPVER="/tmp/openclash_last_version" LAST_VER=$(sed -n 1p "$LAST_OPVER" 2>/dev/null |sed "s/^v//g" |tr -d "\n") -OP_CV=$(rm -f /var/lock/opkg.lock && opkg status luci-app-openclash 2>/dev/null |grep 'Version' |awk -F '-' '{print $1}' |awk -F 'Version: ' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null) -OP_LV=$(sed -n 1p "$LAST_OPVER" 2>/dev/null |awk -F '-' '{print $1}' |awk -F 'v' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null) +if [ -x "/bin/opkg" ]; then + OP_CV=$(rm -f /var/lock/opkg.lock && opkg status luci-app-openclash 2>/dev/null |grep 'Version' |awk -F 'Version: ' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null) +elif [ -x "/usr/bin/apk" ]; then + OP_CV=$(apk list luci-app-openclash |grep 'installed' | grep -oE '\d+(\.\d+)*' | head -1) +fi +OP_LV=$(sed -n 1p "$LAST_OPVER" 2>/dev/null |awk -F 'v' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null) RELEASE_BRANCH=$(uci -q get openclash.config.release_branch || echo "master") LOG_FILE="/tmp/openclash.log" github_address_mod=$(uci -q get openclash.config.github_address_mod || echo 0) @@ -60,30 +64,50 @@ if [ -n "$OP_CV" ] && [ -n "$OP_LV" ] && [ "$(expr "$OP_LV" \> "$OP_CV")" -eq 1 LOG_OUT "Start Downloading【OpenClash - v$LAST_VER】..." if [ "$github_address_mod" != "0" ]; then if [ "$github_address_mod" == "https://cdn.jsdelivr.net/" ] || [ "$github_address_mod" == "https://fastly.jsdelivr.net/" ] || [ "$github_address_mod" == "https://testingcf.jsdelivr.net/" ]; then - curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$github_address_mod"gh/vernesong/OpenClash@package/"$RELEASE_BRANCH"/luci-app-openclash_"$LAST_VER"_all.ipk -o /tmp/openclash.ipk 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/openclash.ipk" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" + if [ -x "/bin/opkg" ]; then + curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$github_address_mod"gh/vernesong/OpenClash@package/"$RELEASE_BRANCH"/luci-app-openclash_"$LAST_VER"_all.ipk -o /tmp/openclash.ipk 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/openclash.ipk" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" + elif [ -x "/usr/bin/apk" ]; then + curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$github_address_mod"gh/vernesong/OpenClash@package/"$RELEASE_BRANCH"/luci-app-openclash-"$LAST_VER".apk -o /tmp/openclash.apk 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/openclash.apk" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" + fi elif [ "$github_address_mod" == "https://raw.fastgit.org/" ]; then - curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 https://raw.fastgit.org/vernesong/OpenClash/package/"$RELEASE_BRANCH"/luci-app-openclash_"$LAST_VER"_all.ipk -o /tmp/openclash.ipk 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/openclash.ipk" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" + if [ -x "/bin/opkg" ]; then + curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 https://raw.fastgit.org/vernesong/OpenClash/package/"$RELEASE_BRANCH"/luci-app-openclash_"$LAST_VER"_all.ipk -o /tmp/openclash.ipk 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/openclash.ipk" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" + elif [ -x "/usr/bin/apk" ]; then + curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 https://raw.fastgit.org/vernesong/OpenClash/package/"$RELEASE_BRANCH"/luci-app-openclash-"$LAST_VER".apk -o /tmp/openclash.apk 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/openclash.apk" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" + fi else - curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$github_address_mod"https://raw.githubusercontent.com/vernesong/OpenClash/package/"$RELEASE_BRANCH"/luci-app-openclash_"$LAST_VER"_all.ipk -o /tmp/openclash.ipk 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/openclash.ipk" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" + if [ -x "/bin/opkg" ]; then + curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$github_address_mod"https://raw.githubusercontent.com/vernesong/OpenClash/package/"$RELEASE_BRANCH"/luci-app-openclash_"$LAST_VER"_all.ipk -o /tmp/openclash.ipk 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/openclash.ipk" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" + elif [ -x "/usr/bin/apk" ]; then + curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 "$github_address_mod"https://raw.githubusercontent.com/vernesong/OpenClash/package/"$RELEASE_BRANCH"/luci-app-openclash-"$LAST_VER".apk -o /tmp/openclash.apk 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/openclash.apk" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" + fi fi else - curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 https://raw.githubusercontent.com/vernesong/OpenClash/package/"$RELEASE_BRANCH"/luci-app-openclash_"$LAST_VER"_all.ipk -o /tmp/openclash.ipk 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/openclash.ipk" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" + if [ -x "/bin/opkg" ]; then + curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 https://raw.githubusercontent.com/vernesong/OpenClash/package/"$RELEASE_BRANCH"/luci-app-openclash_"$LAST_VER"_all.ipk -o /tmp/openclash.ipk 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/openclash.ipk" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" + elif [ -x "/usr/bin/apk" ]; then + curl -SsL --connect-timeout 30 -m 60 --speed-time 30 --speed-limit 1 --retry 2 https://raw.githubusercontent.com/vernesong/OpenClash/package/"$RELEASE_BRANCH"/luci-app-openclash-"$LAST_VER".apk -o /tmp/openclash.apk 2>&1 |sed ':a;N;$!ba; s/\n/ /g' | awk -v time="$(date "+%Y-%m-%d %H:%M:%S")" -v file="/tmp/openclash.apk" '{print time "【" file "】Download Failed:【"$0"】"}' >> "$LOG_FILE" + fi fi - if [ "${PIPESTATUS[0]}" -eq 0 ] && [ -s "/tmp/openclash.ipk" ]; then - LOG_OUT "【OpenClash - v$LAST_VER】Download Successful, Start Pre Update Test..." - - if [ -z "$(opkg install /tmp/openclash.ipk --noaction 2>/dev/null |grep 'Upgrading luci-app-openclash on root' 2>/dev/null)" ]; then - LOG_OUT "【OpenClash - v$LAST_VER】Pre Update Test Failed, The File is Saved in /tmp/openclash.ipk, Please Try to Update Manually!" - if [ "$(uci -q get openclash.config.config_reload)" -eq 1 ]; then - /etc/init.d/openclash restart >/dev/null 2>&1 & - else - SLOG_CLEAN + if [ "${PIPESTATUS[0]}" -eq 0 ]; then + if [ -x "/bin/opkg" ]; then + if [ -s "/tmp/openclash.ipk" ]; then + LOG_OUT "【OpenClash - v$LAST_VER】Download Successful, Start Pre Update Test..." + + if [ -z "$(opkg install /tmp/openclash.ipk --noaction 2>/dev/null |grep 'Upgrading luci-app-openclash on root' 2>/dev/null)" ]; then + LOG_OUT "【OpenClash - v$LAST_VER】Pre Update Test Failed, The File is Saved in /tmp/openclash.ipk, Please Try to Update Manually!" + if [ "$(uci -q get openclash.config.config_reload)" -eq 1 ]; then + /etc/init.d/openclash restart >/dev/null 2>&1 & + else + SLOG_CLEAN + fi + del_lock + exit 0 + fi fi - del_lock - exit 0 + LOG_OUT "【OpenClash - v$LAST_VER】Pre Update Test Passed, Ready to Update and Please Do not Refresh The Page and Other Operations..." fi - LOG_OUT "【OpenClash - v$LAST_VER】Pre Update Test Passed, Ready to Update and Please Do not Refresh The Page and Other Operations..." cat > /tmp/openclash_update.sh <<"EOF" #!/bin/sh START_LOG="/tmp/openclash_start.log" @@ -106,21 +130,45 @@ SLOG_CLEAN() LOG_OUT "Uninstalling The Old Version, Please Do not Refresh The Page or Do Other Operations..." uci -q set openclash.config.enable=0 uci -q commit openclash -opkg remove --force-depends --force-remove luci-app-openclash +if [ -x "/bin/opkg" ]; then + opkg remove --force-depends --force-remove luci-app-openclash +elif [ -x "/usr/bin/apk" ]; then + apk del luci-app-openclash +fi LOG_OUT "Installing The New Version, Please Do Not Refresh The Page or Do Other Operations..." -opkg install /tmp/openclash.ipk -if [ "$?" != "0" ] || [ -z "$(opkg info *openclash |grep Installed-Time)" ]; then +if [ -x "/bin/opkg" ]; then opkg install /tmp/openclash.ipk +elif [ -x "/usr/bin/apk" ]; then + apk add --allow-untrusted /tmp/openclash.apk fi -if [ "$?" == "0" ] && [ -n "$(opkg info *openclash |grep Installed-Time)" ]; then - rm -rf /tmp/openclash.ipk >/dev/null 2>&1 - LOG_OUT "OpenClash Update Successful, About To Restart!" - uci -q set openclash.config.enable=1 - uci -q commit openclash - /etc/init.d/openclash restart 2>/dev/null -else - LOG_OUT "OpenClash Update Failed, The File is Saved in /tmp/openclash.ipk, Please Try to Update Manually!" - SLOG_CLEAN +if [ -x "/bin/opkg" ]; then + if [ "$?" != "0" ] || [ -z "$(opkg info *openclash |grep Installed-Time)" ]; then + opkg install /tmp/openclash.ipk + fi + if [ "$?" == "0" ] && [ -n "$(opkg info *openclash |grep Installed-Time)" ]; then + rm -rf /tmp/openclash.ipk >/dev/null 2>&1 + LOG_OUT "OpenClash Update Successful, About To Restart!" + uci -q set openclash.config.enable=1 + uci -q commit openclash + /etc/init.d/openclash restart 2>/dev/null + else + LOG_OUT "OpenClash Update Failed, The File is Saved in /tmp/openclash.ipk, Please Try to Update Manually!" + SLOG_CLEAN + fi +elif [ -x "/usr/bin/apk" ]; then + if [ "$?" != "0" ] || [ -z "$(apk list luci-app-openclash |grep 'installed')" ]; then + apk add --allow-untrusted /tmp/openclash.apk + fi + if [ "$?" != "0" ] || [ -z "$(apk list luci-app-openclash |grep 'installed')" ]; then + rm -rf /tmp/openclash.apk >/dev/null 2>&1 + LOG_OUT "OpenClash Update Successful, About To Restart!" + uci -q set openclash.config.enable=1 + uci -q commit openclash + /etc/init.d/openclash restart 2>/dev/null + else + LOG_OUT "OpenClash Update Failed, The File is Saved in /tmp/openclash.apk, Please Try to Update Manually!" + SLOG_CLEAN + fi fi EOF chmod 4755 /tmp/openclash_update.sh @@ -130,6 +178,7 @@ EOF else LOG_OUT "【OpenClash - v$LAST_VER】Download Failed, Please Check The Network or Try Again Later!" rm -rf /tmp/openclash.ipk >/dev/null 2>&1 + rm -rf /tmp/openclash.apk >/dev/null 2>&1 if [ "$(uci -q get openclash.config.config_reload)" -eq 1 ]; then /etc/init.d/openclash restart >/dev/null 2>&1 & else diff --git a/luci-app-openclash/root/usr/share/openclash/openclash_version.sh b/luci-app-openclash/root/usr/share/openclash/openclash_version.sh index 163559af7c..028b166121 100644 --- a/luci-app-openclash/root/usr/share/openclash/openclash_version.sh +++ b/luci-app-openclash/root/usr/share/openclash/openclash_version.sh @@ -4,8 +4,12 @@ TIME=$(date "+%Y-%m-%d-%H") CHTIME=$(date "+%Y-%m-%d-%H" -r "/tmp/openclash_last_version" 2>/dev/null) LAST_OPVER="/tmp/openclash_last_version" RELEASE_BRANCH=$(uci -q get openclash.config.release_branch || echo "master") -OP_CV=$(rm -f /var/lock/opkg.lock && opkg status luci-app-openclash 2>/dev/null |grep 'Version' |awk -F '-' '{print $1}' |awk -F 'Version: ' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null) -OP_LV=$(sed -n 1p $LAST_OPVER 2>/dev/null |awk -F '-' '{print $1}' |awk -F 'v' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null) +if [ -x "/bin/opkg" ]; then + OP_CV=$(rm -f /var/lock/opkg.lock && opkg status luci-app-openclash 2>/dev/null |grep 'Version' |awk -F 'Version: ' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null) +elif [ -x "/usr/bin/apk" ]; then + OP_CV=$(apk list luci-app-openclash |grep 'installed' | grep -oE '\d+(\.\d+)*' | head -1) +fi +OP_LV=$(sed -n 1p $LAST_OPVER 2>/dev/null |awk -F 'v' '{print $2}' |awk -F '.' '{print $2$3}' 2>/dev/null) github_address_mod=$(uci -q get openclash.config.github_address_mod || echo 0) if [ -n "$1" ]; then github_address_mod="$1" diff --git a/luci-app-openclash/root/www/luci-static/resources/openclash/img/version.svg b/luci-app-openclash/root/www/luci-static/resources/openclash/img/version.svg index 4664f7519b..f8cfa888e3 100644 --- a/luci-app-openclash/root/www/luci-static/resources/openclash/img/version.svg +++ b/luci-app-openclash/root/www/luci-static/resources/openclash/img/version.svg @@ -1 +1 @@ -Current Version: v0.00.00-betaCurrent Versionv0.00.00-beta \ No newline at end of file +Current Version: v0.00.00Current Versionv0.00.00 \ No newline at end of file