Skip to content

Commit

Permalink
ns2.art: updated knot build to test knot w/defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
msimerson committed Sep 22, 2024
1 parent 521719a commit f916136
Showing 1 changed file with 43 additions and 20 deletions.
63 changes: 43 additions & 20 deletions tnpi/ns2.theartfarm.com.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#!/bin/sh

# shellcheck disable=1091
. mail-toaster.sh || exit
set -e

. mail-toaster.sh

export JAIL_START_EXTRA=""
export JAIL_CONF_EXTRA=""
export JAIL_FSTAB=""

mt6-include user

install_knot()
{
tell_status "installing Knot DNS 3"
stage_pkg_install knot3 rsync || exit

if [ ! -d "$STAGE_MNT/data/home" ]; then
mkdir -p "$STAGE_MNT/data/home" || exit
fi
stage_pkg_install knot3 rsync

install_nrpe
}
Expand All @@ -33,41 +33,64 @@ install_nrpe()

configure_knot()
{
for _d in etc home home/knot; do
if [ ! -d "$STAGE_MNT/data/$_d" ]; then
mkdir "$STAGE_MNT/data/$_d"
fi
done

chown -R 553:553 "$STAGE_MNT/data/home/knot"

local _cfg="$STAGE_MNT/usr/local/etc/knot/knot.conf"
if [ ! -f "$_cfg" ] && [ -f "$_cfg.sample" ]; then
tell_status "installing default $_cfg"
cp "$_cfg.sample" "$_cfg"
fi

if grep -qs '^#[[:space:]]*listen' "$_cfg"; then
sed -i '' \
-e '/^#[[:space:]]*listen:/ s/^#//' \
"$_cfg"
fi

stage_sysrc sshd_enable=YES
stage_sysrc knot_enable=YES
stage_sysrc knot_config=/data/etc/knot.conf

for _f in master.password group;
do
if [ -f "$ZFS_JAIL_MNT/ns2.theartfarm.com/etc/$_f" ]; then
cp "$ZFS_JAIL_MNT/ns2.theartfarm.com/etc/$_f" "$STAGE_MNT/etc/"
stage_exec pwd_mkdb -p /etc/master.passwd
fi
done
preserve_passdb knot
stage_exec pw user mod knot -d /data/home/knot -s /bin/sh
}

start_knot()
{
tell_status "starting knot daemon"
stage_exec service knot start || exit
stage_exec service knot start
}

test_knot()
{
tell_status "testing knot"
stage_test_running knot

stage_listening 53
stage_listening 53 4 2
echo "it worked."

tell_status "testing UDP DNS query"
drill ns2.theartfarm.com @"$(get_jail_ip stage)" || exit
drill -Q www.example.com @"$(get_jail_ip stage)"

tell_status "testing TCP DNS query"
drill -t ns2.theartfarm.com @"$(get_jail_ip stage)" || exit
drill -Q -t www.example.com @"$(get_jail_ip stage)"

if [ -f "$STAGE_MNT/data/etc/knot.conf" ]; then
tell_status "switching knot config to /data/etc/knot.conf"
stage_sysrc knot_config=/data/etc/knot.conf

#stage_exec service knot restart
#drill ns2.theartfarm.com @"$(get_jail_ip stage)"
#drill -t ns2.theartfarm.com @"$(get_jail_ip stage)"
fi
}

base_snapshot_exists || exit
base_snapshot_exists
create_staged_fs ns2.theartfarm.com
start_staged_jail ns2.theartfarm.com
install_knot
Expand Down

0 comments on commit f916136

Please sign in to comment.