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
This commit is contained in:
+97
-29
@@ -1,55 +1,120 @@
|
||||
#!/bin/bash
|
||||
# install.sh - One-shot installer: setup + build + autotest + systemd install
|
||||
# Run once after cloning the repository.
|
||||
# Works in Russia (GitHub blocked): supports HTTPS_PROXY, offline bundle, mirrors
|
||||
# Usage:
|
||||
# sudo ./install.sh # normal (with proxy/VPN)
|
||||
# sudo ./install.sh --offline # use pre-downloaded bundle
|
||||
# HTTPS_PROXY=socks5://127.0.0.1:1080 sudo ./install.sh
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "$SCRIPT_DIR/lib/functions.sh"
|
||||
source "$SCRIPT_DIR/lib/download_helper.sh"
|
||||
|
||||
if [[ "$EUID" -ne 0 ]]; then
|
||||
print_red "[!] This script must be run as root (or with sudo)"
|
||||
print_red "[!] Run as root (or sudo)"
|
||||
echo " sudo ./install.sh"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for offline flag
|
||||
OFFLINE_MODE=0
|
||||
if [[ "${1:-}" == "--offline" ]]; then
|
||||
OFFLINE_MODE=1
|
||||
echo ""
|
||||
echo "[*] OFFLINE MODE: skipping network, using local bundle only"
|
||||
sleep 1
|
||||
fi
|
||||
|
||||
# Load proxy
|
||||
load_proxy
|
||||
|
||||
# Check if proxy is set
|
||||
if [[ -n "${HTTPS_PROXY:-}" ]]; then
|
||||
echo "[OK] Proxy detected: $HTTPS_PROXY"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "=============================================="
|
||||
echo " Zapret for Linux - Full Installer"
|
||||
echo "=============================================="
|
||||
echo ""
|
||||
echo " This will:"
|
||||
echo " 1. Install dependencies (git, make, gcc, curl)"
|
||||
echo " 2. Build nfqws binary from source"
|
||||
echo " 3. Run autotest to find working strategy"
|
||||
echo " 4. Install systemd service for auto-start"
|
||||
echo " 1. Sync upstream lists & strategies"
|
||||
echo " 2. Install dependencies"
|
||||
echo " 3. Build nfqws from source"
|
||||
echo " 4. Auto-test strategies"
|
||||
echo " 5. Install systemd service"
|
||||
echo ""
|
||||
read -rp "Continue? [Y/n]: " ans
|
||||
if [[ "${ans:-Y}" != [yY]* ]]; then
|
||||
echo "Aborted."
|
||||
exit 0
|
||||
|
||||
if [[ "$OFFLINE_MODE" -eq 1 ]]; then
|
||||
echo " Mode: OFFLINE (no internet required)"
|
||||
else
|
||||
echo " Mode: ONLINE (needs internet or proxy/VPN)"
|
||||
if ! curl -sfL --max-time 5 "https://github.com" >/dev/null 2>&1; then
|
||||
print_yellow "[!] GitHub NOT reachable."
|
||||
echo " Options:"
|
||||
echo " a) Set proxy: HTTPS_PROXY=socks5://127.0.0.1:1080 sudo ./install.sh"
|
||||
echo " b) Use VPN and re-run"
|
||||
echo " c) Run offline: sudo ./install.sh --offline"
|
||||
echo " d) Or prepare offline bundle first: proxychains ./prepare_offline_bundle.sh"
|
||||
echo ""
|
||||
read -rp "Continue anyway? [y/N]: " ans
|
||||
[[ "$ans" == [yY]* ]] || exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Step 0: Sync upstream lists and strategies
|
||||
bash "$SCRIPT_DIR/sync_from_upstream.sh" || true
|
||||
read -rp "Continue? [Y/n]: " ans
|
||||
[[ "${ans:-Y}" == [yY]* ]] || { echo "Aborted."; exit 0; }
|
||||
|
||||
# Step 0: Sync upstream (lists, hosts, new .bat strategies)
|
||||
if [[ "$OFFLINE_MODE" -eq 0 ]]; then
|
||||
echo ""
|
||||
echo "[*] Step 0: Syncing upstream lists/strategies..."
|
||||
bash "$SCRIPT_DIR/sync_from_upstream.sh" 2>&1 || {
|
||||
print_yellow "[!] Sync failed. Continuing with local files..."
|
||||
}
|
||||
else
|
||||
echo ""
|
||||
echo "[*] Step 0: OFFLINE — skipping upstream sync"
|
||||
fi
|
||||
|
||||
# Step 1: Setup
|
||||
echo ""
|
||||
echo "[*] Step 1/4: Running setup..."
|
||||
bash "$SCRIPT_DIR/setup.sh"
|
||||
echo "[*] Step 1/4: Installing dependencies..."
|
||||
bash "$SCRIPT_DIR/setup.sh" || {
|
||||
print_red "[!] Setup failed. Check dependencies."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Step 2: Build (done inside setup, but verify)
|
||||
# Step 2: Build nfqws
|
||||
echo ""
|
||||
echo "[*] Step 2/4: Verifying build..."
|
||||
echo "[*] Step 2/4: Building nfqws..."
|
||||
check_nfqws || {
|
||||
print_red "[!] nfqws not found after setup. Trying to rebuild..."
|
||||
bash "$SCRIPT_DIR/install_nfqws.sh"
|
||||
bash "$SCRIPT_DIR/install_nfqws.sh" || {
|
||||
print_red "[!] Build failed."
|
||||
echo ""
|
||||
echo "Common causes:"
|
||||
echo " - GitHub blocked (set HTTPS_PROXY or use --offline)"
|
||||
echo " - Missing build tools (gcc, make)"
|
||||
echo " - libnetfilter_queue not installed"
|
||||
echo ""
|
||||
echo "Try:"
|
||||
echo " HTTPS_PROXY=socks5://127.0.0.1:1080 sudo ./install.sh"
|
||||
echo " OR"
|
||||
echo " sudo ./install.sh --offline"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# Step 3: Auto-test
|
||||
echo ""
|
||||
echo "[*] Step 3/4: Auto-testing strategies..."
|
||||
bash "$SCRIPT_DIR/autotest.sh" --auto
|
||||
bash "$SCRIPT_DIR/autotest.sh" --auto || {
|
||||
print_yellow "[!] Auto-test: no strategy worked automatically."
|
||||
echo " Try manually: sudo ./general.sh, sudo ./general_ALT.sh, ..."
|
||||
}
|
||||
|
||||
# Step 4: Done
|
||||
echo ""
|
||||
@@ -59,22 +124,25 @@ print_green "=============================================="
|
||||
echo ""
|
||||
|
||||
if command -v systemctl >/dev/null 2>&1; then
|
||||
echo "[*] Service status:"
|
||||
systemctl status zapret --no-pager 2>/dev/null || true
|
||||
echo ""
|
||||
echo "Commands:"
|
||||
echo " sudo systemctl status zapret # check status"
|
||||
echo " sudo systemctl stop zapret # stop"
|
||||
echo " sudo systemctl start zapret # start"
|
||||
echo " sudo systemctl restart zapret # restart"
|
||||
echo " sudo journalctl -u zapret -f # view logs"
|
||||
echo " sudo systemctl status zapret"
|
||||
echo " sudo systemctl stop zapret"
|
||||
echo " sudo systemctl start zapret"
|
||||
echo " sudo systemctl restart zapret"
|
||||
echo " sudo journalctl -u zapret -f"
|
||||
else
|
||||
echo "[*] systemd not found. To start manually:"
|
||||
echo " sudo ./general.sh (or any other strategy)"
|
||||
echo " sudo ./general.sh"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "[*] To update in the future:"
|
||||
echo " sudo ./update.sh # check for new version + rebuild"
|
||||
echo " sudo ./update.sh --full-auto # force rebuild + re-test"
|
||||
echo "[*] To update in future:"
|
||||
if [[ "$OFFLINE_MODE" -eq 1 ]]; then
|
||||
echo " Re-run with VPN/proxy: sudo ./install.sh"
|
||||
else
|
||||
echo " sudo ./update.sh # auto sync + rebuild"
|
||||
echo " sudo ./update.sh --full-auto # force rebuild"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
Reference in New Issue
Block a user