From cb2bb86950a54dd05f4c3beeeab1dbfc19f17ca5 Mon Sep 17 00:00:00 2001 From: yanistyle Date: Sun, 11 Oct 2026 23:22:38 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20install.sh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index a50dc33..a60feea 100644 --- a/install.sh +++ b/install.sh @@ -1,3 +1,4 @@ + #!/bin/sh [ -f "/etc/openwrt_release" ] || { printf "\033[1;31m[!] Ошибка: Эта система не OpenWrt.\033[0m\n"; exit 1; } @@ -233,6 +234,85 @@ cd / rm -rf "$WORK_DIR" restore_dns +# Проверяем, что есть всё, чего ждёт PodKop от пакета sing-box +# (init-скрипт, UCI-конфиг, рабочие папки). Если стоковый пакет не ставился, +# например PodKop поставлен без зависимостей, создаём недостающее. +ensure_service_files() { + printf "${C}[*] Проверяю файлы службы sing-box...${N}\n" + mkdir -p /etc/sing-box /usr/share/sing-box + + if [ -f /etc/config/sing-box ]; then + printf "${G}[+] /etc/config/sing-box найден.${N}\n" + else + printf "${Y}[!] /etc/config/sing-box не найден, создаю.${N}\n" + cat > /etc/config/sing-box <<'EOF' +config sing-box 'main' + option enabled '0' + option user 'root' + option conffile '/etc/sing-box/config.json' + option workdir '/usr/share/sing-box' +# list ifaces 'wan' +# list ifaces 'wan6' +EOF + fi + + if [ -f /etc/init.d/sing-box ]; then + printf "${G}[+] /etc/init.d/sing-box найден.${N}\n" + else + printf "${Y}[!] /etc/init.d/sing-box не найден, создаю.${N}\n" + cat > /etc/init.d/sing-box <<'EOF' +#!/bin/sh /etc/rc.common + +USE_PROCD=1 +START=99 +STOP=10 + +PROG=/usr/bin/sing-box + +start_service() { + config_load sing-box + + local enabled user conffile workdir ifaces + config_get_bool enabled "main" "enabled" "0" + [ "$enabled" -eq 1 ] || return 0 + + config_get user "main" "user" "root" + config_get conffile "main" "conffile" "/etc/sing-box/config.json" + config_get workdir "main" "workdir" "/usr/share/sing-box" + config_get ifaces "main" "ifaces" + + mkdir -p "$workdir" + [ "$user" = "root" ] || chown "$user:$(id -ng "$user")" "$workdir" + + procd_open_instance + procd_set_param command "$PROG" run -c "$conffile" -D "$workdir" + procd_set_param user "$user" + procd_set_param file "$conffile" + procd_set_param stdout 1 + procd_set_param stderr 1 + procd_set_param respawn + procd_close_instance +} + +service_triggers() { + local ifaces iface + config_load sing-box + config_get ifaces "main" "ifaces" + + procd_open_trigger + for iface in $ifaces; do + procd_add_interface_trigger "interface.*.up" "$iface" /etc/init.d/sing-box restart + done + procd_close_trigger + procd_add_reload_trigger "sing-box" +} +EOF + chmod +x /etc/init.d/sing-box + fi +} + +ensure_service_files + printf "${C}[*] Запускаю сервис...${N}\n" /etc/init.d/"$SERVICE_NAME" start >/dev/null 2>&1 || printf "${Y}[!] Не удалось запустить службу. Проверьте логи.${N}\n" @@ -241,4 +321,4 @@ if [ "$ZB_STOPPED" = "1" ]; then /etc/init.d/zeroblock start >/dev/null 2>&1 || printf "${Y}[!] Не удалось запустить Zero-Block.${N}\n" fi -printf "\n${G}[+] Установка завершена:${N} ${Y}${CURRENT_VER:-н/д}${N} -> ${Y}${NEW_VER}${N}\n" +printf "\n${G}[+] Установка завершена:${N} ${Y}${CURRENT_VER:-н/д}${N} -> ${Y}${NEW_VER}${N}\n" \ No newline at end of file