2023-02-26 00:35:27 +00:00
|
|
|
#! /bin/bash
|
|
|
|
|
2024-09-18 02:22:27 +00:00
|
|
|
set -e
|
|
|
|
|
|
|
|
# NOTE: groupadd and useradd require root.
|
|
|
|
[ "$EUID" -ne 0 ] && echo "Must be run by root" && exit 1
|
|
|
|
|
|
|
|
IMAGE="docker.io/internetsystemsconsortium/bind9:9.18"
|
|
|
|
|
|
|
|
# determine current uid and gid
|
|
|
|
uidgid=$(podman run --rm --entrypoint=/bin/sh "$IMAGE" -c "/usr/bin/id -u bind; /usr/bin/id -g bind")
|
|
|
|
read -d '' -r uid gid <<< "$uidgid" || :
|
|
|
|
|
|
|
|
# create the group and user
|
|
|
|
id -g bind >/dev/null 2>&1 || groupadd -f -g "$gid" bind
|
|
|
|
id -u bind >/dev/null 2>&1 || useradd -u "$uid" -g "$gid" -M --no-log-init bind
|
|
|
|
|
|
|
|
# create our main directory setup
|
|
|
|
install -d -o bind -g bind -m 0755 /etc/bind/cfg /etc/bind/cache /etc/bind/zones /etc/bind/log/named
|
|
|
|
# copy over our config and data without overwriting anything, hopefully.
|
|
|
|
for d in cfg cache zones; do
|
|
|
|
rsync -av --chown bind:bind --ignore-existing ./$d/ /etc/bind/$d/
|
|
|
|
done
|
|
|
|
|
|
|
|
# install our podman config
|
|
|
|
if [ -d /etc/containers/systemd ]; then
|
|
|
|
install -o root -g root -m 0644 named.container /etc/containers/systemd/
|
|
|
|
systemctl daemon-reload
|
|
|
|
systemctl start named
|
|
|
|
else
|
|
|
|
echo "containers-common not installed?"
|
2023-02-26 00:35:27 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-09-18 02:22:27 +00:00
|
|
|
exit 0
|