From 9e7176274a0b98e6b41eff8c9f6b2f3ef0d261a6 Mon Sep 17 00:00:00 2001 From: maksarsanjeev Date: Sat, 10 Oct 2026 03:01:50 +0300 Subject: [PATCH] ops installer: take secrets from ~/.brovops-sub and ~/.brovops-token So the install can run non-interactively over SSH: the files are moved into /etc/brov-ops and deleted; hidden prompts remain as the fallback in a terminal. Co-Authored-By: Claude Opus 5.5 --- ops/deploy/install.sh | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/ops/deploy/install.sh b/ops/deploy/install.sh index 66c0f75..df10b54 100644 --- a/ops/deploy/install.sh +++ b/ops/deploy/install.sh @@ -6,8 +6,10 @@ # /etc/brov-ops (root, 600). Telegram and Claude go through a local proxy core (mihomo in # proxy mode on 127.0.0.1:7890 — only this service uses it, the VM itself is not tunnelled). # -# Asks (hidden input) for the VLESS subscription URL and the Telegram bot token on the -# first run. The first person to send /start to the bot becomes its owner. +# Secrets on the first run: the VLESS subscription URL and the Telegram bot token are taken +# from ~/.brovops-sub and ~/.brovops-token of the user running sudo (moved into +# /etc/brov-ops and deleted), or asked for with hidden input when run from a terminal. +# The first person to send /start to the bot becomes its owner. set -e [ "$(id -u)" -eq 0 ] || { echo "Запусти через sudo: sudo sh $0"; exit 1; } @@ -38,13 +40,19 @@ if [ "$(sha256sum /usr/local/bin/mihomo 2>/dev/null | cut -d' ' -f1)" != "$MIHOM install -m 755 "$TMP/mihomo" /usr/local/bin/mihomo rm -rf "$TMP" fi +USER_HOME=$(getent passwd "${SUDO_USER:-root}" | cut -d: -f6) +take_file() { # ~/.brovops- → stdout, then removed + f="$USER_HOME/.brovops-$1" + [ -f "$f" ] && [ ! -L "$f" ] && { cat "$f"; rm -f "$f"; } +} ask_secret() { # prompt → stdout, input not echoed printf "%s" "$1" > /dev/tty stty -echo < /dev/tty; read -r v < /dev/tty; stty echo < /dev/tty; echo > /dev/tty printf "%s" "$v" } if [ ! -s $PROXY_DIR/vless.sub ]; then - ask_secret "Ссылка подписки VLESS (ввод скрыт): " > $PROXY_DIR/vless.sub + take_file sub > $PROXY_DIR/vless.sub + [ -s $PROXY_DIR/vless.sub ] || ask_secret "Ссылка подписки VLESS (ввод скрыт): " > $PROXY_DIR/vless.sub [ -s $PROXY_DIR/vless.sub ] || { echo "✗ подписка не введена"; exit 1; } fi SUB=$(head -n1 $PROXY_DIR/vless.sub | tr -d '\r\n ') @@ -102,7 +110,8 @@ if [ ! -f $ETC/config.env ]; then -e "s|^WHISPER_MODEL=.*|WHISPER_MODEL=$WHISPER|" "$HERE/deploy/config.env.example" > $ETC/config.env fi if ! grep -q "^TELEGRAM_TOKEN=." $ETC/config.env; then - TOK=$(ask_secret "Токен бота от @BotFather (ввод скрыт): ") + TOK=$(take_file token) + [ -n "$TOK" ] || TOK=$(ask_secret "Токен бота от @BotFather (ввод скрыт): ") if [ -n "$TOK" ]; then grep -v "^TELEGRAM_TOKEN=" $ETC/config.env > $ETC/config.env.new echo "TELEGRAM_TOKEN=$TOK" >> $ETC/config.env.new