ops: installer asks for the subscription and bot token; first /start claims the bot

- install.sh prompts (hidden) for the VLESS subscription URL and the Telegram token on
  the first run, and picks Whisper base on VMs under 3.5 GB RAM.
- The owner chat no longer has to be looked up: whoever sends /start first becomes the
  owner (saved in the settings table); OWNER_CHAT_ID still overrides.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
maksarsanjeev
2026-10-10 02:55:02 +03:00
parent 80990bbbcd
commit 14c1f740d9
4 changed files with 59 additions and 18 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
# Telegram bot token from @BotFather (revoke and reissue if it was ever pasted anywhere).
TELEGRAM_TOKEN=
# Your chat id: start the bot, send /start, it tells you the number.
# Optional: fixed owner chat id. Empty = whoever sends /start first becomes the owner.
OWNER_CHAT_ID=
# Token BroV uses for the API (install.sh generates one).
+27 -9
View File
@@ -6,8 +6,8 @@
# /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).
#
# Before the first run put the VLESS subscription URL into /etc/brov-ops/proxy/vless.sub
# (one line). After it: fill /etc/brov-ops/config.env, log Claude in (printed at the end).
# 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.
set -e
[ "$(id -u)" -eq 0 ] || { echo "Запусти через sudo: sudo sh $0"; exit 1; }
@@ -38,7 +38,15 @@ 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
[ -s $PROXY_DIR/vless.sub ] || { echo "✗ положи ссылку подписки VLESS в $PROXY_DIR/vless.sub и запусти снова"; exit 1; }
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
[ -s $PROXY_DIR/vless.sub ] || { echo "✗ подписка не введена"; exit 1; }
fi
SUB=$(head -n1 $PROXY_DIR/vless.sub | tr -d '\r\n ')
umask 077
cat > $PROXY_DIR/config.yaml <<EOF
@@ -87,8 +95,19 @@ fi
echo "→ Настройки"
if [ ! -f $ETC/config.env ]; then
# Whisper "small" needs ~1 GB on top of Claude: on a small VM take "base".
MEM_MB=$(awk '/MemTotal/ {print int($2/1024)}' /proc/meminfo)
WHISPER=small; [ "$MEM_MB" -lt 3500 ] && WHISPER=base
sed -e "s|^API_TOKEN=.*|API_TOKEN=$(openssl rand -hex 24)|" -e "s|^CLAUDE_BIN=.*|CLAUDE_BIN=$CLAUDE|" \
"$HERE/deploy/config.env.example" > $ETC/config.env
-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 (ввод скрыт): ")
if [ -n "$TOK" ]; then
grep -v "^TELEGRAM_TOKEN=" $ETC/config.env > $ETC/config.env.new
echo "TELEGRAM_TOKEN=$TOK" >> $ETC/config.env.new
mv $ETC/config.env.new $ETC/config.env
fi
fi
chown root:root $ETC/config.env
chmod 600 $ETC/config.env # systemd reads it as root; the service only sees its variables
@@ -103,10 +122,9 @@ systemctl is-active --quiet brov-ops && echo "✓ brov-ops работает" ||
cat <<EOF
Дальше (один раз):
1. sudo nano $ETC/config.env — TELEGRAM_TOKEN (новый, после /revoke), потом OWNER_CHAT_ID
2. Войти в Claude под своей подпиской:
1. Войти в Claude под своей подпиской:
sudo -u brovops -H env HTTPS_PROXY=$PROXY HTTP_PROXY=$PROXY $CLAUDE
(в нём /login, потом /exit)
3. sudo systemctl restart brov-ops
Токен для BroV (API_TOKEN) — в $ETC/config.env.
(в нём /login, потом /exit), затем: sudo systemctl restart brov-ops
2. Написать боту /start — первый, кто напишет, станет владельцем.
Токен для BroV (API_TOKEN): sudo grep API_TOKEN $ETC/config.env
EOF