mirror of
https://github.com/necronicle/z2k.git
synced 2026-04-28 03:20:25 +00:00
Critical: CRLF→LF in hostlists (broke nfqws2 matching), die in pipe subshell (errors silently ignored), update_z2k /bin/sh overwrite guard, missing quic_rutracker blob registration, telemetry race condition (multi-process merge). Security: sed injection via user input → grep -vxF, grep -qx → -qxF for domain matching, chmod 777/666 → 755/644 + chown nobody, predictable /tmp/z2k cleanup before mkdir. High: PID path mismatch /opt/var/run → /var/run, zapret2_nat chain in cleanup, orphaned tcpdump on monitor stop, cross-filesystem mv → cp+rm, base.sh re-source clobber fix. Medium: version mismatch, root check for default install path, early exit for help/version, backup/restore dir fix, awk special chars, HTTP RKN failure_detector, youtube_tcp_tcp typo, hostlist warning, kernel module regex anchoring, state eviction + locking in Lua. Dead code removed (~200 lines): check_installation_status, menu_view_strategy, apply_category_strategies, update_init_section, get_init_tcp/udp_params, TEST_DOMAINS, HTTP_STRATEGIES_CONF, check_keenetic_specifics, discord_tcp variable. Added .gitattributes to enforce LF line endings. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
72 lines
2.3 KiB
Bash
72 lines
2.3 KiB
Bash
#!/bin/sh
|
|
# lib/system_init.sh - Инициализация системных переменных для z2k
|
|
# Заменяет вызов check_system() из zapret2/common/installer.sh
|
|
|
|
# ==============================================================================
|
|
# ОПРЕДЕЛЕНИЕ ТИПА СИСТЕМЫ
|
|
# ==============================================================================
|
|
|
|
init_system_vars() {
|
|
print_info "Определение типа системы..."
|
|
|
|
# Определить OS
|
|
UNAME=$(uname -s)
|
|
|
|
# Определить подсистему
|
|
SUBSYS=""
|
|
|
|
# Для Linux определить тип init системы
|
|
if [ "$UNAME" = "Linux" ]; then
|
|
# Проверить systemd
|
|
if command -v systemctl >/dev/null 2>&1 && systemctl --version >/dev/null 2>&1; then
|
|
SYSTEM="systemd"
|
|
SYSTEMCTL="systemctl"
|
|
INIT="systemd"
|
|
# Проверить OpenRC
|
|
elif [ -f /sbin/openrc-run ] || [ -f /usr/sbin/openrc-run ]; then
|
|
SYSTEM="openrc"
|
|
INIT="openrc"
|
|
# Проверить OpenWrt/Keenetic (procd)
|
|
elif [ -f /etc/openwrt_release ] || [ -f /opt/etc/init.d/rc.func ]; then
|
|
SYSTEM="openwrt"
|
|
INIT="procd"
|
|
# Generic Linux (SysV init или custom)
|
|
else
|
|
SYSTEM="linux"
|
|
INIT="sysv"
|
|
fi
|
|
|
|
print_success "Система: $SYSTEM (init: $INIT)"
|
|
|
|
elif [ "$UNAME" = "FreeBSD" ] || [ "$UNAME" = "OpenBSD" ]; then
|
|
SYSTEM="bsd"
|
|
INIT="rc"
|
|
print_success "Система: BSD"
|
|
|
|
elif [ "$UNAME" = "Darwin" ]; then
|
|
SYSTEM="macos"
|
|
INIT="launchd"
|
|
print_success "Система: macOS"
|
|
|
|
else
|
|
print_warning "Неизвестная система: $UNAME"
|
|
SYSTEM="unknown"
|
|
INIT="unknown"
|
|
fi
|
|
|
|
# Экспортировать переменные для использования в других модулях
|
|
export SYSTEM
|
|
export SUBSYS
|
|
export UNAME
|
|
export INIT
|
|
export SYSTEMCTL
|
|
|
|
# Показать детали
|
|
print_info "Переменные окружения:"
|
|
print_info " SYSTEM=$SYSTEM"
|
|
print_info " UNAME=$UNAME"
|
|
print_info " INIT=$INIT"
|
|
[ -n "$SYSTEMCTL" ] && print_info " SYSTEMCTL=$SYSTEMCTL"
|
|
|
|
return 0
|
|
}
|