feat: allow custom builds
This commit is contained in:
parent
5a11c6cad0
commit
24280e3891
1 changed files with 54 additions and 21 deletions
75
main.sh
75
main.sh
|
@ -3,27 +3,55 @@
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
set -eu -o pipefail
|
set -eu -o pipefail
|
||||||
|
|
||||||
|
|
||||||
cleanup () {
|
cleanup () {
|
||||||
echo
|
echo
|
||||||
|
|
||||||
|
# if Unbound is not started, exit from function
|
||||||
|
[ -v unbound_pid ] || return
|
||||||
|
|
||||||
echo '==> Stopping Unbound'
|
echo '==> Stopping Unbound'
|
||||||
[ -v unbound_pid ] && kill -INT "$unbound_pid"
|
kill -INT "$unbound_pid"
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
|
|
||||||
|
built_or_system () {
|
||||||
|
# args: [1]custom/build/path [2]program_name [3]build_script [4]package_name
|
||||||
|
|
||||||
|
if [ -e "$1" ]; then
|
||||||
|
echo "$2: using custom build at $1" >&2 # stderr; just a message to user
|
||||||
|
echo "$1" # stdout; captured into a variable with $(), see below
|
||||||
|
|
||||||
|
elif exe=$(which "$2"); then
|
||||||
|
echo "$exe" # stdout
|
||||||
|
|
||||||
|
else
|
||||||
|
echo " ** $2: not found neither built nor in-system" >&2 # stderr
|
||||||
|
echo " use script './$3' to automatically build it at the correct path" >&2
|
||||||
|
|
||||||
|
# if $4 is set, say about possible pkg name
|
||||||
|
[ -v 4 ] && \
|
||||||
|
echo " or install it from your package manager, usually pkg is named '$4'" >&2
|
||||||
|
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
exe_dig="bind9/bin/dig/dig"
|
||||||
|
exe_drill="ldns/drill/drill"
|
||||||
|
exe_hr="hickory-dns/target/release/resolve"
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo '==> Checking deps'
|
echo '==> Checking deps'
|
||||||
echo 'Note: dig is installed from package usually named "bind-utils"'
|
|
||||||
echo ' drill -- package "ldns"'
|
|
||||||
echo " and hickory's resolve can be built with ./build_hr.sh"
|
|
||||||
echo ' (this script will find it in subdir, no need to install)'
|
|
||||||
which unbound
|
which unbound
|
||||||
which hyperfine
|
which hyperfine
|
||||||
which dig
|
exe_dig=$(built_or_system "$exe_dig" dig "build_dig.sh" bind-utils)
|
||||||
which drill
|
exe_drill=$(built_or_system "$exe_drill" drill "build_drill.sh" ldns)
|
||||||
hr="hickory-dns/target/release/resolve"
|
exe_hr=$(built_or_system "$exe_hr" resolve "build_hr.sh")
|
||||||
[ -e "$hr" ] || hr=$(which resolve)
|
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo '==> Starting Unbound'
|
echo '==> Starting Unbound'
|
||||||
|
@ -31,30 +59,35 @@ unbound -c ./unbound.conf -dp 2>unbound.log &
|
||||||
unbound_pid=$!
|
unbound_pid=$!
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo '==> Benchmarks for A domain.tld.'
|
echo '==> Benchmarks for A domain.tld.'
|
||||||
hyperfine -N \
|
hyperfine -N \
|
||||||
"dig -p 2253 domain.tld @127.0.0.1" \
|
"$exe_dig -p 2253 domain.tld @127.0.0.1" \
|
||||||
"drill -p 2253 domain.tld @127.0.0.1" \
|
"$exe_drill -p 2253 domain.tld @127.0.0.1" \
|
||||||
"$hr -n 127.0.0.1:2253 domain.tld"
|
"$exe_hr -n 127.0.0.1:2253 domain.tld"
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo '==> Benchmarks for AAAA domain.tld.'
|
echo '==> Benchmarks for AAAA domain.tld.'
|
||||||
hyperfine -N \
|
hyperfine -N \
|
||||||
"dig -p 2253 aaaa domain.tld @127.0.0.1" \
|
"$exe_dig -p 2253 aaaa domain.tld @127.0.0.1" \
|
||||||
"drill -p 2253 aaaa domain.tld @127.0.0.1" \
|
"$exe_drill -p 2253 aaaa domain.tld @127.0.0.1" \
|
||||||
"$hr -n 127.0.0.1:2253 -t AAAA domain.tld"
|
"$exe_hr -n 127.0.0.1:2253 -t AAAA domain.tld"
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo '==> Benchmarks for MX domain.tld.'
|
echo '==> Benchmarks for MX domain.tld.'
|
||||||
hyperfine -N \
|
hyperfine -N \
|
||||||
"dig -p 2253 mx domain.tld @127.0.0.1" \
|
"$exe_dig -p 2253 mx domain.tld @127.0.0.1" \
|
||||||
"drill -p 2253 mx domain.tld @127.0.0.1" \
|
"$exe_drill -p 2253 mx domain.tld @127.0.0.1" \
|
||||||
"$hr -n 127.0.0.1:2253 -t MX domain.tld"
|
"$exe_hr -n 127.0.0.1:2253 -t MX domain.tld"
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo '==> Benchmarks for CNAME mail.domain.tld.'
|
echo '==> Benchmarks for CNAME mail.domain.tld.'
|
||||||
hyperfine -N \
|
hyperfine -N \
|
||||||
"dig -p 2253 mail.domain.tld @127.0.0.1" \
|
"$exe_dig -p 2253 mail.domain.tld @127.0.0.1" \
|
||||||
"drill -p 2253 mail.domain.tld @127.0.0.1" \
|
"$exe_drill -p 2253 mail.domain.tld @127.0.0.1" \
|
||||||
"$hr -n 127.0.0.1:2253 mail.domain.tld"
|
"$exe_hr -n 127.0.0.1:2253 mail.domain.tld"
|
||||||
|
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo '==> All done'
|
||||||
|
|
Loading…
Add table
Reference in a new issue