mirror of
https://github.com/remittor/zapret-openwrt.git
synced 2026-01-27 12:50:35 +03:00
Compare commits
14 Commits
v0.7.20251
...
v0.8.20260
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d747201f9b | ||
|
|
9ead0e1d30 | ||
|
|
b37b35db80 | ||
|
|
9737a10e1f | ||
|
|
bc1af90349 | ||
|
|
11f632259e | ||
|
|
a215600415 | ||
|
|
28e6c466cb | ||
|
|
c72921f2fa | ||
|
|
55041b3b16 | ||
|
|
bf012b36bf | ||
|
|
9717bc8ff7 | ||
|
|
61e234ab12 | ||
|
|
c11ca1ca2e |
238
.github/workflows/build.yml
vendored
238
.github/workflows/build.yml
vendored
@@ -27,6 +27,7 @@ on:
|
||||
options:
|
||||
- true
|
||||
- false
|
||||
|
||||
push:
|
||||
tags:
|
||||
- v[0-9]+*
|
||||
@@ -36,17 +37,19 @@ env:
|
||||
FAKE_BUILD: ${{ github.event.inputs.fake_build == 'true' }}
|
||||
MAX_SPEED: ${{ github.event.inputs.max_speed != 'false' }}
|
||||
TAG_SUFFIX: ${{ github.event.inputs.fake_build == 'true' && '-fake' || github.event.inputs.test_build == 'true' && '-test' || '' }}
|
||||
REPO_NAME: zapret-openwrt
|
||||
REPO_URL: https://github.com/remittor/zapret-openwrt
|
||||
REPO_LNK: remittor/zapret-openwrt
|
||||
REPO_BRANCH: master
|
||||
BUILD_ROOT: ${{ github.workspace }}/builder
|
||||
PKGDIR: ${{ github.workspace }}/zapret-openwrt
|
||||
SDKDIR: /builder
|
||||
BUILD_DATE: unknown
|
||||
REPO_DATE: unknown
|
||||
LUCI_ARCH: aarch64_cortex-a53
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
outputs:
|
||||
tag: ${{ steps.gh.outputs.tag }}
|
||||
date: ${{ steps.gh.outputs.date }}
|
||||
@@ -103,14 +106,29 @@ jobs:
|
||||
fi
|
||||
echo "is_active=$is_active" >> $GITHUB_OUTPUT
|
||||
|
||||
var:
|
||||
runs-on: ubuntu-24.04
|
||||
outputs:
|
||||
IPK_BRANCH: ${{ steps.set.outputs.IPK_BRANCH }}
|
||||
APK_BRANCH: ${{ steps.set.outputs.APK_BRANCH }}
|
||||
XXX_BRANCH: ${{ steps.set.outputs.XXX_BRANCH }}
|
||||
steps:
|
||||
- id: set
|
||||
run: |
|
||||
echo "IPK_BRANCH=v24.10.5" >> "$GITHUB_OUTPUT"
|
||||
echo "APK_BRANCH=v25.12.0-rc2" >> "$GITHUB_OUTPUT"
|
||||
echo "XXX_BRANCH=SNAPSHOT" >> "$GITHUB_OUTPUT"
|
||||
|
||||
build:
|
||||
needs: check
|
||||
needs: [ check, var ]
|
||||
#if: needs.check.outputs.is_active == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
branch: [ openwrt-24.10, SNAPSHOT ]
|
||||
branch:
|
||||
- ${{ needs.var.outputs.IPK_BRANCH }}
|
||||
- ${{ needs.var.outputs.APK_BRANCH }}
|
||||
arch:
|
||||
- aarch64_cortex-a53
|
||||
- aarch64_cortex-a72
|
||||
@@ -141,33 +159,63 @@ jobs:
|
||||
isTestOrFake:
|
||||
- ${{ needs.check.outputs.test_build == 'true' || needs.check.outputs.fake_build == 'true' }}
|
||||
exclude:
|
||||
- branch: SNAPSHOT
|
||||
- branch: ${{ needs.var.outputs.APK_BRANCH }}
|
||||
arch: arm_cortex-a9_vfpv3-d16
|
||||
- branch: ${{ needs.var.outputs.APK_BRANCH }}
|
||||
arch: mips_4kec
|
||||
- { isTestOrFake: true }
|
||||
include:
|
||||
- branch: openwrt-24.10
|
||||
- branch: ${{ needs.var.outputs.IPK_BRANCH }}
|
||||
arch: x86_64
|
||||
- branch: openwrt-24.10
|
||||
- branch: ${{ needs.var.outputs.IPK_BRANCH }}
|
||||
arch: aarch64_cortex-a53
|
||||
- branch: SNAPSHOT
|
||||
- branch: ${{ needs.var.outputs.APK_BRANCH }}
|
||||
arch: aarch64_cortex-a53
|
||||
container:
|
||||
image: openwrt/sdk:${{ matrix.arch }}-${{ matrix.branch }}
|
||||
image: ghcr.io/openwrt/sdk:${{ matrix.arch }}-${{ matrix.branch }}
|
||||
options: --user root
|
||||
|
||||
outputs:
|
||||
pkgver: ${{ steps.build.outputs.pkgver }}
|
||||
pkgver: ${{ steps.prepare.outputs.pkgver }}
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: ${{ env.REPO_LNK }}
|
||||
path: zapret-openwrt
|
||||
path: ${{ env.REPO_NAME }}
|
||||
|
||||
- name: Fix SDK paths
|
||||
run: |
|
||||
mkdir -p $SDKDIR/shared-workdir
|
||||
rm -rf $SDKDIR/shared-workdir/build
|
||||
ln -sf $SDKDIR $SDKDIR/shared-workdir/build
|
||||
|
||||
- name: Initialization environment
|
||||
working-directory: ${{ env.SDKDIR }}
|
||||
env:
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
ARCH_TAG: ${{ matrix.arch }}
|
||||
BRANCH: ${{ matrix.branch }}
|
||||
FAKE_BUILD: ${{ env.FAKE_BUILD == 'true' || ( env.TEST_BUILD == 'true' && matrix.branch == needs.var.outputs.APK_BRANCH ) }}
|
||||
run: |
|
||||
if [ "$BRANCH" = "${{ needs.var.outputs.IPK_BRANCH }}" ]; then
|
||||
echo "PKGTYPE=ipk" >> $GITHUB_ENV
|
||||
else
|
||||
echo "PKGTYPE=apk" >> $GITHUB_ENV
|
||||
fi
|
||||
mkdir -p ./logs
|
||||
#echo ============== $SDKDIR ======================
|
||||
#ls -la $SDKDIR
|
||||
#echo ----------------------------------------------
|
||||
echo "FAKE_BUILD=$FAKE_BUILD" >> $GITHUB_ENV
|
||||
echo "ARCH_TAG=$ARCH_TAG" >> $GITHUB_ENV
|
||||
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
|
||||
echo "TZ=UTC" >> $GITHUB_ENV
|
||||
|
||||
- name: Setup OpenWrt SDK
|
||||
working-directory: /builder
|
||||
env:
|
||||
BRANCH: ${{ matrix.branch }}
|
||||
shell: bash
|
||||
if: false
|
||||
working-directory: ${{ env.SDKDIR }}
|
||||
run: |
|
||||
# gpg --verbose --recv-keys 0x1D53D1877742E911
|
||||
# gpg --verbose --import <(wget -qO- 'https://git.openwrt.org/?p=keyring.git;a=blob_plain;f=gpg/0x1D53D1877742E911.asc')
|
||||
@@ -178,120 +226,120 @@ jobs:
|
||||
sed -r -i 's/^rm.+//' setup.sh
|
||||
./setup.sh
|
||||
ls -lh
|
||||
if [ "$BRANCH" = "openwrt-24.10" ]; then
|
||||
echo "PKGTYPE=ipk" >> $GITHUB_ENV
|
||||
else
|
||||
echo "PKGTYPE=apk" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- name: Setup ccache
|
||||
if: false
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: '/builder/.ccache'
|
||||
path: ${{ env.SDKDIR }}/.ccache
|
||||
key: ccache-${{ matrix.arch }}-${{ matrix.branch }}-${{ github.run_id }}
|
||||
restore-keys: |
|
||||
ccache-${{ matrix.arch }}-${{ matrix.branch }}-
|
||||
|
||||
- name: Init packages
|
||||
id: init
|
||||
working-directory: '/builder'
|
||||
env:
|
||||
FAKE_BUILD: ${{ env.FAKE_BUILD == 'true' || ( env.TEST_BUILD == 'true' && matrix.branch == 'SNAPSHOT' ) }}
|
||||
BUILD_DATE: ${{ needs.check.outputs.build_date }}
|
||||
ARCH: ${{ matrix.arch }}
|
||||
BRANCH: ${{ matrix.branch }}
|
||||
SIGN_KEY: ${{ secrets.SIGN_PRIVATE_KEY }}
|
||||
CCACHE_DIR: '/builder/.ccache'
|
||||
shell: bash
|
||||
- name: Prepare packages
|
||||
id: prepare
|
||||
working-directory: ${{ env.SDKDIR }}
|
||||
run: |
|
||||
PKGDIR=$GITHUB_WORKSPACE/zapret-openwrt
|
||||
MKFN=$PKGDIR/luci-app-zapret/Makefile
|
||||
MKFN=$( ls -1 $PKGDIR/luci-app-zapret*/Makefile )
|
||||
PKGVER=$( grep -s '^PKG_VERSION:=.*' $MKFN | cut -d'=' -f2 )
|
||||
PKGREL=$( grep -s '^PKG_RELEASE:=.*' $MKFN | cut -d'=' -f2 )
|
||||
[ "$PKGREL" != "1" ] && PKGVER=$PKGVER-r$PKGREL
|
||||
echo "PKG_VERSION = $PKGVER"
|
||||
cp -vr $PKGDIR ./package/zapret-openwrt/
|
||||
|
||||
mv feeds.conf.default feeds.conf
|
||||
sed -i -e 's|base.*\.git|base https://github.com/openwrt/openwrt.git|' feeds.conf
|
||||
sed -i -e 's|packages.*\.git|packages https://github.com/openwrt/packages.git|' feeds.conf
|
||||
sed -i -e 's|luci.*\.git|luci https://github.com/openwrt/luci.git|' feeds.conf
|
||||
mkdir -p ./logs
|
||||
|
||||
if [ "$FAKE_BUILD" = "false" ]; then
|
||||
./scripts/feeds update base packages luci
|
||||
./scripts/feeds install -a
|
||||
fi
|
||||
echo "FAKE_BUILD=$FAKE_BUILD" >> $GITHUB_ENV
|
||||
cp -vr $PKGDIR ./package/$REPO_NAME/
|
||||
echo "PKGVER=$PKGVER" >> $GITHUB_ENV
|
||||
echo "pkgver=$PKGVER" >> $GITHUB_OUTPUT
|
||||
echo "status=success" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build packages
|
||||
id: build
|
||||
if: steps.init.outputs.status == 'success'
|
||||
working-directory: '/builder'
|
||||
env:
|
||||
BUILD_DATE: ${{ needs.check.outputs.build_date }}
|
||||
ARCH: ${{ matrix.arch }}
|
||||
BRANCH: ${{ matrix.branch }}
|
||||
SIGN_KEY: ${{ secrets.SIGN_PRIVATE_KEY }}
|
||||
CCACHE_DIR: '/builder/.ccache'
|
||||
shell: bash
|
||||
- name: Init packages
|
||||
id: init
|
||||
if: steps.prepare.outputs.status == 'success'
|
||||
working-directory: ${{ env.SDKDIR }}
|
||||
run: |
|
||||
MAKE_JOBS=$(($(nproc)+1))
|
||||
echo "$MAKE_JOBS thread compile"
|
||||
|
||||
if [ "$FAKE_BUILD" = "false" ]; then
|
||||
make defconfig
|
||||
sed -i 's/CONFIG_LUCI_JSMIN=y/CONFIG_LUCI_JSMIN=n/g' .config
|
||||
echo "------------- .config BEG -------------------"
|
||||
cat .config
|
||||
echo "------------- .config END -------------------"
|
||||
if [ "$ARCH" = "$LUCI_ARCH" ]; then
|
||||
PKGLIST=`echo package/zapret-openwrt/{zapret,zapret-mdig,zapret-ip2net,luci-app-zapret}/compile`
|
||||
else
|
||||
PKGLIST=`echo package/zapret-openwrt/{zapret,zapret-mdig,zapret-ip2net}/compile`
|
||||
fi
|
||||
if [ "$MAX_SPEED" = "false" ]; then
|
||||
make $PKGLIST V=s CONFIG_CCACHE=1 BUILD_LOG=1
|
||||
else
|
||||
make -j$MAKE_JOBS $PKGLIST CONFIG_CCACHE=1
|
||||
fi
|
||||
else
|
||||
OUT_DIR=./bin/packages/dev_x/base
|
||||
mkdir -p $OUT_DIR
|
||||
touch $OUT_DIR/zapret2_$PKGVER-$ARCH.$PKGTYPE
|
||||
touch $OUT_DIR/luci-app-zapret2_$PKGVER-all.$PKGTYPE
|
||||
mv feeds.conf.default feeds.conf
|
||||
sed -i -e 's|base.*\.git|base https://github.com/openwrt/openwrt.git|' feeds.conf
|
||||
sed -i -e 's|packages.*\.git|packages https://github.com/openwrt/packages.git|' feeds.conf
|
||||
sed -i -e 's|luci.*\.git|luci https://github.com/openwrt/luci.git|' feeds.conf
|
||||
./scripts/feeds update base packages luci
|
||||
./scripts/feeds install -a
|
||||
echo "status=success" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Init config
|
||||
id: config
|
||||
if: steps.init.outputs.status == 'success'
|
||||
working-directory: ${{ env.SDKDIR }}
|
||||
run: |
|
||||
make defconfig
|
||||
sed -i 's/CONFIG_LUCI_JSMIN=y/CONFIG_LUCI_JSMIN=n/g' .config
|
||||
echo "status=success" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Show config
|
||||
working-directory: ${{ env.SDKDIR }}
|
||||
run: |
|
||||
cat .config || echo "File .config not found"
|
||||
|
||||
- name: Build packages
|
||||
id: build
|
||||
if: steps.config.outputs.status == 'success' && env.FAKE_BUILD != 'true'
|
||||
working-directory: ${{ env.SDKDIR }}
|
||||
env:
|
||||
ARCH_TAG: ${{ matrix.arch }}
|
||||
run: |
|
||||
PKGLIST="package/zapret-openwrt/zapret2/compile"
|
||||
if [ "$ARCH_TAG" = "$LUCI_ARCH" ]; then
|
||||
PKGLIST="$PKGLIST package/zapret-openwrt/luci-app-zapret2/compile"
|
||||
fi
|
||||
|
||||
MAKE_JOBS=$(nproc)
|
||||
echo "$MAKE_JOBS thread compile"
|
||||
if [ "$MAX_SPEED" != "true" ]; then
|
||||
make $PKGLIST V=sc BUILD_LOG=1
|
||||
else
|
||||
make $PKGLIST -j$MAKE_JOBS
|
||||
fi
|
||||
echo "status=success" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build packages (FAKE)
|
||||
id: build_fake
|
||||
if: env.FAKE_BUILD == 'true'
|
||||
working-directory: ${{ env.SDKDIR }}
|
||||
env:
|
||||
ARCH_TAG: ${{ matrix.arch }}
|
||||
run: |
|
||||
OUT_DIR=./bin/packages/dev_x/base
|
||||
mkdir -p $OUT_DIR
|
||||
touch $OUT_DIR/zapret2_$PKGVER-$ARCH_TAG.$PKGTYPE
|
||||
touch $OUT_DIR/luci-app-zapret2_$PKGVER-all.$PKGTYPE
|
||||
echo "status=success" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Install packages
|
||||
id: install
|
||||
if: steps.build.outputs.status == 'success' || steps.build_fake.outputs.status == 'success'
|
||||
working-directory: ${{ env.SDKDIR }}
|
||||
env:
|
||||
ARCH_TAG: ${{ matrix.arch }}
|
||||
SIGN_KEY: ${{ secrets.SIGN_PRIVATE_KEY }}
|
||||
run: |
|
||||
find ./bin/packages/*/base -type f ! -regex ".*\(zapret2\).*\.[ai]pk$" -delete
|
||||
|
||||
#echo ">>>>>>> build a repository index to make the output directory usable as local OPKG source"
|
||||
#ln -s `which usign` staging_dir/host/bin/usign
|
||||
#echo "$SIGN_KEY" | base64 -d > key-build
|
||||
#make package/index
|
||||
|
||||
OUTDIR=$GITHUB_WORKSPACE/$PKGTYPE-$ARCH
|
||||
OUTDIR=$GITHUB_WORKSPACE/$PKGTYPE-$ARCH_TAG
|
||||
mkdir -p $OUTDIR
|
||||
cp -R ./bin/packages/*/base/. $OUTDIR/
|
||||
./staging_dir/host/bin/ccache --max-size=10M --show-stats
|
||||
|
||||
echo "OUTDIR=$OUTDIR" >> $GITHUB_ENV
|
||||
echo "pkgver=$PKGVER" >> $GITHUB_OUTPUT
|
||||
echo "status=success" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Compress build logs
|
||||
if: always()
|
||||
env:
|
||||
ARCH: ${{ matrix.arch }}
|
||||
ARCH_TAG: ${{ matrix.arch }}
|
||||
BRANCH: ${{ matrix.branch }}
|
||||
LOGS_DIR: '/builder/logs'
|
||||
LOGS_DIR: ${{ env.SDKDIR }}/logs
|
||||
run: |
|
||||
tar -cJvf logs-$BRANCH-$ARCH.tar.xz $LOGS_DIR
|
||||
tar -cJvf logs-$BRANCH-$ARCH_TAG.tar.xz $LOGS_DIR
|
||||
|
||||
- name: Upload packages
|
||||
if: steps.build.outcome == 'success'
|
||||
if: steps.install.outcome == 'success'
|
||||
uses: actions/upload-artifact@main
|
||||
with:
|
||||
path: ${{ env.OUTDIR }}
|
||||
@@ -309,7 +357,7 @@ jobs:
|
||||
needs: [ check, build ]
|
||||
permissions:
|
||||
contents: write
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-zapret2
|
||||
PKG_VERSION:=0.7.20251227
|
||||
PKG_VERSION:=0.8.20260109
|
||||
PKG_RELEASE:=1
|
||||
PKG_LICENSE:=MIT
|
||||
PKG_MAINTAINER:=remittor <https://github.com/remittor>
|
||||
@@ -171,9 +171,13 @@ return baseclass.extend({
|
||||
this.setStage(999);
|
||||
}
|
||||
} catch (e) {
|
||||
if (e.message?.includes('RPC call to file/exec failed with error -32000: Object not found')) {
|
||||
console.warn('WARN: installUpdates: ' + e.message);
|
||||
return; // goto next timer iteration
|
||||
}
|
||||
clearInterval(timer);
|
||||
this.appendLog('ERROR: installUpdates: ' + e.message);
|
||||
this.appendLog('ERROR: installUpdates: ' + e.stack?.trim().split('\n').pop());
|
||||
this.appendLog('ERROR: installUpdates: ' + e.stack?.trim().split('\n')[0]);
|
||||
this.setStage(999);
|
||||
} finally {
|
||||
timerBusy = false;
|
||||
@@ -1,45 +0,0 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=zapret2-ip2net
|
||||
PKG_VERSION:=0.7.20251227
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_MAINTAINER:=bol-van
|
||||
PKG_LICENSE:=MIT
|
||||
PKG_LICENSE_FILES:=docs/LICENSE.txt
|
||||
|
||||
PKG_SOURCE_URL:=https://github.com/bol-van/zapret2.git
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=6a520f508a6b480e79f4d4d50f61b18bba660021
|
||||
PKG_SOURCE_DATE:=2025-12-27
|
||||
|
||||
#PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
#PKG_SOURCE_URL:=https://github.com/bol-van/zapret2/archive/refs/tags/v$(PKG_VERSION).tar.gz?
|
||||
#PKG_HASH:=skip
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
#TAR_OPTIONS:=--strip-components 1 $(TAR_OPTIONS)
|
||||
#TAR_CMD=$(HOST_TAR) -C $(1) $(TAR_OPTIONS)
|
||||
|
||||
MAKE_PATH:=ip2net
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=ip2net
|
||||
SUBMENU:=Zapret2
|
||||
DEPENDS:=+zlib +zapret2
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
$(Build/Prepare/Default)
|
||||
rm -f $(PKG_BUILD_DIR)/$(MAKE_PATH)/ip2net
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/opt/zapret2/ip2net
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(MAKE_PATH)/ip2net $(1)/opt/zapret2/ip2net/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||
@@ -1,45 +0,0 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=zapret2-mdig
|
||||
PKG_VERSION:=0.7.20251227
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_MAINTAINER:=bol-van
|
||||
PKG_LICENSE:=MIT
|
||||
PKG_LICENSE_FILES:=docs/LICENSE.txt
|
||||
|
||||
PKG_SOURCE_URL:=https://github.com/bol-van/zapret2.git
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=6a520f508a6b480e79f4d4d50f61b18bba660021
|
||||
PKG_SOURCE_DATE:=2025-12-27
|
||||
|
||||
#PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
#PKG_SOURCE_URL:=https://github.com/bol-van/zapret2/archive/refs/tags/v$(PKG_VERSION).tar.gz?
|
||||
#PKG_HASH:=skip
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
#TAR_OPTIONS:=--strip-components 1 $(TAR_OPTIONS)
|
||||
#TAR_CMD=$(HOST_TAR) -C $(1) $(TAR_OPTIONS)
|
||||
|
||||
MAKE_PATH:=mdig
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=mdig
|
||||
SUBMENU:=Zapret2
|
||||
DEPENDS:=+zlib +zapret2
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
$(Build/Prepare/Default)
|
||||
rm -f $(PKG_BUILD_DIR)/$(MAKE_PATH)/mdig
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/opt/zapret2/mdig
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(MAKE_PATH)/mdig $(1)/opt/zapret2/mdig/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||
@@ -1,18 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Copyright (c) 2024 remittor
|
||||
|
||||
. /opt/zapret2/comfunc.sh
|
||||
|
||||
# create empty txt files into ipset directory
|
||||
[ ! -f "/opt/zapret2/ipset/zapret-hosts-google.txt" ] && touch "/opt/zapret2/ipset/zapret-hosts-google.txt"
|
||||
#[ ! -f "/opt/zapret2/ipset/zapret-hosts-auto.txt" ] && touch "/opt/zapret2/ipset/zapret-hosts-auto.txt"
|
||||
[ ! -f "/opt/zapret2/ipset/zapret-hosts-user.txt" ] && touch "/opt/zapret2/ipset/zapret-hosts-user.txt"
|
||||
[ ! -f "/opt/zapret2/ipset/zapret-hosts-user-ipban.txt" ] && touch "/opt/zapret2/ipset/zapret-hosts-user-ipban.txt"
|
||||
#[ ! -f "/opt/zapret2/ipset/zapret-ip.txt" ] && touch "/opt/zapret2/ipset/zapret-ip.txt"
|
||||
[ ! -f "/opt/zapret2/ipset/zapret-ip-user.txt" ] && touch "/opt/zapret2/ipset/zapret-ip-user.txt"
|
||||
[ ! -f "/opt/zapret2/ipset/zapret-ip-user-exclude.txt" ] && touch "/opt/zapret2/ipset/zapret-ip-user-exclude.txt"
|
||||
[ ! -f "/opt/zapret2/ipset/zapret-ip-user-ipban.txt" ] && touch "/opt/zapret2/ipset/zapret-ip-user-ipban.txt"
|
||||
|
||||
# create or merge uci-config
|
||||
$ZAPRET_BASE/renew-cfg.sh
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=zapret2
|
||||
PKG_VERSION:=0.7.20251227
|
||||
PKG_VERSION:=0.8.20260109
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_MAINTAINER:=bol-van
|
||||
@@ -14,8 +14,8 @@ PKG_LICENSE_FILES:=docs/LICENSE.txt
|
||||
|
||||
PKG_SOURCE_URL:=https://github.com/bol-van/zapret2.git
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=6a520f508a6b480e79f4d4d50f61b18bba660021
|
||||
PKG_SOURCE_DATE:=2025-12-27
|
||||
PKG_SOURCE_VERSION:=8e6387a6dfdaa227b50a34f4beb1d5ec2a770d54
|
||||
PKG_SOURCE_DATE:=2026-01-09
|
||||
|
||||
#PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
#PKG_SOURCE_URL:=https://github.com/bol-van/zapret2/archive/refs/tags/v$(PKG_VERSION).tar.gz?
|
||||
@@ -58,13 +58,17 @@ endef
|
||||
define Build/Prepare
|
||||
$(Build/Prepare/Default)
|
||||
rm -f $(PKG_BUILD_DIR)/$(MAKE_PATH)/nfqws2
|
||||
rm -f $(PKG_BUILD_DIR)/ip2net/ip2net
|
||||
rm -f $(PKG_BUILD_DIR)/mdig/mdig
|
||||
endef
|
||||
|
||||
#define Build/Configure
|
||||
#endef
|
||||
|
||||
define Build/Compile
|
||||
$(MAKE) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) $(TARGET_CONFIGURE_OPTS) LUA_CFLAGS="$(LUA_INCLUDE)" LUA_LIB="$(LUA_LIBRARY)"
|
||||
$(MAKE) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) $(TARGET_CONFIGURE_OPTS) LUA_JIT=$(LUA_JIT) LUA_CFLAGS="$(LUA_INCLUDE)" LUA_LIB="$(LUA_LIBRARY)"
|
||||
$(MAKE) -C $(PKG_BUILD_DIR)/ip2net $(TARGET_CONFIGURE_OPTS)
|
||||
$(MAKE) -C $(PKG_BUILD_DIR)/mdig $(TARGET_CONFIGURE_OPTS)
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/conffiles
|
||||
@@ -78,6 +82,10 @@ define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/opt/zapret2
|
||||
$(INSTALL_DIR) $(1)/opt/zapret2/$(MAKE_PATH)
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(MAKE_PATH)/nfqws2 $(1)/opt/zapret2/$(MAKE_PATH)/
|
||||
$(INSTALL_DIR) $(1)/opt/zapret2/ip2net
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ip2net/ip2net $(1)/opt/zapret2/ip2net/
|
||||
$(INSTALL_DIR) $(1)/opt/zapret2/mdig
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/mdig/mdig $(1)/opt/zapret2/mdig/
|
||||
$(INSTALL_DIR) $(1)/opt/zapret2/common
|
||||
$(CP) $(PKG_BUILD_DIR)/common/* $(1)/opt/zapret2/common/
|
||||
$(INSTALL_DIR) $(1)/opt/zapret2/lua
|
||||
@@ -130,6 +138,9 @@ define Package/$(PKG_NAME)/install
|
||||
chmod 644 $(1)/opt/zapret2/init.d/openwrt/custom.d/*.sh
|
||||
chmod 644 $(1)/opt/zapret2/config.default
|
||||
chmod 755 $(1)/opt/zapret2/*.sh
|
||||
chmod 755 $(1)/opt/zapret2/$(MAKE_PATH)/*
|
||||
chmod 755 $(1)/opt/zapret2/ip2net/*
|
||||
chmod 755 $(1)/opt/zapret2/mdig/*
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/preinst
|
||||
@@ -7,13 +7,16 @@ ZAPRET_BASE=/opt/zapret2
|
||||
ZAPRET_INITD=/etc/init.d/zapret2
|
||||
ZAPRET_ORIG_INITD="$ZAPRET_BASE/init.d/openwrt/zapret2"
|
||||
|
||||
ZAP_LOG_TAG=ZAPRET2
|
||||
|
||||
ZAPRET_CONFIG="$ZAPRET_BASE/config"
|
||||
ZAPRET_CONFIG_NEW="$ZAPRET_BASE/config.new"
|
||||
ZAPRET_CONFIG_DEF="$ZAPRET_BASE/config.default"
|
||||
|
||||
ZAPRET_CFG=/etc/config/zapret2
|
||||
ZAPRET_CFG_NAME=zapret2
|
||||
ZAPRET_CFG_SEC_NAME="$( uci -q get $ZAPRET_CFG_NAME.config )"
|
||||
ZAPRET_CFG_SEC=$ZAPRET_CFG_NAME.config
|
||||
ZAPRET_CFG_SEC_NAME="$( uci -q get $ZAPRET_CFG_SEC )"
|
||||
|
||||
. $ZAPRET_BASE/def-cfg.sh
|
||||
|
||||
@@ -148,7 +151,7 @@ function merge_cfg_with_def_values
|
||||
local cfgname=${1:-$ZAPRET_CFG_NAME}
|
||||
local force=$2
|
||||
local cfgfile=/etc/config/$cfgname
|
||||
local NEWCFGNAME="zapret2-default"
|
||||
local NEWCFGNAME="$ZAPRET_CFG_NAME-default"
|
||||
local NEWCFGFILE="/etc/config/$NEWCFGNAME"
|
||||
|
||||
local cfg_sec_name="$( uci -q get $ZAPRET_CFG_NAME.config )"
|
||||
@@ -168,7 +171,7 @@ function merge_cfg_with_def_values
|
||||
function remove_cron_task_logs
|
||||
{
|
||||
if [ -f "$CRONTAB_FILE" ]; then
|
||||
sed -i "/-name 'zapret2+\*.log' -size +/d" "$CRONTAB_FILE"
|
||||
sed -i "/-name '$ZAPRET_CFG_NAME+\*.log' -size +/d" "$CRONTAB_FILE"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -176,8 +179,8 @@ function insert_cron_task_logs
|
||||
{
|
||||
[ ! -f "$CRONTAB_FILE" ] && touch "$CRONTAB_FILE"
|
||||
[ ! -f "$CRONTAB_FILE" ] && return 1
|
||||
if ! grep -q -e "-name 'zapret2\*\.log' -size \+" "$CRONTAB_FILE"; then
|
||||
echo "*/2 * * * * /usr/bin/find /tmp -maxdepth 1 -type f -name 'zapret2+*.log' -size +2600k -exec rm -f {} \;" >> "$CRONTAB_FILE"
|
||||
if ! grep -q -e "-name '$ZAPRET_CFG_NAME\*\.log' -size \+" "$CRONTAB_FILE"; then
|
||||
echo "*/2 * * * * /usr/bin/find /tmp -maxdepth 1 -type f -name '$ZAPRET_CFG_NAME+*.log' -size +2600k -exec rm -f {} \;" >> "$CRONTAB_FILE"
|
||||
/etc/init.d/cron restart 2> /dev/null
|
||||
fi
|
||||
return 0
|
||||
@@ -190,7 +193,7 @@ function init_before_start
|
||||
[ ! -f "$HOSTLIST_FN" ] && touch "$HOSTLIST_FN"
|
||||
chmod 644 $ZAPRET_BASE/ipset/*.txt
|
||||
chmod 666 $ZAPRET_BASE/ipset/*.log
|
||||
rm -f /tmp/zapret2+*.log
|
||||
rm -f /tmp/$ZAPRET_CFG_NAME+*.log
|
||||
#*/
|
||||
if [ "$DAEMON_LOG_ENABLE" = "1" ]; then
|
||||
insert_cron_task_logs
|
||||
@@ -10,14 +10,14 @@ SCRIPT_FILENAME=$1
|
||||
. /opt/zapret2/comfunc.sh
|
||||
|
||||
if ! is_valid_config ; then
|
||||
logger -p err -t ZAPRET2 "Wrong main config: $ZAPRET_CONFIG"
|
||||
logger -p err -t $ZAP_LOG_TAG "Wrong main config: $ZAPRET_CONFIG"
|
||||
exit 91
|
||||
fi
|
||||
|
||||
. $ZAPRET_ORIG_INITD
|
||||
|
||||
EXEDIR=/opt/zapret2
|
||||
ZAPRET_BASE=/opt/zapret2
|
||||
EXEDIR=/opt/$ZAPRET_CFG_NAME
|
||||
ZAPRET_BASE=/opt/$ZAPRET_CFG_NAME
|
||||
|
||||
is_run_on_boot && IS_RUN_ON_BOOT=1 || IS_RUN_ON_BOOT=0
|
||||
|
||||
@@ -30,13 +30,13 @@ function enable
|
||||
if [ -n "$ZAPRET_CFG_SEC_NAME" ]; then
|
||||
run_on_boot=$( get_run_on_boot_option )
|
||||
if [ $run_on_boot != 1 ]; then
|
||||
logger -p notice -t ZAPRET2 "Attempt to enable service, but service blocked!"
|
||||
logger -p notice -t $ZAP_LOG_TAG "Attempt to enable service, but service blocked!"
|
||||
return 61
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [ -n "$ZAPRET_CFG_SEC_NAME" ]; then
|
||||
uci set $ZAPRET_CFG_NAME.config.run_on_boot=1
|
||||
uci set $ZAPRET_CFG_SEC.run_on_boot=1
|
||||
uci commit
|
||||
fi
|
||||
/bin/sh /etc/rc.common $ZAPRET_ORIG_INITD enable
|
||||
@@ -49,7 +49,7 @@ function enabled
|
||||
run_on_boot=$( get_run_on_boot_option )
|
||||
if [ $run_on_boot != 1 ]; then
|
||||
if [ "$IS_RUN_ON_BOOT" = "1" ]; then
|
||||
logger -p notice -t ZAPRET2 "Service is blocked!"
|
||||
logger -p notice -t $ZAP_LOG_TAG "Service is blocked!"
|
||||
fi
|
||||
return 61
|
||||
fi
|
||||
@@ -65,7 +65,7 @@ function boot
|
||||
if [ -n "$ZAPRET_CFG_SEC_NAME" ]; then
|
||||
run_on_boot=$( get_run_on_boot_option )
|
||||
if [ $run_on_boot != 1 ]; then
|
||||
logger -p notice -t ZAPRET2 "Attempt to run service on boot! Service is blocked!"
|
||||
logger -p notice -t $ZAP_LOG_TAG "Attempt to run service on boot! Service is blocked!"
|
||||
return 61
|
||||
fi
|
||||
fi
|
||||
@@ -1,7 +1,9 @@
|
||||
#!/bin/sh
|
||||
# Copyright (c) 2024 remittor
|
||||
|
||||
. /opt/zapret2/comfunc.sh
|
||||
EXE_DIR=$(cd "$(dirname "$0")" 2>/dev/null || exit 1; pwd)
|
||||
|
||||
. $EXE_DIR/comfunc.sh
|
||||
|
||||
merge_cfg_with_def_values
|
||||
|
||||
@@ -12,5 +14,5 @@ CONFIGS_SYNC=0
|
||||
|
||||
if [ "$CONFIGS_SYNC" = "1" ]; then
|
||||
# renew main config
|
||||
/opt/zapret2/sync_config.sh
|
||||
$ZAPRET_BASE/sync_config.sh
|
||||
fi
|
||||
@@ -1,9 +1,11 @@
|
||||
#!/bin/sh
|
||||
# Copyright (c) 2024 remittor
|
||||
|
||||
. /opt/zapret2/comfunc.sh
|
||||
EXE_DIR=$(cd "$(dirname "$0")" 2>/dev/null || exit 1; pwd)
|
||||
|
||||
cfg_run_on_boot="$( uci -q get $ZAPRET_CFG_NAME.config.run_on_boot )"
|
||||
. $EXE_DIR/comfunc.sh
|
||||
|
||||
cfg_run_on_boot="$( uci -q get $ZAPRET_CFG_SEC.run_on_boot )"
|
||||
|
||||
opt_flags=${1:--}
|
||||
opt_strat=$2
|
||||
@@ -15,7 +17,7 @@ fi
|
||||
create_default_cfg "$opt_flags" "$opt_strat"
|
||||
|
||||
if [ "$cfg_run_on_boot" = "1" ]; then
|
||||
uci set $ZAPRET_CFG_NAME.config.run_on_boot=1
|
||||
uci set $ZAPRET_CFG_SEC.run_on_boot=1
|
||||
uci commit
|
||||
fi
|
||||
|
||||
@@ -29,5 +31,5 @@ fi
|
||||
|
||||
if [ "$ZAPRET_SYNC_CONFIG" = "1" ]; then
|
||||
# renew main config
|
||||
/opt/zapret2/sync_config.sh
|
||||
$ZAPRET_BASE/sync_config.sh
|
||||
fi
|
||||
@@ -1,7 +1,9 @@
|
||||
#!/bin/sh
|
||||
# Copyright (c) 2024 remittor
|
||||
|
||||
. /opt/zapret2/comfunc.sh
|
||||
EXE_DIR=$(cd "$(dirname "$0")" 2>/dev/null || exit 1; pwd)
|
||||
|
||||
. $EXE_DIR/comfunc.sh
|
||||
|
||||
function uncomment_param
|
||||
{
|
||||
@@ -41,16 +43,22 @@ function sync_param
|
||||
{
|
||||
local param=$1
|
||||
local vtype=$2
|
||||
local value="$( uci -q get zapret2.config.$param )"
|
||||
local value="$( uci -q get $ZAPRET_CFG_SEC.$param )"
|
||||
uncomment_param $param
|
||||
append_param $param
|
||||
local TAB="$( echo -n -e '\t' )"
|
||||
if [ "$value" = "$TAB" ]; then
|
||||
value=""
|
||||
fi
|
||||
if [ "$param" = "NFQWS_PORTS_TCP_KEEPALIVE" -o "$param" = "NFQWS_PORTS_UDP_KEEPALIVE" ]; then
|
||||
[ "$value" = "0" ] && value=""
|
||||
fi
|
||||
if [ "$param" = "NFQWS2_PORTS_TCP_KEEPALIVE" -o "$param" = "NFQWS2_PORTS_UDP_KEEPALIVE" ]; then
|
||||
[ "$value" = "0" ] && value=""
|
||||
fi
|
||||
if [ "$param" = "NFQWS_OPT" -a "$value" != "" ]; then
|
||||
value=$( echo -n "$value" | sed '/^#/d' )
|
||||
fi
|
||||
if [ "$param" = "NFQWS2_OPT" -a "$value" != "" ]; then
|
||||
value=$( echo -n "$value" | sed '/^#/d' )
|
||||
fi
|
||||
@@ -90,21 +98,42 @@ sync_param DAEMON_LOG_FILE str
|
||||
sync_param AUTOHOSTLIST_RETRANS_THRESHOLD
|
||||
sync_param AUTOHOSTLIST_FAIL_THRESHOLD
|
||||
sync_param AUTOHOSTLIST_FAIL_TIME
|
||||
if [ $ZAPRET_CFG_NAME = "zapret2" ]; then
|
||||
sync_param AUTOHOSTLIST_INCOMING_MAXSEQ
|
||||
sync_param AUTOHOSTLIST_RETRANS_MAXSEQ
|
||||
sync_param AUTOHOSTLIST_UDP_IN
|
||||
sync_param AUTOHOSTLIST_UDP_OUT
|
||||
fi
|
||||
sync_param AUTOHOSTLIST_DEBUGLOG
|
||||
|
||||
sync_param NFQWS2_ENABLE
|
||||
sync_param DESYNC_MARK
|
||||
sync_param DESYNC_MARK_POSTNAT
|
||||
sync_param FILTER_MARK str
|
||||
sync_param NFQWS2_PORTS_TCP str
|
||||
sync_param NFQWS2_PORTS_UDP str
|
||||
sync_param NFQWS2_TCP_PKT_OUT str
|
||||
sync_param NFQWS2_TCP_PKT_IN str
|
||||
sync_param NFQWS2_UDP_PKT_OUT str
|
||||
sync_param NFQWS2_UDP_PKT_IN str
|
||||
sync_param NFQWS2_PORTS_TCP_KEEPALIVE str
|
||||
sync_param NFQWS2_PORTS_UDP_KEEPALIVE str
|
||||
sync_param NFQWS2_OPT str
|
||||
|
||||
if [ $ZAPRET_CFG_NAME = "zapret" ]; then
|
||||
sync_param NFQWS_ENABLE
|
||||
sync_param NFQWS_PORTS_TCP str
|
||||
sync_param NFQWS_PORTS_UDP str
|
||||
sync_param NFQWS_TCP_PKT_OUT str
|
||||
sync_param NFQWS_TCP_PKT_IN str
|
||||
sync_param NFQWS_UDP_PKT_OUT str
|
||||
sync_param NFQWS_UDP_PKT_IN str
|
||||
sync_param NFQWS_PORTS_TCP_KEEPALIVE str
|
||||
sync_param NFQWS_PORTS_UDP_KEEPALIVE str
|
||||
sync_param NFQWS_OPT str
|
||||
fi
|
||||
if [ $ZAPRET_CFG_NAME = "zapret2" ]; then
|
||||
sync_param NFQWS2_ENABLE
|
||||
sync_param NFQWS2_PORTS_TCP str
|
||||
sync_param NFQWS2_PORTS_UDP str
|
||||
sync_param NFQWS2_TCP_PKT_OUT str
|
||||
sync_param NFQWS2_TCP_PKT_IN str
|
||||
sync_param NFQWS2_UDP_PKT_OUT str
|
||||
sync_param NFQWS2_UDP_PKT_IN str
|
||||
sync_param NFQWS2_PORTS_TCP_KEEPALIVE str
|
||||
sync_param NFQWS2_PORTS_UDP_KEEPALIVE str
|
||||
sync_param NFQWS2_OPT str
|
||||
fi
|
||||
|
||||
ZAPRET_CONFIG="$ZAPRET_CONFIG__SAVED"
|
||||
|
||||
18
zapret2/uci-def-cfg.sh
Executable file
18
zapret2/uci-def-cfg.sh
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
# Copyright (c) 2024 remittor
|
||||
|
||||
. /opt/zapret2/comfunc.sh
|
||||
|
||||
# create empty txt files into ipset directory
|
||||
[ ! -f "$ZAPRET_BASE/ipset/zapret-hosts-google.txt" ] && touch "$ZAPRET_BASE/ipset/zapret-hosts-google.txt"
|
||||
#[ ! -f "$ZAPRET_BASE/ipset/zapret-hosts-auto.txt" ] && touch "$ZAPRET_BASE/ipset/zapret-hosts-auto.txt"
|
||||
[ ! -f "$ZAPRET_BASE/ipset/zapret-hosts-user.txt" ] && touch "$ZAPRET_BASE/ipset/zapret-hosts-user.txt"
|
||||
[ ! -f "$ZAPRET_BASE/ipset/zapret-hosts-user-ipban.txt" ] && touch "$ZAPRET_BASE/ipset/zapret-hosts-user-ipban.txt"
|
||||
#[ ! -f "$ZAPRET_BASE/ipset/zapret-ip.txt" ] && touch "$ZAPRET_BASE/ipset/zapret-ip.txt"
|
||||
[ ! -f "$ZAPRET_BASE/ipset/zapret-ip-user.txt" ] && touch "$ZAPRET_BASE/ipset/zapret-ip-user.txt"
|
||||
[ ! -f "$ZAPRET_BASE/ipset/zapret-ip-user-exclude.txt" ] && touch "$ZAPRET_BASE/ipset/zapret-ip-user-exclude.txt"
|
||||
[ ! -f "$ZAPRET_BASE/ipset/zapret-ip-user-ipban.txt" ] && touch "$ZAPRET_BASE/ipset/zapret-ip-user-ipban.txt"
|
||||
|
||||
# create or merge uci-config
|
||||
$ZAPRET_BASE/renew-cfg.sh
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
#!/bin/sh
|
||||
# Copyright (c) 2025 remittor
|
||||
|
||||
. /opt/zapret2/comfunc.sh
|
||||
. /usr/share/libubox/jshn.sh
|
||||
. /etc/openwrt_release
|
||||
EXE_DIR=$(cd "$(dirname "$0")" 2>/dev/null || exit 1; pwd)
|
||||
|
||||
opt_check=
|
||||
opt_prerelease=
|
||||
@@ -14,14 +12,34 @@ opt_test=
|
||||
while getopts "cu:pft:" opt; do
|
||||
case $opt in
|
||||
c) opt_check=true;;
|
||||
p) opt_prerelease=true;;
|
||||
p) opt_prerelease="true";;
|
||||
u) opt_update="$OPTARG";;
|
||||
f) opt_forced=true;;
|
||||
f) opt_forced="true";;
|
||||
t) opt_test="$OPTARG";;
|
||||
esac
|
||||
done
|
||||
|
||||
ZAP_PKG_DIR=/tmp/zapret2_pkg
|
||||
if [ "$EXE_DIR" = "/tmp" ]; then
|
||||
ZAPRET_CFG_NAME="zapret"
|
||||
if [ "$opt_update" = "1" ]; then
|
||||
ZAPRET_CFG_NAME="zapret"
|
||||
opt_update="@"
|
||||
opt_forced="true"
|
||||
fi
|
||||
if [ "$opt_update" = "2" ]; then
|
||||
ZAPRET_CFG_NAME="zapret2"
|
||||
opt_update="@"
|
||||
opt_forced="true"
|
||||
fi
|
||||
else
|
||||
[ -f "$EXE_DIR/comfunc.sh" ] || { echo "ERROR: file $EXE_DIR/comfunc.sh not founded!"; exit 1; }
|
||||
. $EXE_DIR/comfunc.sh
|
||||
fi
|
||||
|
||||
. /usr/share/libubox/jshn.sh
|
||||
. /etc/openwrt_release
|
||||
|
||||
ZAP_PKG_DIR=/tmp/$ZAPRET_CFG_NAME-pkg
|
||||
|
||||
if [ "$opt_test" != "" ]; then
|
||||
echo 1; sleep 2;
|
||||
@@ -33,9 +51,14 @@ if [ "$opt_test" != "" ]; then
|
||||
return "$opt_test"
|
||||
fi
|
||||
|
||||
ZAP_CPU_ARCH=$(get_cpu_arch)
|
||||
ZAP_REL_URL="https://raw.githubusercontent.com/remittor/zapret-openwrt/gh-pages/releases/releases_zap2_$ZAP_CPU_ARCH.json"
|
||||
ZAP_CPU_ARCH="$DISTRIB_ARCH"
|
||||
|
||||
if [ $ZAPRET_CFG_NAME = "zapret" ]; then
|
||||
ZAP_REL_URL="https://raw.githubusercontent.com/remittor/zapret-openwrt/gh-pages/releases/releases_zap1_$ZAP_CPU_ARCH.json"
|
||||
fi
|
||||
if [ $ZAPRET_CFG_NAME = "zapret2" ]; then
|
||||
ZAP_REL_URL="https://raw.githubusercontent.com/remittor/zapret-openwrt/gh-pages/releases/releases_zap2_$ZAP_CPU_ARCH.json"
|
||||
fi
|
||||
CURL_TIMEOUT=5
|
||||
CURL_HEADER1="Accept: application/json"
|
||||
CURL_HEADER2="Cache-Control: no-cache"
|
||||
@@ -62,11 +85,73 @@ fi
|
||||
|
||||
# -------------------------------------------------------------------------------------------------------
|
||||
|
||||
function download_json
|
||||
function get_distrib_param
|
||||
{
|
||||
local url="$1"
|
||||
curl -s -L --max-time $CURL_TIMEOUT -H "$CURL_HEADER1" -H "$CURL_HEADER2" "$url" 2>/dev/null
|
||||
return $?
|
||||
local parname=$1
|
||||
local value="__unknown__"
|
||||
if [ -f /etc/openwrt_release ]; then
|
||||
while IFS='=' read -r key val; do
|
||||
val="${val#\'}"
|
||||
val="${val%\'}"
|
||||
val="${val#\"}"
|
||||
val="${val%\"}"
|
||||
if [ "$key" = "$parname" ]; then
|
||||
value="$val"
|
||||
break
|
||||
fi
|
||||
done < /etc/openwrt_release
|
||||
fi
|
||||
printf '%s' "$value"
|
||||
}
|
||||
|
||||
function pkg_mgr_update
|
||||
{
|
||||
local forced=$1
|
||||
if [ "$PKG_MGR" = "opkg" ]; then
|
||||
PKG_TOTAL=$( opkg list | wc -l )
|
||||
PKG_INSTALLED=$( opkg list-installed | wc -l )
|
||||
if [ "$PKG_TOTAL" = "$PKG_INSTALLED" ]; then
|
||||
echo ">>> OPKG update..."
|
||||
opkg update
|
||||
return $?
|
||||
fi
|
||||
else
|
||||
PKG_AVAIL=$( apk list --available 2>/dev/null | wc -l )
|
||||
if [ "$PKG_AVAIL" -lt 100 ]; then
|
||||
echo ">>> APK update..."
|
||||
apk update
|
||||
return $?
|
||||
fi
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
function curl_install
|
||||
{
|
||||
if command -v curl >/dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
pkg_mgr_update || { echo "ERROR: cannot update packages list"; return 1; }
|
||||
echo ">>> Package curl not found, installing..."
|
||||
if [ "$PKG_MGR" = "opkg" ]; then
|
||||
opkg install curl
|
||||
else
|
||||
apk add curl
|
||||
fi
|
||||
}
|
||||
|
||||
function unzip_install
|
||||
{
|
||||
if command -v unzip >/dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
pkg_mgr_update || { echo "ERROR: cannot update packages list"; return 1; }
|
||||
echo ">>> Package unzip not found, installing..."
|
||||
if [ "$PKG_MGR" = "opkg" ]; then
|
||||
opkg install unzip
|
||||
else
|
||||
apk add unzip
|
||||
fi
|
||||
}
|
||||
|
||||
function get_pkg_version
|
||||
@@ -81,7 +166,7 @@ function get_pkg_version
|
||||
fi
|
||||
fi
|
||||
if [ "$PKG_MGR" = apk ]; then
|
||||
line=$( apk info -e "$pkg_name" 2>/dev/null || true )
|
||||
line=$( apk info -s "$pkg_name" 2>/dev/null | head -n 1 | awk '{print $1}' || true )
|
||||
if [ -n "$line" ]; then
|
||||
base=${line%-r[0-9]*}
|
||||
ver=${base##*-}
|
||||
@@ -117,11 +202,16 @@ function normalize_version
|
||||
;;
|
||||
esac
|
||||
old_ifs="$IFS" ; IFS='.' ; set -- $base ; IFS="$old_ifs"
|
||||
rel=${rel:-1}
|
||||
major=${1:-0}
|
||||
minor=${2:-0}
|
||||
build=${3:-0}
|
||||
rel=${rel:-1}
|
||||
echo "$major.$minor.$build.$rel"
|
||||
if [ $ZAPRET_CFG_NAME = "zapret" ]; then
|
||||
echo "$major.$minor.$rel"
|
||||
fi
|
||||
if [ $ZAPRET_CFG_NAME = "zapret2" ]; then
|
||||
build=${3:-0}
|
||||
echo "$major.$minor.$build.$rel"
|
||||
fi
|
||||
}
|
||||
|
||||
function pkg_version_cmp
|
||||
@@ -139,14 +229,22 @@ function pkg_version_cmp
|
||||
x2=$( echo "$ver2" | cut -d. -f2 )
|
||||
[ "$x1" -gt "$x2" ] && { echo -n "G"; return 0; }
|
||||
[ "$x1" -lt "$x2" ] && { echo -n "L"; return 0; }
|
||||
# build
|
||||
x1=$( echo "$ver1" | cut -d. -f3 )
|
||||
x2=$( echo "$ver2" | cut -d. -f3 )
|
||||
[ "$x1" -gt "$x2" ] && { echo -n "G"; return 0; }
|
||||
[ "$x1" -lt "$x2" ] && { echo -n "L"; return 0; }
|
||||
if [ $ZAPRET_CFG_NAME = "zapret2" ]; then
|
||||
# build
|
||||
x1=$( echo "$ver1" | cut -d. -f3 )
|
||||
x2=$( echo "$ver2" | cut -d. -f3 )
|
||||
[ "$x1" -gt "$x2" ] && { echo -n "G"; return 0; }
|
||||
[ "$x1" -lt "$x2" ] && { echo -n "L"; return 0; }
|
||||
fi
|
||||
# release
|
||||
x1=$( echo "$ver1" | cut -d. -f4 )
|
||||
x2=$( echo "$ver2" | cut -d. -f4 )
|
||||
if [ $ZAPRET_CFG_NAME = "zapret" ]; then
|
||||
x1=$( echo "$ver1" | cut -d. -f3 )
|
||||
x2=$( echo "$ver2" | cut -d. -f3 )
|
||||
fi
|
||||
if [ $ZAPRET_CFG_NAME = "zapret2" ]; then
|
||||
x1=$( echo "$ver1" | cut -d. -f4 )
|
||||
x2=$( echo "$ver2" | cut -d. -f4 )
|
||||
fi
|
||||
[ "$x1" -gt "$x2" ] && { echo -n "G"; return 0; }
|
||||
[ "$x1" -lt "$x2" ] && { echo -n "L"; return 0; }
|
||||
echo -n "E"
|
||||
@@ -165,7 +263,7 @@ function download_releases_info
|
||||
echo "ERROR: Cannot download file \"$ZAP_REL_URL\" (status = $status)"
|
||||
return 103
|
||||
fi
|
||||
txtlen=$( printf '%s\n' "$hdr" | awk -F': ' 'BEGIN{IGNORECASE=1} $1=="Content-Length"{print $2}' | tr -d '\r')
|
||||
txtlen=$( printf '%s\n' "$hdr" | awk -F': ' 'BEGIN{IGNORECASE=1} $1=="Content-Length"{print $2}' | tr -d '\r' )
|
||||
echo "Content-Length: $txtlen bytes"
|
||||
txt="${resp#*$'\r\n\r\n'}"
|
||||
txtlen=${#txt}
|
||||
@@ -175,7 +273,7 @@ function download_releases_info
|
||||
return 104
|
||||
fi
|
||||
echo "Releases info downloaded! Size = $txtlen, Lines = $txtlines"
|
||||
generated_at=$(printf '%s\n' "$txt" | grep -m1 -o '"generated_at"[[:space:]]*:[[:space:]]*".*"' | cut -d'"' -f4)
|
||||
generated_at=$( printf '%s\n' "$txt" | grep -m1 -o '"generated_at"[[:space:]]*:[[:space:]]*".*"' | cut -d'"' -f4 )
|
||||
if [[ "$generated_at" = "" ]]; then
|
||||
echo "ERROR: Cannot download releases info! (incorrect generated_at)"
|
||||
return 105
|
||||
@@ -239,7 +337,7 @@ function get_actual_release
|
||||
done
|
||||
json_cleanup
|
||||
echo "ERROR: latest release for arch \"$ZAP_CPU_ARCH\" not founded!"
|
||||
return 1 # release not founded
|
||||
return 150 # release not founded
|
||||
}
|
||||
|
||||
# -------------------------------------------------------------------------------------------------------
|
||||
@@ -255,11 +353,16 @@ fi
|
||||
|
||||
#echo "DISTRIB_ID: $DISTRIB_ID"
|
||||
echo "DISTRIB_RELEASE: $DISTRIB_RELEASE"
|
||||
echo "DISTRIB_DESCRIPTION:" $(get_distrib_param DISTRIB_DESCRIPTION)
|
||||
echo "DISTRIB_ARCH:" $(get_distrib_param DISTRIB_ARCH)
|
||||
echo "DISTRIB_DESCRIPTION:" $( get_distrib_param DISTRIB_DESCRIPTION )
|
||||
echo "DISTRIB_ARCH:" $( get_distrib_param DISTRIB_ARCH )
|
||||
|
||||
if ! command -v curl >/dev/null 2>&1; then
|
||||
echo "ERROR: package \"curl\" not installed!"
|
||||
if [ "$opt_forced" = true ]; then
|
||||
curl_install
|
||||
fi
|
||||
fi
|
||||
if ! command -v curl >/dev/null 2>&1; then
|
||||
echo "ERROR: Required package \"curl\" not installed!"
|
||||
return 10
|
||||
fi
|
||||
CURL_INFO=$( curl -V )
|
||||
@@ -281,6 +384,11 @@ if [ "$opt_check" = "true" ]; then
|
||||
fi
|
||||
get_actual_release
|
||||
ZAP_ERR=$?
|
||||
if [ $ZAP_ERR = 150 ] && [ "$opt_prerelease" != true ] && [ "$opt_forced" = true ]; then
|
||||
opt_prerelease="true"
|
||||
get_actual_release
|
||||
ZAP_ERR=$?
|
||||
fi
|
||||
if [ $ZAP_ERR -ne 0 ]; then
|
||||
echo "ERROR: Func get_actual_release return error code: $ZAP_ERR"
|
||||
return $ZAP_ERR
|
||||
@@ -296,7 +404,7 @@ ZAP_PKG_FN=
|
||||
ZAP_PKG_BASE_FN=
|
||||
ZAP_PKG_LUCI_FN=
|
||||
|
||||
ZAP_CUR_PKG_VER=$( get_pkg_version zapret2 )
|
||||
ZAP_CUR_PKG_VER=$( get_pkg_version $ZAPRET_CFG_NAME )
|
||||
echo "Current installed version: $ZAP_CUR_PKG_VER"
|
||||
|
||||
if [ "$opt_update" = "" ]; then
|
||||
@@ -351,7 +459,7 @@ if [ "$opt_update" != "" ]; then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
ZAP_PKG_DIR=/tmp/zapret2_pkg
|
||||
ZAP_PKG_DIR=/tmp/$ZAPRET_CFG_NAME-pkg
|
||||
rm -rf $ZAP_PKG_DIR 2>/dev/null
|
||||
ZAP_PKG_HDRS=$( curl -s -I -L --max-time $CURL_TIMEOUT -H "$CURL_HEADER2" "$ZAP_PKG_URL" )
|
||||
ZAP_PKG_SIZE=$( echo "$ZAP_PKG_HDRS" | grep -i 'content-length: ' | tail -n1 | awk '{print $2}' | tr -d '\r' )
|
||||
@@ -373,6 +481,11 @@ if [ "$opt_update" != "" ]; then
|
||||
echo "ERROR: downloaded package is incorrect! (size = $ZAP_PKG_SZ)"
|
||||
return 216
|
||||
fi
|
||||
if ! command -v unzip >/dev/null 2>&1; then
|
||||
if [ "$opt_forced" = true ]; then
|
||||
unzip_install
|
||||
fi
|
||||
fi
|
||||
if ! command -v unzip >/dev/null 2>&1; then
|
||||
echo "ERROR: package \"upzip\" not installed!"
|
||||
return 218
|
||||
@@ -394,21 +507,24 @@ if [ "$opt_update" != "" ]; then
|
||||
echo "$ZAP_PKG_LIST"
|
||||
echo "------"
|
||||
if [ "$PKG_MGR" != "apk" ]; then
|
||||
ZAP_PKG_BASE_FN=$( find "$ZAP_PKG_DIR" -maxdepth 1 -type f -name "zapret2_*.${ZAP_PKG_EXT}" | head -n 1 )
|
||||
ZAP_PKG_BASE_FN=$( find "$ZAP_PKG_DIR" -maxdepth 1 -type f -name "${ZAPRET_CFG_NAME}_*.${ZAP_PKG_EXT}" | head -n 1 )
|
||||
else
|
||||
ZAP_PKG_BASE_FN=$( find "$ZAP_PKG_DIR" -maxdepth 1 -type f -name "zapret2-[0-9]*.?*.${ZAP_PKG_EXT}" | head -n 1 )
|
||||
ZAP_PKG_BASE_FN=$( find "$ZAP_PKG_DIR" -maxdepth 1 -type f -name "${ZAPRET_CFG_NAME}-[0-9]*.?*.${ZAP_PKG_EXT}" | head -n 1 )
|
||||
fi
|
||||
ZAP_PKG_LUCI_FN=$( find "$ZAP_PKG_DIR" -maxdepth 1 -type f -name "luci-app-zapret2*.${ZAP_PKG_EXT}" | head -n 1 )
|
||||
ZAP_PKG_LUCI_FN=$( find "$ZAP_PKG_DIR" -maxdepth 1 -type f -name "luci-app-${ZAPRET_CFG_NAME}*.${ZAP_PKG_EXT}" | head -n 1 )
|
||||
if [ ! -f "$ZAP_PKG_BASE_FN" ]; then
|
||||
echo "ERROR: File \"zapret2*.${ZAP_PKG_EXT}\" not found!"
|
||||
echo "ERROR: File \"${ZAPRET_CFG_NAME}*.${ZAP_PKG_EXT}\" not found!"
|
||||
return 231
|
||||
fi
|
||||
echo "ZAP_PKG_BASE_FN = $ZAP_PKG_BASE_FN"
|
||||
if [ ! -f "$ZAP_PKG_LUCI_FN" ]; then
|
||||
echo "ERROR: File \"luci-app-zapret2*.${ZAP_PKG_EXT}\" not found!"
|
||||
echo "ERROR: File \"luci-app-${ZAPRET_CFG_NAME}*.${ZAP_PKG_EXT}\" not found!"
|
||||
return 232
|
||||
fi
|
||||
echo "ZAP_PKG_LUCI_FN = $ZAP_PKG_LUCI_FN"
|
||||
if [ "$opt_forced" = true ]; then
|
||||
pkg_mgr_update
|
||||
fi
|
||||
echo "Install downloaded packages..."
|
||||
if [ "$PKG_MGR" != "apk" ]; then
|
||||
opkg install --force-reinstall "$ZAP_PKG_BASE_FN"
|
||||
Reference in New Issue
Block a user