Import build.sh from cdist manifest

This commit is contained in:
Nico Schottelius 2021-08-08 17:42:37 +02:00
parent 54e3d10b05
commit f652630fb7
2 changed files with 127 additions and 0 deletions

View file

@ -0,0 +1,4 @@
FROM nginx:1.21-alpine
COPY watch-and-run.sh /
ENTRYPOINT /docker-entrypoint.sh /watch-and-run.sh

View file

@ -0,0 +1,123 @@
#!/bin/sh
package=knot
service=knotd
state=$(cat "$__object/parameter/state")
################################################################################
# Basic stuff
#
__package "$package" --state "$state"
require="__package/$package" __start_on_boot "$service"
zonesrc=$__files/dns/zones
zonesextsrc=$__files/dns/zones_extensions
zonedst=/var/lib/knot
confdst=/etc/knot/knot.conf
tmpdir="$__object/files"
confsrc=$tmpdir/knot.conf
mkdir "$tmpdir"
cp $__type/files/knot.conf "$confsrc"
for zone in $(cd "$zonesrc" && ls -1); do
zonefile="$zonedst/${zone}.zone"
zonesrcfile="$zonesrc/$zone"
# Handled synthetic in knot
synth_module=""
case $zone in
# Treat IPv4 all the same
*.155.185.in-addr.arpa|*.203.185.in-addr.arpa|*.78.147.in-addr.arpa)
module="module: mod-synthrecord/ungleich-reverse-v4"
;;
ipv4.at.ungleich.ch)
module="module: mod-synthrecord/ungleich-forward-v4"
;;
1.1.0.0.2.0.0.0.0.c.5.e.a.0.a.2.ip6.arpa)
module="module: mod-synthrecord/k8s-p6-1-reverse"
;;
k8s-1.place6.ungleich.ch)
module="module: mod-synthrecord/nameservice-forward"
;;
d.1.0.0.0.c.5.e.a.0.a.2.ip6.arpa)
module="module: mod-synthrecord/linthfarm-reverse"
;;
linthfarm.place6.ungleich.ch)
module="module: mod-synthrecord/linthfarm-forward"
;;
3.1.0.0.0.c.5.e.a.0.a.2.ip6.arpa)
module="module: mod-synthrecord/place7-reverse"
;;
6.1.0.0.0.c.5.e.a.0.a.2.ip6.arpa)
module="module: mod-synthrecord/room7-reverse"
;;
0.1.0.0.0.c.5.e.a.0.a.2.ip6.arpa)
module="module: mod-synthrecord/ungleich-reverse-diesbach"
;;
1.c.5.e.a.0.a.2.ip6.arpa)
module="module: mod-synthrecord/vpn-reverse"
;;
*[0-7].c.5.e.a.0.a.2.ip6.arpa)
module="module: mod-synthrecord/ungleich-reverse"
;;
*[0-7].4.9.2.9.0.a.2.ip6.arpa)
module="module: mod-synthrecord/ungleich-reverse2"
;;
hacks.in.digitalglarus.ch)
module="module: mod-synthrecord/ungleich-forward-diesbach"
;;
has-a.name|has-aaaa.name)
module="module: mod-synthrecord/nameservice-forward"
;;
ipv6.fun.via.wifi.ungleich.ch)
module="module: mod-synthrecord/place7-forward"
;;
ipv6.magic.ungleich.ch)
module="module: mod-synthrecord/vpn-forward"
;;
loves.ipv6.at.ungleich.ch)
module="module: mod-synthrecord/ungleich-forward"
;;
room7.place10.ungleich.ch|magic.room7.ungleich.ch)
module="module: mod-synthrecord/room7-forward"
;;
uses.ipv6.at.ungleich.ch)
module="module: mod-synthrecord/ungleich-forward2"
;;
*)
module=""
;;
esac
# Add to configuration
cat << eof >> "$confsrc"
- domain: ${zone}.
file: $zonefile
${module}
eof
# Zone
require="__package/$package" __file "$zonefile" \
--state "$state" \
--source "$zonesrcfile" \
--mode 0644 \
--owner knot
done
# Config
require="__package/$package" __file "$confdst" \
--state "$state" \
--mode 0644 \
--source "$confsrc"