Files
EvoBGP/deploy/docker/bird/bird-from-source.sh
T
Denozordec 1c7152a285
CI / changes (push) Successful in 11s
CI / commitlint (push) Has been skipped
CI / openapi (push) Has been skipped
CI / web (push) Has been skipped
CI / go (push) Successful in 1m8s
CI / bird2 (push) Successful in 17s
CI / release (push) Successful in 5m10s
feat(docker): update BIRD build process and documentation
Refined the BIRD build process in the Docker setup by consolidating the source download and extraction steps. Enhanced the `bird-from-source.sh` script to include a fallback mechanism for downloading the BIRD tarball from GitHub if the primary source fails. Updated the README documentation to clarify the build process and provide links to the BIRD source. This improves reliability and user understanding of the setup.
2026-07-01 00:11:16 +07:00

74 lines
2.6 KiB
Bash

#!/bin/sh
# Сборка BIRD из официального tarball (BIRD_VERSION, по умолчанию 2.14).
# Источники: https://bird.nic.cz/get-bird/ (актуальные), https://bird.nic.cz/old-releases/ (архив).
# Tarball: https://bird.nic.cz/download/bird-<version>.tar.gz
# Запуск от root (Docker) или через sudo на хосте. Префикс: /usr/local.
# birdc: ncurses + readline; runtime gobinary — libreadline8 + libncurses6.
set -eu
BIRD_VERSION="${BIRD_VERSION:-2.14}"
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
curl \
flex \
bison \
libncurses-dev \
libreadline-dev
cd /tmp
rm -rf "bird-${BIRD_VERSION}"
BIRD_TARBALL="bird-${BIRD_VERSION}.tar.gz"
BIRD_SRC_DIR="bird-${BIRD_VERSION}"
BIRD_NIC_URL="https://bird.nic.cz/download/${BIRD_TARBALL}"
# Старые релизы (2.14 и др.) — только на old-releases; get-bird — для актуальных.
BIRD_REFERER="https://bird.nic.cz/old-releases/"
case "${BIRD_VERSION}" in
2.19.*|2.18.*|2.17.*|3.*) BIRD_REFERER="https://bird.nic.cz/get-bird/" ;;
esac
GITHUB_TAG_URL="https://github.com/CZ-NIC/bird/archive/refs/tags/v${BIRD_VERSION}.tar.gz"
download_bird_tarball() {
if curl -fsSL --retry 3 --retry-delay 2 \
-H "Referer: ${BIRD_REFERER}" \
-H "User-Agent: EvoBGP-docker-build/1.0 (+https://bird.nic.cz/get-bird/)" \
"${BIRD_NIC_URL}" -o "${BIRD_TARBALL}"; then
return 0
fi
echo "bird.nic.cz download failed, trying GitHub mirror (CZ-NIC/bird)..." >&2
curl -fsSL --retry 3 --retry-delay 2 \
-H "User-Agent: EvoBGP-docker-build/1.0" \
"${GITHUB_TAG_URL}" -o "${BIRD_TARBALL}"
}
download_bird_tarball
tar xzf "${BIRD_TARBALL}"
rm -f "${BIRD_TARBALL}"
if [ ! -d "${BIRD_SRC_DIR}" ]; then
# GitHub archive: bird-2.14 → иногда bird-bird-2.14; ищем единственный каталог bird-*.
BIRD_SRC_DIR="$(find /tmp -maxdepth 1 -type d -name 'bird-*' | head -n 1)"
if [ -z "${BIRD_SRC_DIR}" ] || [ ! -d "${BIRD_SRC_DIR}" ]; then
echo "BIRD source directory not found after extract" >&2
exit 1
fi
fi
cd "${BIRD_SRC_DIR}"
if [ ! -f ./configure ]; then
apt-get install -y --no-install-recommends autoconf automake libtool
autoreconf -fi
fi
./configure --prefix=/usr/local --enable-client
make -j"$(nproc)"
make install
cd /
rm -rf "${BIRD_SRC_DIR}"
apt-get purge -y build-essential flex bison libncurses-dev libreadline-dev autoconf automake libtool 2>/dev/null || \
apt-get purge -y build-essential flex bison libncurses-dev libreadline-dev
apt-get autoremove -y
rm -rf /var/lib/apt/lists/*