Files
zapret-discord-youtube-linux/prepare_offline_bundle.sh
OpenCode Agent 62ec6c5749 fix(core): critical fixes for service menu, autotest, strategy runner, dependencies
- service.sh: split service_remove into internal (no prompts) and interactive
  versions to prevent 'eternal wait' when installing new strategy.
  Install now calls service_remove_internal > /dev/null instead of service_remove.
  Also filter strategy list to general*.sh only to avoid clutter.
  Systemd ExecStart now points to run_strategy.sh <name> consistently.

- run_strategy.sh: add SIGTERM/SIGINT trap cleanup_strategy() that kills nfqws
  and cleans up firewall. Prevents stale nfqws/firewall rules after autotest kill.
  Also handles nfqws exit gracefully with final cleanup.

- autotest.sh: rewritten to test strategies by config name (not wrapper filename).
  Stop now sends SIGTERM to wrapper (which triggers trap cleanup) instead of
  bare kill. Added extra sleep after stop to let trap fire.
  Auto-install ExecStart fixed to run_strategy.sh <strategy>.

- setup.sh: added libmnl-dev and zlib1g-dev to Ubuntu/Debian dependency install
  to prevent build failures (missing libmnl/libmnl.h and zlib.h).

- general*.sh: removed UTF-8 BOM (0xEF 0xBB 0xBF) that caused 'exec format error'
  when running scripts on Linux. All 19 wrappers cleaned.

- ensure_wrappers.sh: always rewrite wrappers to ensure no stale BOM or paths.

Fixes: eternal wait on menu option 1, nfqws build failure, stale processes after test.
2026-05-10 22:47:48 +04:00

110 lines
4.4 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# prepare_offline_bundle.sh - Создание офлайн-пакета (с подключённым VPN)
# Запустите с VPN: proxychains ./prepare_offline_bundle.sh
# Получите bundle.tar.gz для переноса на компьютер без доступа к GitHub
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BUNDLE_DIR="/tmp/zapret-bundle-$$"
BUNDLE_FILE="$SCRIPT_DIR/zapret-discord-youtube-linux-bundle.tar.gz"
echo "================================================"
echo " Offline Bundle Preparation"
echo " Run this WITH VPN/proxy enabled"
echo "================================================"
echo ""
# Check for GitHub access
echo "[*] Testing GitHub connectivity..."
if ! curl -sfL --max-time 10 "https://github.com" >/dev/null 2>&1; then
echo "[WARN] GitHub not reachable."
echo " Proxychains or VPN needed!"
echo ""
echo "Examples:"
echo " proxychains ./prepare_offline_bundle.sh"
echo " HTTPS_PROXY=socks5://localhost:1080 ./prepare_offline_bundle.sh"
read -rp "Continue anyway? [y/N]: " ans
[[ "$ans" == [yY]* ]] || exit 1
fi
mkdir -p "$BUNDLE_DIR/sources"
mkdir -p "$BUNDLE_DIR/upstream"
# Step 1: Download zapret source
echo ""
echo "[*] Step 1/3: Downloading bol-van/zapret..."
if command -v git >/dev/null 2>&1; then
git clone --depth=1 https://github.com/bol-van/zapret.git "$BUNDLE_DIR/sources/zapret"
else
echo " git not found. Using HTTPS:"
curl -sfL -o "/tmp/zapret.tar.gz" "https://api.github.com/repos/bol-van/zapret/tarball/master" 2>/dev/null || {
echo "[FAIL] Could not download zapret. Try with proxychains."
exit 1
}
mkdir -p "$BUNDLE_DIR/sources/zapret"
tar -xzf "/tmp/zapret.tar.gz" -C "$BUNDLE_DIR/sources/zapret" --strip-components=1
rm -f "/tmp/zapret.tar.gz"
fi
echo " [OK] zapret source downloaded"
# Step 2: Download upstream Flowseal lists
echo ""
echo "[*] Step 2/3: Downloading upstream lists/strategies..."
UPSTREAM_TMP="/tmp/upstream-$$"
if command -v git >/dev/null 2>&1; then
git clone --depth=1 https://github.com/Flowseal/zapret-discord-youtube.git "$UPSTREAM_TMP"
else
(cd "$BUNDLE_DIR" && curl -sfL -o "zapret-win.tar.gz" "https://api.github.com/repos/Flowseal/zapret-discord-youtube/tarball/main" && \
mkdir -p "$UPSTREAM_TMP" && tar -xzf zapret-win.tar.gz -C "$UPSTREAM_TMP" --strip-components=1)
fi
# Copy needed files
cp "$UPSTREAM_TMP/.service/hosts" "$BUNDLE_DIR/hosts" 2>/dev/null || true
cp "$UPSTREAM_TMP/.service/version.txt" "$BUNDLE_DIR/version.txt" 2>/dev/null || true
cp "$UPSTREAM_TMP/lists/"*.txt "$BUNDLE_DIR/" 2>/dev/null || true
cp "$UPSTREAM_TMP/general"*.bat "$BUNDLE_DIR/" 2>/dev/null || true
echo " [OK] Upstream content downloaded: lists, bat files, hosts, version"
# Step 3: Download fake .bin files
echo ""
echo "[*] Step 3/3: Downloading fake packet binaries..."
FAKE_URL="https://github.com/bol-van/zapret/raw/master/files/fake"
for f in quic_initial_www_google_com.bin quic_initial_dbankcloud_ru.bin tls_clienthello_www_google_com.bin tls_clienthello_4pda_to.bin tls_clienthello_max_ru.bin stun.bin; do
if curl -sfL "$FAKE_URL/$f" -o "$BUNDLE_DIR/$f" 2>/dev/null; then
echo " [OK] $f"
else
echo " [SKIP] $f (will build at install time)"
fi
done
# Package everything
echo ""
echo "[*] Packaging..."
mkdir -p "$BUNDLE_DIR/installed-scripts"
cp "$SCRIPT_DIR"/*.sh "$BUNDLE_DIR/installed-scripts/" 2>/dev/null || true
cp "$SCRIPT_DIR/lib/"*.sh "$BUNDLE_DIR/installed-scripts/lib/" 2>/dev/null || true
cp "$SCRIPT_DIR/strategies/"*.conf "$BUNDLE_DIR/installed-scripts/strategies/" 2>/dev/null || true
cp "$SCRIPT_DIR/systemd/"*.service "$BUNDLE_DIR/installed-scripts/systemd/" 2>/dev/null || true
cp "$SCRIPT_DIR/systemd/"*.timer "$BUNDLE_DIR/installed-scripts/systemd/" 2>/dev/null || true
tar -czf "$BUNDLE_FILE" -C "/tmp" "$(basename "$BUNDLE_DIR")"
rm -rf "$BUNDLE_DIR" "$UPSTREAM_TMP"
echo ""
echo "================================================"
echo " BUNDLE READY"
echo " File: $BUNDLE_FILE"
echo "================================================"
echo ""
echo "To install on target machine without internet:"
echo " cd /opt"
echo " tar -xzf zapret-discord-youtube-linux-bundle.tar.gz"
echo " cd zapret-bundle-*/installed-scripts"
echo " sudo ./install.sh --offline"
echo ""
echo "Or if you have proxy on target:"
echo " export HTTP_PROXY=http://proxy:port"
echo " sudo ./install.sh"
echo ""