V8.00.000.2025.06.17
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 1m54s
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 1m54s
Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
@@ -17,13 +17,11 @@ guard_sourcing
|
||||
# Globals:
|
||||
# ARY_IPV4_NS
|
||||
# ARY_IPV6_NS
|
||||
# DIR_BAK
|
||||
# RECOVERY
|
||||
# TARGET
|
||||
# VAR_ARCHITECTURE
|
||||
# VAR_CODENAME
|
||||
# VAR_FINAL_IPV6
|
||||
# VAR_LINK_IPV6
|
||||
# VAR_VERSION
|
||||
# VAR_RUN_RECOVERY
|
||||
# Arguments:
|
||||
# None
|
||||
# Returns:
|
||||
@@ -32,59 +30,66 @@ guard_sourcing
|
||||
setup_resolv() {
|
||||
### Declare Arrays, HashMaps, and Variables.
|
||||
declare ns=""
|
||||
declare var_target="${TARGET}"
|
||||
|
||||
if [[ -f "${TARGET}/etc/resolv.conf" ]]; then
|
||||
### Check for TARGET / RECOVERY.
|
||||
[[ "${VAR_RUN_RECOVERY}" == "true" ]] && var_target="${RECOVERY}"
|
||||
|
||||
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."
|
||||
if [[ -f "${var_target}/etc/resolv.conf" ]]; then
|
||||
|
||||
mkdir -p "${var_target}/root/.ciss/cdi/backup/etc"
|
||||
mv "${var_target}/etc/resolv.conf" "${var_target}/root/.ciss/cdi/backup/etc/resolv.conf.bak"
|
||||
do_log "info" "file_only" "4035() Existing '${var_target}/etc/resolv.conf' moved."
|
||||
|
||||
fi
|
||||
|
||||
touch "${TARGET}/etc/resolv.conf"
|
||||
chmod 0644 "${TARGET}/etc/resolv.conf"
|
||||
touch "${var_target}/etc/resolv.conf"
|
||||
chmod 0644 "${var_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"
|
||||
insert_header "${var_target}/etc/resolv.conf"
|
||||
insert_comments "${var_target}/etc/resolv.conf"
|
||||
cat << EOF >> "${var_target}/etc/resolv.conf"
|
||||
### Custom DNS IPv4 configuration
|
||||
EOF
|
||||
|
||||
for ns in "${ARY_IPV4_NS[@]}"; do
|
||||
|
||||
echo "nameserver ${ns}" >> "${TARGET}/etc/resolv.conf"
|
||||
echo "nameserver ${ns}" >> "${var_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."
|
||||
echo "" >> "${var_target}/etc/resolv.conf"
|
||||
do_log "info" "file_only" "4035() IPv4 nameserver at: '${var_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"
|
||||
cat << EOF >> "${var_target}/etc/resolv.conf"
|
||||
### Custom DNS IPv6 configuration
|
||||
EOF
|
||||
|
||||
for ns in "${ARY_IPV6_NS[@]}"; do
|
||||
|
||||
echo "nameserver ${ns}" >> "${TARGET}/etc/resolv.conf"
|
||||
echo "nameserver ${ns}" >> "${var_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."
|
||||
echo "" >> "${var_target}/etc/resolv.conf"
|
||||
do_log "info" "file_only" "4035() IPv6 nameserver at: '${var_target}/etc/resolv.conf' configured."
|
||||
|
||||
fi
|
||||
|
||||
cat << EOF >> "${TARGET}/etc/resolv.conf"
|
||||
cat << EOF >> "${var_target}/etc/resolv.conf"
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||
EOF
|
||||
|
||||
guard_dir && return 0
|
||||
}
|
||||
### Prevents accidental 'unset -f'.
|
||||
# shellcheck disable=SC2034
|
||||
readonly -f setup_resolv
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||
|
||||
Reference in New Issue
Block a user