From 744de6aec254d3c1b22ce45756c6f7d9b7d1a093 Mon Sep 17 00:00:00 2001 From: Nikita Skryabin Date: Tue, 18 Feb 2025 09:45:49 +0300 Subject: [PATCH 1/6] chore(install.sh): replace rm command with find --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 119bade..6c702b9 100755 --- a/install.sh +++ b/install.sh @@ -97,7 +97,7 @@ main() { fi - rm -f $DOWNLOAD_DIR/podkop*.ipk $DOWNLOAD_DIR/luci-app-podkop*.ipk $DOWNLOAD_DIR/luci-i18n-podkop-ru*.ipk + find "$DOWNLOAD_DIR" -type f -name '*podkop*' -exec rm {} \; if [ "$IS_SHOULD_RESTART_NETWORK" ]; then printf "\033[32;1mRestart network\033[0m\n" @@ -429,4 +429,4 @@ sing_box() { fi } -main \ No newline at end of file +main From 6f997a6e73d5a59d319c03aeebc559a6e26332ad Mon Sep 17 00:00:00 2001 From: Nikita Skryabin Date: Tue, 18 Feb 2025 09:58:26 +0300 Subject: [PATCH 2/6] refactor(install.sh): improve download retry logic --- install.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/install.sh b/install.sh index 6c702b9..cb73e8e 100755 --- a/install.sh +++ b/install.sh @@ -47,23 +47,24 @@ main() { filename=$(basename "$url") filepath="$DOWNLOAD_DIR/$filename" + if [ -f "$filepath" ] && [ -s "$filepath" ]; then + echo "$filename has already been uploaded" + continue + fi + attempt=0 while [ $attempt -lt $COUNT ]; do - if [ -f "$filepath" ] && [ -s "$filepath" ]; then - echo "$filename has already been uploaded" - break - fi - echo "Download $filename (count $((attempt+1)))..." wget -q -O "$filepath" "$url" if [ -s "$filepath" ]; then echo "$filename successfully downloaded" + break else echo "Download error $filename. Retry..." rm -f "$filepath" + attempt=$((attempt+1)) fi - attempt=$((attempt+1)) done done @@ -96,7 +97,6 @@ main() { done fi - find "$DOWNLOAD_DIR" -type f -name '*podkop*' -exec rm {} \; if [ "$IS_SHOULD_RESTART_NETWORK" ]; then From ade2b844ec1f649f54f7f0e8ac9647454c2337d7 Mon Sep 17 00:00:00 2001 From: Nikita Skryabin Date: Tue, 18 Feb 2025 10:05:34 +0300 Subject: [PATCH 3/6] fix(init.d/podkop): change rm command to remove only *.lst files in /tmp/podkop directory --- podkop/files/etc/init.d/podkop | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/podkop/files/etc/init.d/podkop b/podkop/files/etc/init.d/podkop index 1b1040f..1a5ad3f 100755 --- a/podkop/files/etc/init.d/podkop +++ b/podkop/files/etc/init.d/podkop @@ -73,7 +73,7 @@ stop_service() { remove_cron_job dnsmasq_rm - rm -rf /tmp/podkop/* + rm -rf /tmp/podkop/*.lst log "Flush nft" if nft list table inet PodkopTable >/dev/null 2>&1; then @@ -1608,4 +1608,4 @@ show_config() { show_version() { local version=$(opkg info podkop | grep -m 1 "Version:" | cut -d' ' -f2) echo "$version" -} \ No newline at end of file +} From bd0e33781f863329b15431eea65c33f5fb5b4c2d Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 18 Feb 2025 12:06:33 +0300 Subject: [PATCH 4/6] fix(install): correct continue logic for existing package files --- install.sh | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/install.sh b/install.sh index cb73e8e..c43c362 100755 --- a/install.sh +++ b/install.sh @@ -43,31 +43,42 @@ main() { add_tunnel fi - wget -qO- "$REPO" | grep -o 'https://[^"[:space:]]*\.ipk' | while read -r url; do + download_success=0 + while read -r url; do filename=$(basename "$url") filepath="$DOWNLOAD_DIR/$filename" - + if [ -f "$filepath" ] && [ -s "$filepath" ]; then echo "$filename has already been uploaded" + download_success=1 continue fi - + attempt=0 while [ $attempt -lt $COUNT ]; do echo "Download $filename (count $((attempt+1)))..." - wget -q -O "$filepath" "$url" - - if [ -s "$filepath" ]; then - echo "$filename successfully downloaded" - break - else - echo "Download error $filename. Retry..." - rm -f "$filepath" - attempt=$((attempt+1)) + if wget -q -O "$filepath" "$url"; then + if [ -s "$filepath" ]; then + echo "$filename successfully downloaded" + download_success=1 + break + fi fi + echo "Download error $filename. Retry..." + rm -f "$filepath" + attempt=$((attempt+1)) done - done - + + if [ $attempt -eq $COUNT ]; then + echo "Failed to download $filename after $COUNT attempts" + fi + done < <(wget -qO- "$REPO" | grep -o 'https://[^"[:space:]]*\.ipk') + + if [ $download_success -eq 0 ]; then + echo "No packages were downloaded successfully" + exit 1 + fi + for pkg in podkop luci-app-podkop; do file=$(ls "$DOWNLOAD_DIR" | grep "^$pkg" | head -n 1) if [ -n "$file" ]; then From 1c02a2208b9bbe7f11766b6c82088bb525d1a6cb Mon Sep 17 00:00:00 2001 From: itdoginfo Date: Tue, 18 Feb 2025 13:21:31 +0300 Subject: [PATCH 5/6] Stop service before rm --- podkop/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/podkop/Makefile b/podkop/Makefile index 7b60fae..eb8a91d 100644 --- a/podkop/Makefile +++ b/podkop/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=podkop -PKG_VERSION:=0.3.9 +PKG_VERSION:=0.3.10 PKG_RELEASE:=1 PKG_MAINTAINER:=ITDog @@ -33,6 +33,8 @@ define Package/podkop/prerm grep -q "105 podkop" /etc/iproute2/rt_tables && sed -i "/105 podkop/d" /etc/iproute2/rt_tables +/etc/init.d/podkop stop + exit 0 endef From 16c174d624f0b177ec312423b534f4aa021f5f28 Mon Sep 17 00:00:00 2001 From: itdoginfo Date: Tue, 18 Feb 2025 13:21:52 +0300 Subject: [PATCH 6/6] v0.3.10 --- README.md | 1 + install.sh | 8 +------- luci-app-podkop/Makefile | 2 +- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 7809f4f..d7e979f 100644 --- a/README.md +++ b/README.md @@ -155,6 +155,7 @@ Luci: Services/podkop - [ ] Валидации предустановленных значений. Если прописаны другие, то вывод в лог о неизвестной переменной и продолжение работы - [ ] Добавление в список доменов домены первого уровня (LuCI) - [ ] Проверка, что версия в makefile совпадает с тегом +- [ ] Don't touch my DHCP! Приоритет 2 - [x] Списки доменов и подсетей с роутера diff --git a/install.sh b/install.sh index c43c362..f9d5855 100755 --- a/install.sh +++ b/install.sh @@ -47,13 +47,7 @@ main() { while read -r url; do filename=$(basename "$url") filepath="$DOWNLOAD_DIR/$filename" - - if [ -f "$filepath" ] && [ -s "$filepath" ]; then - echo "$filename has already been uploaded" - download_success=1 - continue - fi - + attempt=0 while [ $attempt -lt $COUNT ]; do echo "Download $filename (count $((attempt+1)))..." diff --git a/luci-app-podkop/Makefile b/luci-app-podkop/Makefile index 8fb1073..3a05355 100644 --- a/luci-app-podkop/Makefile +++ b/luci-app-podkop/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-podkop -PKG_VERSION:=0.3.9 +PKG_VERSION:=0.3.10 PKG_RELEASE:=1 LUCI_TITLE:=LuCI podkop app