added dns config + refactoring...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2024-01-31 17:26:58 +03:00
parent b079498481
commit 306f0ddc4c
4 changed files with 65 additions and 11 deletions

View File

@ -286,6 +286,41 @@ xreadpass(){
}
# Review changes in PATH.new, then edit/apply changes to PATH
#
# reviewApplyChanges PATH
#
# NOTE: if changes are not applied this will return non-zero making this
# usable in conditionals...
reviewApplyChanges(){
local file=$1
echo "# Review updated: ${file}.new:"
@ cat ${file}.new
echo
# XXX add option to edit...
local res
while true ; do
read -ep "# [a]pply, [e]dit, [s]kip? " res
case "${res,,}" in
a|apply)
break
;;
e|edit)
${EDITOR} "${file}"
;;
s|skip)
echo "# file saved as: ${file}.new"
return 1
;;
*)
echo "ERROR: unknown command: \"$res\"" >&2
continue
;;
esac
done
@ mv -b "${file}"{.new,}
}
#----------------------------------------------------------------------

View File

@ -52,7 +52,7 @@ if xreadYes "# Install additional apps?" APPS ; then
@ apt install ${SOFTWARE[@]}
fi
# Networking
# Bridges...
# XXX need to:
# - bootstrap this
# - setup the gate, ssh, and wireguard
@ -88,25 +88,40 @@ if xreadYes "# Create bridges?" BRIDGES ; then
cat bridges.tpl \
| expandPCTTemplate WAN_PORT ADMIN_PORT)"
if [ -z "$DRY_RUN" ] ; then
# XXX add $BRIDGES to /etc/network/interfaces either before the
# source command or at the end...
# XXX
# review/apply setup...
echo "# Review updated: /etc/network/interfaces.new:"
@ cat /etc/network/interfaces.new
echo
if xreadYes "# Apply changes?" ; then
@ mv -b /etc/network/interfaces{.new,}
fi
if reviewApplyChanges /etc/network/interfaces ; then
@ ifreload -a
fi
fi
echo "# Building config..."
# XXX do we need any extra vars here???
buildAssets
# DNS
if xreadYes "# Update DNS?" DNS ; then
file=/etc/resolv.conf
@ cp "staging/${file}" "${file}".new
reviewApplyChanges "${file}"
fi
# Firewall
if xreadYes "# Update firewall rules?" FIREWALL ; then
@ cp --backup -i templates/etc/pve/firewall/cluster.fw /etc/pve/firewall/
file=/etc/pve/firewall/cluster.fw
@ cp "staging/${file}" "${file}".new
reviewApplyChanges "${file}"
fi
showNotes
echo "# Done."

View File

@ -0,0 +1,4 @@
search srv
nameserver 127.0.0.1
nameserver ${NS_ADMIN_IPn}
nameserver 8.8.8.8