ops installer: server list from a file when the subscription page is blocked
From the homelab the subscription host times out while the VLESS node itself is reachable: ~/.brovops-nodes (the subscription content) becomes a file provider; the URL provider stays optional. take_file no longer trips set -e on a missing file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+32
-15
@@ -44,18 +44,42 @@ USER_HOME=$(getent passwd "${SUDO_USER:-root}" | cut -d: -f6)
|
||||
take_file() { # ~/.brovops-<name> → stdout, then removed
|
||||
f="$USER_HOME/.brovops-$1"
|
||||
[ -f "$f" ] && [ ! -L "$f" ] && { cat "$f"; rm -f "$f"; }
|
||||
return 0 # a missing file is fine (set -e would stop the install)
|
||||
}
|
||||
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
|
||||
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; }
|
||||
# Server list: the subscription content as a file (~/.brovops-nodes — when the subscription
|
||||
# page itself is blocked from here) and/or the subscription URL (~/.brovops-sub).
|
||||
NODES=$(take_file nodes); [ -n "$NODES" ] && printf '%s\n' "$NODES" > $PROXY_DIR/nodes.txt
|
||||
SUBURL=$(take_file sub); [ -n "$SUBURL" ] && printf '%s\n' "$SUBURL" > $PROXY_DIR/vless.sub
|
||||
if [ ! -s $PROXY_DIR/nodes.txt ] && [ ! -s $PROXY_DIR/vless.sub ]; then
|
||||
ask_secret "Ссылка подписки VLESS (ввод скрыт): " > $PROXY_DIR/vless.sub
|
||||
[ -s $PROXY_DIR/vless.sub ] || { echo "✗ нет ни подписки, ни списка серверов"; exit 1; }
|
||||
fi
|
||||
PROVIDERS=""; USE=""
|
||||
if [ -s $PROXY_DIR/nodes.txt ]; then
|
||||
PROVIDERS="$PROVIDERS
|
||||
nodes:
|
||||
type: file
|
||||
path: ./nodes.txt
|
||||
health-check: {enable: true, url: \"https://www.gstatic.com/generate_204\", interval: 300}"
|
||||
USE="nodes"
|
||||
fi
|
||||
if [ -s $PROXY_DIR/vless.sub ]; then
|
||||
SUB=$(head -n1 $PROXY_DIR/vless.sub | tr -d '\r\n ')
|
||||
PROVIDERS="$PROVIDERS
|
||||
vless:
|
||||
type: http
|
||||
url: \"$SUB\"
|
||||
path: ./vless.yaml
|
||||
interval: 43200
|
||||
proxy: DIRECT
|
||||
health-check: {enable: true, url: \"https://www.gstatic.com/generate_204\", interval: 300}"
|
||||
USE="${USE:+$USE, }vless"
|
||||
fi
|
||||
umask 077
|
||||
cat > $PROXY_DIR/config.yaml <<EOF
|
||||
# Generated by install.sh — proxy for brov-ops only (no TUN, nothing system-wide).
|
||||
@@ -65,22 +89,15 @@ allow-lan: false
|
||||
mode: rule
|
||||
log-level: warning
|
||||
ipv6: false
|
||||
proxy-providers:
|
||||
vless:
|
||||
type: http
|
||||
url: "$SUB"
|
||||
path: ./vless.yaml
|
||||
interval: 43200
|
||||
proxy: DIRECT
|
||||
health-check: {enable: true, url: "https://www.gstatic.com/generate_204", interval: 300}
|
||||
proxy-providers:$PROVIDERS
|
||||
proxy-groups:
|
||||
- {name: out, type: url-test, use: [vless], url: "https://www.gstatic.com/generate_204", interval: 120, tolerance: 100}
|
||||
- {name: out, type: url-test, use: [$USE], url: "https://www.gstatic.com/generate_204", interval: 120, tolerance: 100}
|
||||
rules:
|
||||
- MATCH,out
|
||||
EOF
|
||||
umask 022
|
||||
chown brovops:brovops $PROXY_DIR/config.yaml $PROXY_DIR/vless.sub
|
||||
chmod 600 $PROXY_DIR/config.yaml $PROXY_DIR/vless.sub
|
||||
chown -R brovops:brovops $PROXY_DIR
|
||||
chmod 600 $PROXY_DIR/*
|
||||
install -m 644 "$HERE/deploy/brov-ops-proxy.service" /etc/systemd/system/
|
||||
systemctl daemon-reload
|
||||
systemctl enable --now brov-ops-proxy >/dev/null
|
||||
|
||||
Reference in New Issue
Block a user