Merge pull request #28 from vernette/main

fix(install): resolve update failure due to improper cleanup
This commit is contained in:
itdoginfo
2025-02-18 12:52:30 +03:00
committed by GitHub
2 changed files with 32 additions and 21 deletions

View File

@@ -43,29 +43,41 @@ main() {
add_tunnel add_tunnel
fi 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") filename=$(basename "$url")
filepath="$DOWNLOAD_DIR/$filename" filepath="$DOWNLOAD_DIR/$filename"
if [ -f "$filepath" ] && [ -s "$filepath" ]; then
echo "$filename has already been uploaded"
download_success=1
continue
fi
attempt=0 attempt=0
while [ $attempt -lt $COUNT ]; do 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)))..." echo "Download $filename (count $((attempt+1)))..."
wget -q -O "$filepath" "$url" if wget -q -O "$filepath" "$url"; then
if [ -s "$filepath" ]; then
if [ -s "$filepath" ]; then echo "$filename successfully downloaded"
echo "$filename successfully downloaded" download_success=1
else break
echo "Download error $filename. Retry..." fi
rm -f "$filepath"
fi fi
echo "Download error $filename. Retry..."
rm -f "$filepath"
attempt=$((attempt+1)) attempt=$((attempt+1))
done 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 for pkg in podkop luci-app-podkop; do
file=$(ls "$DOWNLOAD_DIR" | grep "^$pkg" | head -n 1) file=$(ls "$DOWNLOAD_DIR" | grep "^$pkg" | head -n 1)
@@ -96,8 +108,7 @@ main() {
done done
fi fi
find "$DOWNLOAD_DIR" -type f -name '*podkop*' -exec rm {} \;
rm -f $DOWNLOAD_DIR/podkop*.ipk $DOWNLOAD_DIR/luci-app-podkop*.ipk $DOWNLOAD_DIR/luci-i18n-podkop-ru*.ipk
if [ "$IS_SHOULD_RESTART_NETWORK" ]; then if [ "$IS_SHOULD_RESTART_NETWORK" ]; then
printf "\033[32;1mRestart network\033[0m\n" printf "\033[32;1mRestart network\033[0m\n"

View File

@@ -73,7 +73,7 @@ stop_service() {
remove_cron_job remove_cron_job
dnsmasq_rm dnsmasq_rm
rm -rf /tmp/podkop/* rm -rf /tmp/podkop/*.lst
log "Flush nft" log "Flush nft"
if nft list table inet PodkopTable >/dev/null 2>&1; then if nft list table inet PodkopTable >/dev/null 2>&1; then