forked from msimerson/Mail-Toaster-6
-
Notifications
You must be signed in to change notification settings - Fork 0
/
provision-nsd.sh
executable file
·64 lines (51 loc) · 1.21 KB
/
provision-nsd.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/sh
# shellcheck disable=1091
. mail-toaster.sh || exit
export JAIL_START_EXTRA=""
export JAIL_CONF_EXTRA=""
install_nsd()
{
tell_status "installing NSD"
stage_pkg_install nsd rsync dialog4ports || exit
if [ ! -d "$STAGE_MNT/data/home/nsd" ]; then
mkdir -p "$STAGE_MNT/data/home/nsd" || exit
chown 216:216 "$STAGE_MNT/data/home/nsd"
fi
stage_exec pw user mod nsd -u 216 -g 216 -s /bin/sh -d /data/home/nsd
}
configure_nsd()
{
stage_sysrc nsd_enable=YES
stage_sysrc nsd_config=/data/etc/nsd.conf
for _f in master.password group;
do
if [ -f "$ZFS_JAIL_MNT/nsd/etc/$_f" ]; then
cp "$ZFS_JAIL_MNT/nsd/etc/$_f" "$STAGE_MNT/etc/"
stage_exec pwd_mkdb -p /etc/master.passwd
fi
done
}
start_nsd()
{
tell_status "starting nsd daemon"
stage_exec service nsd start || exit
}
test_nsd()
{
tell_status "testing nsd"
stage_test_running nsd
stage_listening 53
echo "it worked."
tell_status "testing UDP DNS query"
drill www.example.com @"$(get_jail_ip stage)" || exit
tell_status "testing TCP DNS query"
drill -t www.example.com @"$(get_jail_ip stage)" || exit
}
base_snapshot_exists || exit
create_staged_fs nsd
start_staged_jail nsd
install_nsd
configure_nsd
start_nsd
test_nsd
promote_staged_jail nsd