Files
zapret-discord-youtube-linux/prepare_offline_bundle.sh
T
Stitch505 2a6a358baf feat(ru): full Russia/offline support (#RF)
- Add lib/download_helper.sh: proxy detection, GitHub mirrors, offline cache, tarball fallback
- Rewrite install_nfqws.sh: offline bundle support, bol-van/zapret via git clone + tarball + mirror fallback
- Rewrite sync_from_upstream.sh: proxy aware, --offline flag, graceful degradation
- Add prepare_offline_bundle.sh: create tar.gz with sources + lists + fake bins on machine WITH internet
- Add .env.example: GITHUB_PROXY, HTTPS_PROXY configuration
- Update install.sh: check GitHub reachability, suggest proxy/offline, --offline flag
- Update README: Russia section at top, Offline section, VPN/proxy examples, .env guide
2026-05-10 20:11:08 +04:00

110 lines
4.4 KiB
Bash
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 ""