feat: VictoriaMetrics и NetBird между панелью и ger-nod-02
ansible-core-net / deploy (push) Canceled after 0s
ansible-core-secrets / deploy (push) Canceled after 0s
ansible-ger-nod-02 / deploy (push) Canceled after 0s
ansible-opnsense / deploy (push) Canceled after 0s
ansible-core-mon / deploy (push) Successful in 58s
ansible-rus-central / deploy (push) Successful in 44s
ansible-core-net / deploy (push) Canceled after 0s
ansible-core-secrets / deploy (push) Canceled after 0s
ansible-ger-nod-02 / deploy (push) Canceled after 0s
ansible-opnsense / deploy (push) Canceled after 0s
ansible-core-mon / deploy (push) Successful in 58s
ansible-rus-central / deploy (push) Successful in 44s
Prometheus остаётся для LAN. Нода отдаёт метрики через vmagent, а панель ходит на неё по отдельному ключу NetBird, не через группу роутеров. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
5704272c18
commit
72a9c86e52
46 files changed
+13496
-25
No files matched your search
@@ -10,6 +10,7 @@ admin_created=0
|
||||
token_updated=0
|
||||
profile_created=0
|
||||
node_created=0
|
||||
node_address_updated=0
|
||||
host_created=0
|
||||
node_secret=""
|
||||
active_token="${RW_API_TOKEN:-}"
|
||||
@@ -20,7 +21,7 @@ redact_json() {
|
||||
jq 'walk(
|
||||
if type == "object" then
|
||||
with_entries(
|
||||
if (.key | test("(?i)privateKey|privKey|secretKey|SECRET_KEY|accessToken|apiToken|password|^token$|vlessUuid|trojanPassword|ssPassword|shortUuid|subscriptionUrl"))
|
||||
if (.key | test("(?i)privateKey|privKey|secretKey|SECRET_KEY|accessToken|apiToken|password|^token$|vlessUuid|trojanPassword|ssPassword|shortUuid|subscriptionUrl|setupKey|setup_key|METRICS_PASS"))
|
||||
then .value = "[REDACTED]"
|
||||
else .
|
||||
end
|
||||
@@ -223,20 +224,29 @@ if [ -z "${node_uuid}" ]; then
|
||||
node_created=1
|
||||
fi
|
||||
|
||||
current_addr=$(printf '%s' "${nodes_json}" | jq -r --arg n "$RW_NODE_NAME" '(.response // []) | map(select(.name == $n)) | .[0].address // empty')
|
||||
if [ -n "${RW_NODE_ADDR}" ] && [ "${current_addr}" != "${RW_NODE_ADDR}" ]; then
|
||||
node_address_updated=1
|
||||
fi
|
||||
node_update=$(jq -n \
|
||||
--arg u "$node_uuid" \
|
||||
--arg pu "$profile_uuid" \
|
||||
--arg iu "$inbound_uuid" \
|
||||
--arg addr "$RW_NODE_ADDR" \
|
||||
--argjson port "$RW_NODE_PORT" \
|
||||
'{
|
||||
uuid: $u,
|
||||
address: $addr,
|
||||
port: $port,
|
||||
configProfile: {
|
||||
activeConfigProfileUuid: $pu,
|
||||
activeInbounds: [$iu]
|
||||
}
|
||||
}')
|
||||
api PATCH /nodes/ -d "${node_update}" >/dev/null 2>&1 \
|
||||
|| api PUT /nodes/ -d "${node_update}" >/dev/null 2>&1 \
|
||||
|| true
|
||||
if ! api PATCH /nodes/ -d "${node_update}" >/dev/null \
|
||||
&& ! api PUT /nodes/ -d "${node_update}" >/dev/null; then
|
||||
echo "WARN: не удалось обновить адрес ноды ${RW_NODE_NAME}" >&2
|
||||
fi
|
||||
|
||||
hosts_json=$(api GET /hosts/)
|
||||
host_uuid=$(printf '%s' "${hosts_json}" | jq -r --arg a "$RW_SELFSTEAL" '
|
||||
@@ -420,11 +430,33 @@ if [ -n "${RW_USERS_FILE:-}" ] && [ -f "${RW_USERS_FILE}" ]; then
|
||||
done < <(printf '%s' "${existing}" | jq -r '.response.users[]? | "\(.username)\t\(.uuid)"')
|
||||
fi
|
||||
|
||||
xray_url=""
|
||||
xray_user="${RW_XRAY_USER:-homelab}"
|
||||
if [ -n "${xray_user}" ]; then
|
||||
users_now=$(api GET "/users/?size=500" || api GET /users/ || echo '{}')
|
||||
xray_url=$(printf '%s' "${users_now}" | jq -r --arg u "${xray_user}" '
|
||||
.response.users[]? | select(.username == $u) | .subscriptionUrl // empty' | head -1)
|
||||
if [ -z "${xray_url}" ]; then
|
||||
short=$(printf '%s' "${users_now}" | jq -r --arg u "${xray_user}" '
|
||||
.response.users[]? | select(.username == $u) | .shortUuid // empty' | head -1)
|
||||
if [ -n "${short}" ] && [ -n "${RW_SUB_DOMAIN:-}" ]; then
|
||||
xray_url="https://${RW_SUB_DOMAIN}/${short}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
xray_saved=0
|
||||
if [ -n "${xray_url}" ]; then
|
||||
xray_saved=1
|
||||
fi
|
||||
|
||||
# Секреты только в файл 0600. В stdout — статус без значений ключей.
|
||||
secrets_file="${RW_SECRETS_FILE:-/opt/remnawave/.bootstrap-secrets.json}"
|
||||
umask 077
|
||||
jq -n --arg api_token "${active_token}" --arg node_secret "${node_secret}" \
|
||||
'{api_token: $api_token, node_secret: $node_secret}' > "${secrets_file}"
|
||||
jq -n \
|
||||
--arg api_token "${active_token}" \
|
||||
--arg node_secret "${node_secret}" \
|
||||
--arg xray_url "${xray_url}" \
|
||||
'{api_token: $api_token, node_secret: $node_secret, xray_checker_subscription_url: $xray_url}' > "${secrets_file}"
|
||||
chmod 600 "${secrets_file}"
|
||||
|
||||
jq -n \
|
||||
@@ -432,22 +464,28 @@ jq -n \
|
||||
--arg node_uuid "${node_uuid}" \
|
||||
--arg host_uuid "${host_uuid}" \
|
||||
--arg reality_pub "${pub}" \
|
||||
--arg node_address "${RW_NODE_ADDR}" \
|
||||
--argjson admin_created "${admin_created}" \
|
||||
--argjson token_updated "${token_updated}" \
|
||||
--argjson profile_created "${profile_created}" \
|
||||
--argjson node_created "${node_created}" \
|
||||
--argjson node_address_updated "${node_address_updated}" \
|
||||
--argjson host_created "${host_created}" \
|
||||
--argjson users_changed "${users_changed}" \
|
||||
--argjson xray_saved "${xray_saved}" \
|
||||
'{
|
||||
profile_uuid: $profile_uuid,
|
||||
node_uuid: $node_uuid,
|
||||
host_uuid: $host_uuid,
|
||||
node_address: $node_address,
|
||||
reality_public_key: $reality_pub,
|
||||
admin_created: ($admin_created == 1),
|
||||
token_updated: ($token_updated == 1),
|
||||
profile_created: ($profile_created == 1),
|
||||
node_created: ($node_created == 1),
|
||||
node_address_updated: ($node_address_updated == 1),
|
||||
host_created: ($host_created == 1),
|
||||
users_changed: ($users_changed == 1),
|
||||
changed: (($admin_created + $token_updated + $profile_created + $node_created + $host_created + $users_changed) > 0)
|
||||
xray_checker_url_saved: ($xray_saved == 1),
|
||||
changed: (($admin_created + $token_updated + $profile_created + $node_created + $node_address_updated + $host_created + $users_changed + $xray_saved) > 0)
|
||||
}'
|
||||
Reference in new issue
Block a user