Verify manager reachability after Headscale enrollment

This commit is contained in:
2026-10-04 11:41:44 +02:00
parent 6f02d7bc49
commit 80a1ac8685
+6 -8
View File
@@ -205,14 +205,6 @@ if [[ $WANT_WZ == 1 && -e /var/ossec/etc/ossec.conf ]]; then
fi
[[ $WANT_TS == 1 || $WANT_WZ == 1 || $SSH_ENABLED == 1 ]] || { echo 'Komponenten inzwischen vorhanden; nichts geaendert.'; exit 0; }
# Check manager reachability before installing a new agent.
if [[ $WANT_WZ == 1 ]]; then
for port in 1514 1515; do
timeout 5 bash -c 'exec 7<>/dev/tcp/$1/$2' -- "$MANAGER" "$port" || {
echo "Wazuh-Manager auf Port $port nicht erreichbar; Installation abgebrochen." >&2; exit 1;
}
done
fi
apt-get -o DPkg::Lock::Timeout=120 update
apt-get -o DPkg::Lock::Timeout=120 install -y --no-install-recommends ca-certificates curl gnupg
install -d -m 755 /usr/share/keyrings /etc/apt/sources.list.d
@@ -238,6 +230,12 @@ if [[ $WANT_TS == 1 ]]; then
fi
if [[ $WANT_WZ == 1 ]]; then
# A Headscale manager IP only becomes reachable after the new client joins.
for port in 1514 1515; do
timeout 5 bash -c 'exec 7<>/dev/tcp/$1/$2' -- "$MANAGER" "$port" || {
echo "Wazuh-Manager auf Port $port nicht erreichbar; Agent-Installation abgebrochen." >&2; exit 1;
}
done
if ! has_repo 'packages.wazuh.com'; then
[[ ! -e /etc/apt/sources.list.d/lxc-enroll-wazuh.list ]] || exit 1
download https://packages.wazuh.com/key/GPG-KEY-WAZUH "$DIR/wazuh.asc"