Name: dae Version: 0.7.0rc1 Release: 1%{?dist} Summary: dae transparrent proxy License: MIT URL: https://github.com/daeuniverse/dae BuildArch: %{_arch} %global debug_package ${nil} %define builddate %(date +%Y%m%d) # Determine the correct architecture based on the build architecture %ifarch aarch64 %global architecture arm64 %else %ifarch x86_64 %global architecture x86_64 %endif %endif %description eBPF-based Linux high-performance transparent proxy solution. %prep curl -o %{_sourcedir}/dae-linux-%{architecture}.zip -L https://github.com/daeuniverse/dae/releases/download/v%{version}/dae-linux-%{architecture}.zip %setup -q -c -T unzip -q %{_sourcedir}/dae-linux-%{architecture}.zip -d %{_builddir} mv %{_builddir}/dae-linux-%{architecture} %{_builddir}/dae %build echo 'Build not required' %install mkdir -p %{buildroot}/usr/local/bin mkdir -p %{buildroot}/usr/local/etc/dae mkdir -p %{buildroot}/etc/systemd/system # Install binaries install -m 0755 %{_builddir}/dae %{buildroot}/usr/local/bin/dae # Install config and data files install -m 0644 %{_builddir}/geoip.dat %{buildroot}/usr/local/etc/dae/geoip.dat install -m 0644 %{_builddir}/geosite.dat %{buildroot}/usr/local/etc/dae/geosite.dat install -m 0600 %{_builddir}/example.dae %{buildroot}/usr/local/etc/dae/example.dae # Install systemd service file cat < %{buildroot}/etc/systemd/system/dae.service [Unit] Description=dae Service Documentation=https://github.com/daeuniverse/dae After=network-online.target docker.service systemd-sysctl.service Wants=network-online.target [Service] Type=notify User=root LimitNPROC=512 LimitNOFILE=1048576 ExecStartPre=/usr/local/bin/dae validate -c /usr/local/etc/dae/config.dae ExecStart=/usr/local/bin/dae run --disable-timestamp -c /usr/local/etc/dae/config.dae ExecReload=/usr/local/bin/dae reload $MAINPID Restart=on-abnormal TimeoutStartSec=120 [Install] WantedBy=multi-user.target EOF %post systemctl daemon-reload if [ $1 -ge 2 ]; then # Hot reload config systemctl restart dae # Check DNS resolution, TLS and connectivity with curl # List of endpoints to curl endpoints=( "https://domains.google.com/checkip" "https://checkip.amazonaws.com" "https://whatismyip.akamai.com" "https://www.cloudflare.com/cdn-cgi/trace" "https://api.fastly.com/public-ip-list" ) # Array to store results results=() # Function to check if a curl command succeeds checkip() { local url="$1" local result curl -s "$url" > /dev/null if [ $? -eq 0 ]; then result="success: $url" else result="failed: $url" fi echo "$result" } # Execute curl commands in parallel and collect results readarray -t results < <( for url in "${endpoints[@]}"; do checkip "$url" & done ) # Wait for all background processes to finish wait connection='false' # Check results array for success for result in "${results[@]}"; do if [[ "$result" == success* ]]; then echo "$result" connection='true' fi done if [[ $connection == 'false' ]]; then echo "A successful connection was not made to any URLs" exit 1 else echo "A successful connection was made to at least one URL" fi fi %pre %posttrans %preun if [ $1 -eq 0 ]; then systemctl stop dae.service systemctl disable dae.service fi %postun if [ $1 -eq 0 ]; then systemctl daemon-reload fi %clean rm -rf $RPM_BUILD_ROOT %files /usr/local/bin/dae /usr/local/etc/dae/geoip.dat /usr/local/etc/dae/geosite.dat /usr/local/etc/dae/example.dae /etc/systemd/system/dae.service %changelog * Date: %{builddate} - %{version}