Files
CISS.debian.installer/func/cdi_4000_debootstrap/4035_setup_resolv.sh
Marc S. Weidner d316c1d2b5
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 1m36s
V8.00.000.2025.06.17
Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
2025-08-27 19:38:29 +02:00

91 lines
2.6 KiB
Bash

#!/bin/bash
# SPDX-Version: 3.0
# SPDX-CreationInfo: 2025-06-17; WEIDNER, Marc S.; <msw@coresecret.dev>
# SPDX-ExternalRef: GIT https://git.coresecret.dev/msw/CISS.debian.installer.git
# SPDX-FileContributor: WEIDNER, Marc S.; Centurion Intelligence Consulting Agency
# SPDX-FileCopyrightText: 2024-2025; WEIDNER, Marc S.; <msw@coresecret.dev>
# SPDX-FileType: SOURCE
# SPDX-License-Identifier: EUPL-1.2 OR LicenseRef-CCLA-1.0
# SPDX-LicenseComment: This file is part of the CISS.debian.installer.secure framework.
# SPDX-PackageName: CISS.debian.installer
# SPDX-Security-Contact: security@coresecret.eu
guard_sourcing
#######################################
# Configure the '/etc/resolv.conf' file.
# Globals:
# ARY_IPV4_NS
# ARY_IPV6_NS
# DIR_BAK
# TARGET
# VAR_ARCHITECTURE
# VAR_CODENAME
# VAR_FINAL_IPV6
# VAR_LINK_IPV6
# VAR_VERSION
# Arguments:
# None
# Returns:
# 0: on success
#######################################
setup_resolv() {
### Declare Arrays, HashMaps, and Variables.
declare ns=""
if [[ -f "${TARGET}/etc/resolv.conf" ]]; then
mkdir -p "${TARGET}/root/.ciss/cdi/backup/etc"
mv "${TARGET}/etc/resolv.conf" "${TARGET}/root/.ciss/cdi/backup/etc/resolv.conf.bak"
do_log "info" "file_only" "4035() Existing '${TARGET}/etc/resolv.conf' moved."
fi
touch "${TARGET}/etc/resolv.conf"
chmod 0644 "${TARGET}/etc/resolv.conf"
### Create '/etc/resolv.conf' IPv4 entries for static configuration.
insert_header "${TARGET}/etc/resolv.conf"
insert_comments "${TARGET}/etc/resolv.conf"
cat << EOF >> "${TARGET}/etc/resolv.conf"
### Custom DNS IPv4 configuration
EOF
for ns in "${ARY_IPV4_NS[@]}"; do
echo "nameserver ${ns}" >> "${TARGET}/etc/resolv.conf"
do_log "info" "file_only" "4035() IPv4 nameserver added: [${ns}]."
done
echo "" >> "${TARGET}/etc/resolv.conf"
do_log "info" "file_only" "4035() IPv4 nameserver at: '${TARGET}/etc/resolv.conf' configured."
### Create '/etc/resolv.conf' IPv6 entries for static configuration.
if [[ "${VAR_LINK_IPV6,,}" == "true" || -n "${VAR_FINAL_IPV6}" ]]; then
cat << EOF >> "${TARGET}/etc/resolv.conf"
### Custom DNS IPv6 configuration
EOF
for ns in "${ARY_IPV6_NS[@]}"; do
echo "nameserver ${ns}" >> "${TARGET}/etc/resolv.conf"
do_log "info" "file_only" "4035() IPv6 nameserver added: [${ns}]."
done
echo "" >> "${TARGET}/etc/resolv.conf"
do_log "info" "file_only" "4035() IPv6 nameserver at: '${TARGET}/etc/resolv.conf' configured."
fi
cat << EOF >> "${TARGET}/etc/resolv.conf"
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
EOF
guard_dir && return 0
}
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh