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.
This commit is contained in:
OpenCode Agent
2026-05-10 22:41:08 +04:00
parent 06484b84a2
commit 62ec6c5749
32 changed files with 118 additions and 85 deletions

82
autotest.sh Normal file → Executable file
View File

@@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# autotest.sh - Automatic strategy tester # autotest.sh - Automatic strategy tester v2
# Iterates through all strategies, checks connectivity, suggests installation # Iterates through all strategies, checks connectivity, suggests installation
set -e set -e
@@ -16,25 +16,25 @@ TEST_URLS=(
# Strategy order (most common first) # Strategy order (most common first)
STRATEGIES=( STRATEGIES=(
general.sh general
general_ALT.sh ALT
general_ALT2.sh ALT2
general_ALT3.sh ALT3
general_ALT4.sh ALT4
general_ALT6.sh ALT6
general_ALT7.sh ALT7
general_ALT8.sh ALT8
general_ALT9.sh ALT9
general_ALT10.sh ALT10
general_ALT11.sh ALT11
general_FAKE_TLS_AUTO.sh FAKE_TLS_AUTO
general_FAKE_TLS_AUTO_ALT.sh FAKE_TLS_AUTO_ALT
general_FAKE_TLS_AUTO_ALT2.sh FAKE_TLS_AUTO_ALT2
general_FAKE_TLS_AUTO_ALT3.sh FAKE_TLS_AUTO_ALT3
general_SIMPLE_FAKE.sh SIMPLE_FAKE
general_SIMPLE_FAKE_ALT.sh SIMPLE_FAKE_ALT
general_SIMPLE_FAKE_ALT2.sh SIMPLE_FAKE_ALT2
general_ALT5.sh # NOT RECOMMENDED, last ALT5 # NOT RECOMMENDED, last
) )
# Test a single URL # Test a single URL
@@ -75,18 +75,18 @@ test_strategy() {
# Run a strategy with timeout # Run a strategy with timeout
run_strategy_test() { run_strategy_test() {
local strategy="$1" local strategy="$1"
local strategy_path="$SCRIPT_DIR/$strategy" local strategy_path="$SCRIPT_DIR/run_strategy.sh"
local strategy_name="${strategy%.sh}" local strategy_name="$strategy"
echo "" echo ""
echo "==============================================" echo "=============================================="
echo " Testing: $strategy_name" echo " Testing: $strategy_name"
echo " $(describe_strategy "$strategy_path")" echo " $(describe_strategy "$SCRIPT_DIR/general_${strategy}.sh")"
echo "==============================================" echo "=============================================="
# Check if strategy file exists # Check if strategy config exists
if [[ ! -f "$strategy_path" ]]; then if [[ ! -f "$SCRIPT_DIR/strategies/${strategy}.conf" ]]; then
print_yellow " [!] Strategy file not found, skipping..." print_yellow " [!] Strategy config not found, skipping..."
return 1 return 1
fi fi
@@ -94,9 +94,9 @@ run_strategy_test() {
cleanup_firewall >/dev/null 2>&1 || true cleanup_firewall >/dev/null 2>&1 || true
sleep 1 sleep 1
# Start strategy in background # Start strategy in background (run_strategy.sh handles its own cleanup on signals)
echo " [*] Starting $strategy_name..." echo " [*] Starting $strategy_name..."
"$strategy_path" >/dev/null 2>&1 & "$strategy_path" "$strategy" >/dev/null 2>&1 &
local strategy_pid=$! local strategy_pid=$!
# Wait for nfqws to initialize # Wait for nfqws to initialize
@@ -109,6 +109,7 @@ run_strategy_test() {
kill "$strategy_pid" 2>/dev/null || true kill "$strategy_pid" 2>/dev/null || true
wait "$strategy_pid" 2>/dev/null || true wait "$strategy_pid" 2>/dev/null || true
cleanup_firewall >/dev/null 2>&1 || true cleanup_firewall >/dev/null 2>&1 || true
sleep 1
return 1 return 1
fi fi
@@ -120,8 +121,12 @@ run_strategy_test() {
# Stop strategy # Stop strategy
echo " [*] Stopping $strategy_name..." echo " [*] Stopping $strategy_name..."
# Kill wrapper first, then cleanup_firewall will kill nfqws # Send SIGTERM to wrapper — it will cleanup firewall + nfqws via trap
kill "$strategy_pid" 2>/dev/null || true kill -TERM "$strategy_pid" 2>/dev/null || true
# Give trap time to fire and cleanup
sleep 2
# Ensure nfqws is gone
pkill -f "nfqws.*qnum=$NFQUEUE_NUM" 2>/dev/null || true
wait "$strategy_pid" 2>/dev/null || true wait "$strategy_pid" 2>/dev/null || true
cleanup_firewall >/dev/null 2>&1 || true cleanup_firewall >/dev/null 2>&1 || true
sleep 1 sleep 1
@@ -177,7 +182,7 @@ main() {
for strat in "${STRATEGIES[@]}"; do for strat in "${STRATEGIES[@]}"; do
if run_strategy_test "$strat"; then if run_strategy_test "$strat"; then
working_strategy="$strat" working_strategy="$strat"
working_desc="$(describe_strategy "$SCRIPT_DIR/$strat")" working_desc="$(describe_strategy "$SCRIPT_DIR/general_${strat}.sh")"
break break
fi fi
done done
@@ -186,7 +191,7 @@ main() {
echo "==============================================" echo "=============================================="
if [[ -n "$working_strategy" ]]; then if [[ -n "$working_strategy" ]]; then
print_green " WORKING STRATEGY FOUND!" print_green " WORKING STRATEGY FOUND!"
print_green " Strategy: ${working_strategy%.sh}" print_green " Strategy: $working_strategy"
print_green " Desc: $working_desc" print_green " Desc: $working_desc"
echo "==============================================" echo "=============================================="
echo "" echo ""
@@ -195,17 +200,17 @@ main() {
echo "[*] Auto-installing to systemd..." echo "[*] Auto-installing to systemd..."
# Write strategy marker directly # Write strategy marker directly
mkdir -p "$SCRIPT_DIR/.service" mkdir -p "$SCRIPT_DIR/.service"
echo "${working_strategy%.sh}" > "$SCRIPT_DIR/.service/installed_strategy" echo "$working_strategy" > "$SCRIPT_DIR/.service/installed_strategy"
local service_path="$SYSTEMD_DIR/zapret.service" local service_path="$SYSTEMD_DIR/zapret.service"
cat > "$service_path" <<EOF cat > "$service_path" <<EOF
[Unit] [Unit]
Description=Zapret DPI bypass (strategy: ${working_strategy%.sh}) Description=Zapret DPI bypass (strategy: $working_strategy)
After=network.target After=network.target
[Service] [Service]
Type=simple Type=simple
ExecStart=$SCRIPT_DIR/$working_strategy ExecStart=$SCRIPT_DIR/run_strategy.sh $working_strategy
Restart=on-failure Restart=on-failure
RestartSec=5 RestartSec=5
StandardOutput=journal StandardOutput=journal
@@ -228,12 +233,11 @@ EOF
echo "" echo ""
echo " sudo ./service.sh" echo " sudo ./service.sh"
echo " → 1. Install Service" echo " → 1. Install Service"
echo " → Choose: ${working_strategy%.sh}" echo " → Choose: $working_strategy"
echo "" echo ""
read -rp "Install this strategy to systemd now? [Y/n]: " ans read -rp "Install this strategy to systemd now? [Y/n]: " ans
if [[ "${ans:-Y}" == [yY]* ]]; then if [[ "${ans:-Y}" == [yY]* ]]; then
bash "$SCRIPT_DIR/service.sh" >&1 & bash "$SCRIPT_DIR/service.sh"
# The service.sh menu will handle installation
fi fi
fi fi
else else
@@ -243,7 +247,7 @@ EOF
echo "[*] Suggestions:" echo "[*] Suggestions:"
echo " - Try adding custom domains to lists/list-general-user.txt" echo " - Try adding custom domains to lists/list-general-user.txt"
echo " - Check that Secure DNS is enabled" echo " - Check that Secure DNS is enabled"
echo " - Try modifying strategy parameters manually in run_strategy.sh" echo " - Try modifying strategy parameters manually in strategies/*.conf"
echo " - Check diagnostics: sudo ./service.sh → 10. Run Diagnostics" echo " - Check diagnostics: sudo ./service.sh → 10. Run Diagnostics"
fi fi

15
ensure_wrappers.sh Normal file → Executable file
View File

@@ -10,22 +10,21 @@ for conf in "$SCRIPT_DIR/strategies"/*.conf; do
[[ -f "$conf" ]] || continue [[ -f "$conf" ]] || continue
name=$(basename "$conf" .conf) name=$(basename "$conf" .conf)
wrapper="$SCRIPT_DIR/general_${name}.sh" wrapper="$SCRIPT_DIR/general_${name}.sh"
# Skip general.sh as special case (name = general) # Skip general.sh as special case (name = general)
if [[ "$name" == "general" ]]; then if [[ "$name" == "general" ]]; then
wrapper="$SCRIPT_DIR/general.sh" wrapper="$SCRIPT_DIR/general.sh"
fi fi
if [[ ! -f "$wrapper" ]]; then # Always rewrite wrapper to ensure consistency (no BOM, correct shebang)
echo "[*] Creating wrapper: $(basename "$wrapper")$name" cat > "$wrapper" <<EOF
cat > "$wrapper" <<EOF
#!/bin/bash #!/bin/bash
# Auto-generated wrapper: $name # Auto-generated wrapper: $name
SCRIPT_DIR="\$(cd "\$(dirname "\${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
exec "\$SCRIPT_DIR/run_strategy.sh" "$name" exec "\$SCRIPT_DIR/run_strategy.sh" "$name"
EOF EOF
chmod +x "$wrapper" chmod +x "$wrapper"
fi echo "[*] Wrapper updated: $(basename "$wrapper")$name"
done done
echo "[OK] All wrappers checked." echo "[OK] All wrappers checked."

3
general.sh Normal file → Executable file
View File

@@ -1,4 +1,3 @@
#!/bin/bash #!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
exec "$SCRIPT_DIR/run_strategy.sh" "general" exec "$SCRIPT_DIR/run_strategy.sh" "general"

2
general_ALT.sh Normal file → Executable file
View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
exec "$SCRIPT_DIR/run_strategy.sh" "ALT" exec "$SCRIPT_DIR/run_strategy.sh" "ALT"

2
general_ALT10.sh Normal file → Executable file
View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
exec "$SCRIPT_DIR/run_strategy.sh" "ALT10" exec "$SCRIPT_DIR/run_strategy.sh" "ALT10"

2
general_ALT11.sh Normal file → Executable file
View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
exec "$SCRIPT_DIR/run_strategy.sh" "ALT11" exec "$SCRIPT_DIR/run_strategy.sh" "ALT11"

2
general_ALT2.sh Normal file → Executable file
View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
exec "$SCRIPT_DIR/run_strategy.sh" "ALT2" exec "$SCRIPT_DIR/run_strategy.sh" "ALT2"

2
general_ALT3.sh Normal file → Executable file
View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
exec "$SCRIPT_DIR/run_strategy.sh" "ALT3" exec "$SCRIPT_DIR/run_strategy.sh" "ALT3"

2
general_ALT4.sh Normal file → Executable file
View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
exec "$SCRIPT_DIR/run_strategy.sh" "ALT4" exec "$SCRIPT_DIR/run_strategy.sh" "ALT4"

2
general_ALT5.sh Normal file → Executable file
View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
exec "$SCRIPT_DIR/run_strategy.sh" "ALT5" exec "$SCRIPT_DIR/run_strategy.sh" "ALT5"

2
general_ALT6.sh Normal file → Executable file
View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
exec "$SCRIPT_DIR/run_strategy.sh" "ALT6" exec "$SCRIPT_DIR/run_strategy.sh" "ALT6"

2
general_ALT7.sh Normal file → Executable file
View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
exec "$SCRIPT_DIR/run_strategy.sh" "ALT7" exec "$SCRIPT_DIR/run_strategy.sh" "ALT7"

2
general_ALT8.sh Normal file → Executable file
View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
exec "$SCRIPT_DIR/run_strategy.sh" "ALT8" exec "$SCRIPT_DIR/run_strategy.sh" "ALT8"

2
general_ALT9.sh Normal file → Executable file
View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
exec "$SCRIPT_DIR/run_strategy.sh" "ALT9" exec "$SCRIPT_DIR/run_strategy.sh" "ALT9"

2
general_FAKE_TLS_AUTO.sh Normal file → Executable file
View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
exec "$SCRIPT_DIR/run_strategy.sh" "FAKE_TLS_AUTO" exec "$SCRIPT_DIR/run_strategy.sh" "FAKE_TLS_AUTO"

2
general_FAKE_TLS_AUTO_ALT.sh Normal file → Executable file
View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
exec "$SCRIPT_DIR/run_strategy.sh" "FAKE_TLS_AUTO_ALT" exec "$SCRIPT_DIR/run_strategy.sh" "FAKE_TLS_AUTO_ALT"

2
general_FAKE_TLS_AUTO_ALT2.sh Normal file → Executable file
View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
exec "$SCRIPT_DIR/run_strategy.sh" "FAKE_TLS_AUTO_ALT2" exec "$SCRIPT_DIR/run_strategy.sh" "FAKE_TLS_AUTO_ALT2"

2
general_FAKE_TLS_AUTO_ALT3.sh Normal file → Executable file
View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
exec "$SCRIPT_DIR/run_strategy.sh" "FAKE_TLS_AUTO_ALT3" exec "$SCRIPT_DIR/run_strategy.sh" "FAKE_TLS_AUTO_ALT3"

2
general_SIMPLE_FAKE.sh Normal file → Executable file
View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
exec "$SCRIPT_DIR/run_strategy.sh" "SIMPLE_FAKE" exec "$SCRIPT_DIR/run_strategy.sh" "SIMPLE_FAKE"

2
general_SIMPLE_FAKE_ALT.sh Normal file → Executable file
View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
exec "$SCRIPT_DIR/run_strategy.sh" "SIMPLE_FAKE_ALT" exec "$SCRIPT_DIR/run_strategy.sh" "SIMPLE_FAKE_ALT"

2
general_SIMPLE_FAKE_ALT2.sh Normal file → Executable file
View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
exec "$SCRIPT_DIR/run_strategy.sh" "SIMPLE_FAKE_ALT2" exec "$SCRIPT_DIR/run_strategy.sh" "SIMPLE_FAKE_ALT2"

0
install.sh Normal file → Executable file
View File

0
install_nfqws.sh Normal file → Executable file
View File

0
lib/download_helper.sh Normal file → Executable file
View File

0
lib/functions.sh Normal file → Executable file
View File

0
prepare_offline_bundle.sh Normal file → Executable file
View File

32
run_strategy.sh Normal file → Executable file
View File

@@ -2,8 +2,6 @@
# run_strategy.sh - Generic strategy runner using .conf files # run_strategy.sh - Generic strategy runner using .conf files
# Loads strategies/strategy_name.conf, substitutes variables, runs nfqws. # Loads strategies/strategy_name.conf, substitutes variables, runs nfqws.
# set -e removed: nfqws may exit non-zero on SIGTERM; empty arrays are fine
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/lib/functions.sh" source "$SCRIPT_DIR/lib/functions.sh"
@@ -102,4 +100,32 @@ done < "$TMP_ARGS"
rm -f "$TMP_ARGS" rm -f "$TMP_ARGS"
trap - EXIT trap - EXIT
run_nfqws "$0" "${CLEAN_ARGS[@]}" # Setup firewall and start nfqws
check_nfqws || exit 1
tcp_enable_timestamps
setup_firewall
# Trap cleanup on SIGTERM/SIGINT (e.g. from systemd or autotest kill)
cleanup_strategy() {
print_yellow ""
print_yellow "[*] Caught stop signal, cleaning up..."
pkill -f "nfqws.*qnum=$NFQUEUE_NUM" 2>/dev/null || true
cleanup_firewall >/dev/null 2>&1 || true
exit 0
}
trap cleanup_strategy SIGTERM SIGINT
echo ""
print_cyan "[*] Starting strategy: $STRATEGY"
print_cyan "[*] $(describe_strategy "$SCRIPT_DIR/general_${STRATEGY}.sh")"
echo ""
# Start nfqws in background so this shell handles signals and cleanup
"$BIN_DIR/nfqws" --qnum=$NFQUEUE_NUM "${CLEAN_ARGS[@]}" &
NFQWS_PID=$!
wait "$NFQWS_PID"
EXIT_CODE=$?
# If nfqws exited on its own, cleanup firewall
cleanup_firewall >/dev/null 2>&1 || true
exit $EXIT_CODE

33
service.sh Normal file → Executable file
View File

@@ -126,16 +126,14 @@ service_install() {
while IFS= read -r -d '' f; do while IFS= read -r -d '' f; do
local name local name
name=$(basename "$f") name=$(basename "$f")
[[ "$name" == service.sh ]] && continue # Only list strategy wrappers (general*.sh), skip service/utility scripts
[[ "$name" == run_strategy.sh ]] && continue [[ "$name" == general*.sh ]] || continue
[[ "$name" == install_nfqws.sh ]] && continue
[[ "$name" == lib ]] && continue
files+=("$f") files+=("$f")
local desc local desc
desc=$(describe_strategy "$f") desc=$(describe_strategy "$f")
printf " %2d. %-35s %s\n" "$i" "$name" "$desc" printf " %2d. %-35s %s\n" "$i" "$name" "$desc"
((i++)) ((i++))
done < <(find "$SCRIPT_DIR" -maxdepth 1 -type f -name '*.sh' -print0 | sort -z) done < <(find "$SCRIPT_DIR" -maxdepth 1 -type f -name 'general*.sh' -print0 | sort -z)
echo "" echo ""
read -rp " Input file index (number): " choice read -rp " Input file index (number): " choice
@@ -156,8 +154,8 @@ service_install() {
echo "" echo ""
echo "[*] Installing strategy: $strategy_name" echo "[*] Installing strategy: $strategy_name"
# Stop any existing service # Stop any existing service (internal — no prompts)
service_remove >/dev/null 2>&1 || true service_remove_internal > /dev/null 2>&1 || true
# Write strategy marker # Write strategy marker
mkdir -p "$SCRIPT_DIR/.service" mkdir -p "$SCRIPT_DIR/.service"
@@ -172,7 +170,7 @@ After=network.target
[Service] [Service]
Type=simple Type=simple
ExecStart=$selected ExecStart=$SCRIPT_DIR/run_strategy.sh $strategy_name
Restart=on-failure Restart=on-failure
RestartSec=5 RestartSec=5
StandardOutput=journal StandardOutput=journal
@@ -195,19 +193,16 @@ EOF
else else
echo "" echo ""
print_yellow "[!] systemctl not found. Service file created but not installed automatically." print_yellow "[!] systemctl not found. Service file created but not installed automatically."
echo " To start manually: $selected" echo " To start manually: $SCRIPT_DIR/run_strategy.sh $strategy_name"
fi fi
read -rp "Press Enter to continue..." read -rp "Press Enter to continue..."
} }
# ============================================ # ============================================
# SERVICE REMOVE # SERVICE REMOVE (internal — no prompts)
# ============================================ # ============================================
service_remove() { service_remove_internal() {
echo ""
echo "[*] Removing services..."
# Stop systemd service # Stop systemd service
if command -v systemctl >/dev/null 2>&1; then if command -v systemctl >/dev/null 2>&1; then
systemctl stop zapret.service 2>/dev/null || true systemctl stop zapret.service 2>/dev/null || true
@@ -225,6 +220,16 @@ service_remove() {
# Remove markers # Remove markers
rm -f "$SCRIPT_DIR/.service/installed_strategy" rm -f "$SCRIPT_DIR/.service/installed_strategy"
}
# ============================================
# SERVICE REMOVE (interactive)
# ============================================
service_remove() {
echo ""
echo "[*] Removing services..."
service_remove_internal
echo "" echo ""
print_green "[OK] Services removed." print_green "[OK] Services removed."

2
setup.sh Normal file → Executable file
View File

@@ -60,7 +60,7 @@ if [[ ${#missing[@]} -gt 0 ]]; then
case "$DISTRO" in case "$DISTRO" in
ubuntu|debian|linuxmint|pop) ubuntu|debian|linuxmint|pop)
apt-get update apt-get update
apt-get install -y curl git make gcc build-essential apt-get install -y curl git make gcc build-essential libmnl-dev zlib1g-dev
;; ;;
arch|manjaro) arch|manjaro)
pacman -Syu --noconfirm curl git make gcc pacman -Syu --noconfirm curl git make gcc

0
sync_from_upstream.sh Normal file → Executable file
View File

0
update.sh Normal file → Executable file
View File

0
utils/test_zapret.sh Normal file → Executable file
View File