фикс: исправлено чтение VPS_HOST при автоопределении (v1.0.8)
This commit is contained in:
parent
7b8bd4aa24
commit
df256ede0e
17
rproxy
17
rproxy
|
|
@ -3,7 +3,7 @@
|
||||||
# Публикация локальных сервисов через SSH-туннели + nginx на VPS
|
# Публикация локальных сервисов через SSH-туннели + nginx на VPS
|
||||||
# http://5.104.75.50:3000/Petro1990/rProxy
|
# http://5.104.75.50:3000/Petro1990/rProxy
|
||||||
|
|
||||||
VERSION="1.0.6"
|
VERSION="1.0.8"
|
||||||
CONF_DIR="/opt/etc/rproxy"
|
CONF_DIR="/opt/etc/rproxy"
|
||||||
CONF_FILE="$CONF_DIR/rproxy.conf"
|
CONF_FILE="$CONF_DIR/rproxy.conf"
|
||||||
SERVICES_DIR="$CONF_DIR/services"
|
SERVICES_DIR="$CONF_DIR/services"
|
||||||
|
|
@ -296,29 +296,24 @@ show_status() {
|
||||||
# ПОМОЩНИКИ VPS
|
# ПОМОЩНИКИ VPS
|
||||||
# ══════════════════════════════════════════════════════════════════════
|
# ══════════════════════════════════════════════════════════════════════
|
||||||
|
|
||||||
|
|
||||||
find_vps_by_domain() {
|
find_vps_by_domain() {
|
||||||
local dom="$1"
|
local dom="$1"
|
||||||
msg "Отладка: Резолвлю $dom..." >&2
|
|
||||||
# Пытаемся получить IP через ping (BusyBox стиль)
|
# Пытаемся получить IP через ping (BusyBox стиль)
|
||||||
local ip=$(ping -c 1 "$dom" 2>/dev/null | grep -o "[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}" | head -n 1)
|
local ip=$(ping -c 1 "$dom" 2>/dev/null | grep -o "[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}" | head -n 1)
|
||||||
# Если не вышло, пробуем nslookup (парсим более надежно через grep -o)
|
# Если не вышло, пробуем nslookup (парсим более надежно через grep -o)
|
||||||
[ -z "$ip" ] && ip=$(nslookup "$dom" 2>/dev/null | grep "Address" | tail -n 1 | grep -o "[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}" | head -n 1)
|
[ -z "$ip" ] && ip=$(nslookup "$dom" 2>/dev/null | grep "Address" | tail -n 1 | grep -o "[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}" | head -n 1)
|
||||||
|
|
||||||
msg "Отладка: Получен IP: '$ip'" >&2
|
|
||||||
[ -z "$ip" ] && return 1
|
[ -z "$ip" ] && return 1
|
||||||
|
|
||||||
for f in "$VPS_DIR"/*.conf; do
|
for f in "$VPS_DIR"/*.conf; do
|
||||||
[ -f "$f" ] || continue
|
[ -f "$f" ] || continue
|
||||||
(
|
# Используем grep для извлечения IP из конфига (быстрее и надежнее источника)
|
||||||
VPS_HOST=""
|
local v_host=$(grep "VPS_HOST=" "$f" | cut -d'"' -f2)
|
||||||
. "$f"
|
if [ "$v_host" = "$ip" ]; then
|
||||||
msg "Отладка: Сравниваю с VPS '$(basename "$f" .conf)' (HOST: $VPS_HOST)" >&2
|
|
||||||
if [ "$VPS_HOST" = "$ip" ]; then
|
|
||||||
basename "$f" .conf
|
basename "$f" .conf
|
||||||
exit 0
|
return 0
|
||||||
fi
|
fi
|
||||||
exit 1
|
|
||||||
) && { basename "$f" .conf; return 0; }
|
|
||||||
done
|
done
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue