V8.00.000.2025.06.17

Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
2025-07-15 10:59:22 +02:00
parent b459ed8a90
commit e38e676717
7 changed files with 436 additions and 422 deletions

View File

@@ -0,0 +1,24 @@
#!/bin/bash
do_log "info" "false" "Live environment DHCP information collection: timeout='${network_timeout_dhcp}' seconds. Please wait."
dhclient -v -1 "${var_auto_nic}" 2>&1 | timeout "${network_timeout_dhcp}" dhcpdump -i "${var_auto_nic}" >> "${LOG_NIC}" || true
awk 'BEGIN {RS="---------------------------------------------------------------------------"; \
ORS="---------------------------------------------------------------------------"} \
NF {last=$0} END {print last}' "${LOG_NIC}" > "${LOG_NIC}".tmp && mv "${LOG_NIC}".tmp "${LOG_NIC}"
do_log "info" "false" "Live environment DHCP information collection: collection completed."
### Extract 'FQDN' from '${LOG_NIC}'
var_auto_fqdn=$(awk -F 'Host name' '/Host name/ {print $2}' "${LOG_NIC}" | xargs)
### Extract 'YIADDR' (Your IP Address) from '${LOG_NIC}'
var_dhcp_yiaddr=$(awk -F 'YIADDR:' '/YIADDR/ {print $2}' "${LOG_NIC}" | awk '{print $1}' | xargs)
### Extract 'SIADDR' (Server IP Address) from '${LOG_NIC}'
var_dhcp_siaddr=$(awk -F 'SIADDR:' '/SIADDR/ {print $2}' "${LOG_NIC}" | awk '{print $1}' | xargs)
### Extract 'Server Identifier' from '${LOG_NIC}'
var_dhcp_srv=$(awk -F 'Server identifier' '/Server identifier/ {print $2}' "${LOG_NIC}" | xargs)
### Extract 'GIADDR' (Gateway IP Address) from '${LOG_NIC}'
var_dhcp_giaddr=$(awk -F 'GIADDR:' '/GIADDR/ {print $2}' "${LOG_NIC}" | awk '{print $1}' | xargs)

View File

@@ -149,7 +149,7 @@ locale:
################################################################################################################################
network:
autoconfig:
enable: true # Automatic network configuration is the default. If you prefer to configure the network
enable: true # Automatic network configuration 'dhcp' is the default. If you prefer to configure the network
# manually, change 'network.autoconfig.enable' from "true" to "false" and configure
# - 'network.choose_interface.static'
# - 'network.hostname'
@@ -157,9 +157,10 @@ network:
# - 'network.static' section
choose_interface:
auto: true # Choose an interface that has a link if possible. Or manually configure the static NIC below.
static: "eth1" # If auto-detect fails or for manual configuration, specify a particular interface.
static: "eth1" # For manual configuration, specify a particular interface.
hostname: "nsa.usic.gov" # Specify the FQDN of the server.
ipv6: true # Specify if you want to use IPv6:
# If not specified and autoconfig is enabled, the given dhcp value is chosen.
ipv6: true # Specify if you want to use IPv6.
timeout:
dhcp: 60 # If the dhcp server is slow, and the installer times out waiting for it, this might be useful.
linkwait: 60 # To set a different link detection timeout (default is 3 seconds).
@@ -173,6 +174,7 @@ network:
ipv4nameserver:
- "135.181.207.105" # dns01.eddns.eu
- "89.58.62.53" # dns02.eddns.de
- "138.199.237.109" # dns03.eddns.eu
ipv4nameserver_fallback:
- "176.9.93.198" # dnsforge.de
- "176.9.1.117" # dnsforge.de
@@ -182,6 +184,7 @@ network:
ipv6nameserver:
- "2a01:4f9:c012:a813:135:181:207:105"
- "2a0a:4cc0:1:e6:89:58:62:53"
- "2a01:4f8:c013:8011:138:199:237:109"
ipv6nameserver_fallback:
- "2a01:4f8:151:34aa::198"
- "2a01:4f8:141:316d::117"

View File

@@ -31,31 +31,22 @@ setup_locales() {
### Give priority to '${locale_locale}' over separately configured variables '{$locale_country}' and '{$locale_language}'.
### If 'locale_locale' is not set, build it from 'locale_language' and 'locale_country'.
if [[ -n "${locale_language:-}" && -n "${locale_country:-}" && -z "${locale_locale}" ]]; then
locale_locale="${locale_language}_${locale_country}.UTF-8"
if [[ -n "${locale_language:-}" && -n "${locale_country:-}" && -z "${locale_locale:-}" ]]; then
declare locale_locale="${locale_language}_${locale_country}.UTF-8"
fi
if [[ -n "${locale_locale}" ]]; then
### Generate the specified locale
do_in_target "${TARGET}" locale-gen "${locale_locale}"
do_log "info" "true" "Command: 'locale-gen ${locale_locale}' executed in: '${TARGET}'."
### Set the standard locale
do_in_target "${TARGET}" update-locale LANG="${locale_locale}" LC_ALL="${locale_locale}"
do_log "info" "true" "Command: 'update-locale LANG=${locale_locale} LC_ALL=${locale_locale}' executed in: '${TARGET}'."
### Set the keyboard layout for the system (for consoles)
# shellcheck disable=SC2154 # "${locale_keyboard_layout}"
sed -i "s/^KEYMAP=.*/KEYMAP=${locale_keyboard_layout}/" "${TARGET}"/etc/default/keyboard
sed -i "s/^KEYMAP=.*/KEYMAP=${locale_keyboard_layout}/" "${TARGET}/etc/default/keyboard"
do_log "info" "false" "Keyboard layout updated: 'KEYMAP=${locale_keyboard_layout}' -> '${TARGET}/etc/default/keyboard'."
### Set the X11 keyboard layout (for graphical environments)
# shellcheck disable=SC2154 # "${locale_keyboard_xkb_keymap}"
do_in_target "${TARGET}" localectl set-x11-keymap "${locale_keyboard_xkb_keymap}"
do_log "info" "true" "Command: 'localectl set-x11-keymap ${locale_keyboard_xkb_keymap}' executed in: '${TARGET}'."
fi
return 0
}

View File

@@ -0,0 +1,31 @@
#!/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
#######################################
# Installation of the specified kernel.
# Globals:
# TARGET
# image
# Arguments:
# None
# Returns:
# 0: Successfully executed commands.
#######################################
installation_kernel() {
# Installing the chosen Kernel Image according to preseed.yaml
# shellcheck disable=SC2154 # "${image}"
do_in_target "${TARGET}" apt-get install -y "${image}"
return 0
}
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh

364
func/4130_setup_network.sh Normal file
View File

@@ -0,0 +1,364 @@
#!/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
# Setup network
setup_network() {
do_in_target "${TARGET}" apt-get install -y isc-dhcp-client ifupdown
mkdir -p "${TARGET}/etc/network/interfaces/interfaces.d"
declare var_auto_nic="" var_auto_ipv4_ccidr="" var_auto_ipv4_subnet="" var_auto_ipv4="" var_auto_ipv4_gw="" \
var_auto_ipv6_ccidr="" var_auto_ipv6="" var_auto_ipv6_gw="" var_link_ipv4="" var_link_ipv6="" var_auto_fqdn=""
declare -a ary_ipv4_ns ary_ipv6_ns
ary_ipv4_ns+=("${network_static_ipv4nameserver_0}")
[[ -n "${network_static_ipv4nameserver_1}" ]] && ary_ipv4_ns+=("${network_static_ipv4nameserver_1}")
[[ -n "${network_static_ipv4nameserver_2}" ]] && ary_ipv4_ns+=("${network_static_ipv4nameserver_2}")
[[ -n "${network_static_ipv4nameserver_fallback_0}" ]] && ary_ipv4_ns+=("${network_static_ipv4nameserver_fallback_0}")
[[ -n "${network_static_ipv4nameserver_fallback_1}" ]] && ary_ipv4_ns+=("${network_static_ipv4nameserver_fallback_1}")
ary_ipv6_ns+=("${network_static_ipv6nameserver_0}")
[[ -n "${network_static_ipv6nameserver_1}" ]] && ary_ipv6_ns+=("${network_static_ipv6nameserver_1}")
[[ -n "${network_static_ipv6nameserver_2}" ]] && ary_ipv6_ns+=("${network_static_ipv6nameserver_2}")
[[ -n "${network_static_ipv6nameserver_fallback_0}" ]] && ary_ipv6_ns+=("${network_static_ipv6nameserver_fallback_0}")
[[ -n "${network_static_ipv6nameserver_fallback_1}" ]] && ary_ipv6_ns+=("${network_static_ipv6nameserver_fallback_1}")
### Check current network connection and configure variables
var_auto_nic=$(ip -o link show | awk -F': ' '/state UP/ && $2!="lo" {print $2; exit}')
var_auto_ipv4_ccidr=$(ip -4 -o addr show "${var_auto_nic}" | awk '{print $4; exit}')
var_auto_ipv4_subnet=$(generate_subnetmask "${var_auto_ipv4_ccidr}")
var_auto_ipv4=$(echo "${var_auto_ipv4_ccidr}" | awk -F'/' '{print $1}')
var_auto_ipv4_gw=$(ip route show default dev "${var_auto_nic}" | awk '/^default/ {print $3; exit}')
var_auto_ipv6_ccidr=$(ip -6 -o addr show "${var_auto_nic}" | awk '/scope global/ {print $4; exit}')
if [[ -n "${var_auto_ipv6_ccidr}" ]]; then
var_auto_ipv6=$(echo "${var_auto_ipv6_ccidr}" | awk -F'/' '{print $1}')
var_auto_ipv6_gw=$(ip -6 route show default dev "${var_auto_nic}" | awk '/^default/ {print $3; exit}')
fi
var_link_ipv4=$(ping -q -c 1 -W 1 -4 debian.org > /dev/null 2>&1 && echo "true" || echo "false")
var_link_ipv6=$(ping -q -c 1 -W 1 -6 debian.org > /dev/null 2>&1 && echo "true" || echo "false")
if [[ -f "/var/lib/dhcp/dhclient.${var_auto_nic}.leases" ]]; then
var_auto_fqdn=$(grep -m1 'option host-name' "/var/lib/dhcp/dhclient.${var_auto_nic}.leases" | sed -E 's/.*"([^"]+)".*/\1/')
else
var_auto_fqdn=""
fi
do_log "info" "false" "Live environment network check: Auto NIC ='${var_auto_nic}'."
do_log "info" "false" "Live environment network check: Auto IPv4 ='${var_auto_ipv4}'."
do_log "info" "false" "Live environment network check: Auto IPv4 CCIDR ='${var_auto_ipv4_ccidr}'."
do_log "info" "false" "Live environment network check: Auto IPv4 Subnet ='${var_auto_ipv4_subnet}'."
do_log "info" "false" "Live environment network check: Auto IPv4 Gateway ='${var_auto_ipv4_gw}'."
do_log "info" "false" "Live environment network check: Auto IPv6 ='${var_auto_ipv6}'."
do_log "info" "false" "Live environment network check: Auto IPv6 CCIDR ='${var_auto_ipv6_ccidr}'."
do_log "info" "false" "Live environment network check: Auto IPv6 Gateway ='${var_auto_ipv6_gw}'."
do_log "info" "false" "Live environment network check: Auto IPv4 Link ='${var_link_ipv4}'."
do_log "info" "false" "Live environment network check: Auto IPv6 Link ='${var_link_ipv6}'."
do_log "info" "false" "Live environment network check: Auto FQDN ='${var_auto_fqdn}'."
### Create network configuration file header.
if [[ -f "${TARGET}/etc/network/interfaces" ]]; then
mkdir -p "${DIR_BAK}/etc/network"
mv "${TARGET}/etc/network/interfaces" "${DIR_BAK}/etc/network/interfaces.bak"
do_log "info" "false" "Existing '${TARGET}/etc/network/interfaces' moved."
fi
cat << EOF >| "${TARGET}/etc/network/interfaces"
# 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
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
EOF
chmod 0644 "${TARGET}/etc/network/interfaces"
do_log "info" "false" "Header '${TARGET}/etc/network/interfaces' created."
### Configure network interfaces based on 'preseed.yaml' and create network configuration files for IPv4.
if [[ "${network_autoconfig_enable,,}" == "true" && "${network_choose_interface_auto,,}" == "true" ]]; then
### Reminder ###
# auto:
# For servers or systems with static interfaces that should always be available (e.g., eth0 on a server).
# For configurations where the interface should be active regardless of the cable status.
# allow-hotplug:
# For systems with dynamic or removable network devices (e.g., laptops or USB adapters).
# To avoid boot delays when interfaces are unavailable.
cat << EOF >| "${TARGET}/etc/network/interfaces/interfaces.d/10-ipv4-dhcp"
# 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
# The primary network interface IPv4
auto ${var_auto_nic}
iface ${var_auto_nic} inet dhcp
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
EOF
chmod 0644 "${TARGET}/etc/network/interfaces/interfaces.d/10-ipv4-dhcp"
do_log "info" "false" "IPv4 on the primary NIC: '${var_auto_nic}' configured with DHCP."
elif [[ "${network_autoconfig_enable,,}" == "true" && "${network_choose_interface_auto,,}" == "false" ]]; then
cat << EOF >| "${TARGET}/etc/network/interfaces/interfaces.d/10-ipv4-dhcp"
# 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
# The primary network interface IPv4
auto ${network_choose_interface_static}
iface ${network_choose_interface_static} inet dhcp
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
EOF
chmod 0644 "${TARGET}/etc/network/interfaces/interfaces.d/10-ipv4-dhcp"
do_log "info" "false" "IPv4 on the primary NIC: '${network_choose_interface_static}' configured with DHCP."
fi
if [[ "${network_autoconfig_enable,,}" == "false" ]]; then
cat << EOF >| "${TARGET}/etc/network/interfaces/interfaces.d/10-ipv4-static"
# 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
# The primary network interface IPv4
auto ${network_choose_interface_static}
iface ${network_choose_interface_static} inet static
address ${network_static_ipv4address}
netmask ${network_static_ipv4netmask}
gateway ${network_static_ipv4gateway}
dns-nameservers ${ary_ipv4_ns[*]}
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
EOF
chmod 0644 "${TARGET}/etc/network/interfaces/interfaces.d/10-ipv4-static"
do_log "info" "false" "IPv4 on the primary NIC: '${network_choose_interface_static}' configured statically."
fi
### Configure network interfaces based on 'preseed.yaml' and create network configuration files for IPv6.
if [[ "${network_autoconfig_enable,,}" == "true" && "${var_link_ipv6,,}" == "true" ]]; then
cat << EOF >| "${TARGET}/etc/network/interfaces/interfaces.d/10-ipv6-dhcp"
# 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
# The primary network interface IPv6
auto ${var_auto_nic}
iface ${var_auto_nic} inet6 dhcp
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
EOF
chmod 0644 "${TARGET}/etc/network/interfaces/interfaces.d/10-ipv6-dhcp"
do_log "info" "false" "IPv6 on the primary NIC: '${var_auto_nic}' configured with DHCP."
fi
if [[ "${network_autoconfig_enable,,}" == "false" && -n "${network_static_ipv6address}" ]]; then
cat << EOF >| "${TARGET}/etc/network/interfaces/interfaces.d/10-ipv6-static"
# 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
# The primary network interface IPv6
auto ${network_choose_interface_static}
iface ${network_choose_interface_static} inet6 static
address ${network_static_ipv6address}/${network_static_ipv6netmask}
gateway ${network_static_ipv6gateway}
dns-nameservers ${ary_ipv6_ns[*]}
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
EOF
chmod 0644 "${TARGET}/etc/network/interfaces/interfaces.d/10-ipv6-static"
do_log "info" "false" "IPv6 on the primary NIC: '${network_choose_interface_static}' configured statically."
fi
if [[ -f "${TARGET}/etc/resolv.conf" ]]; then
mkdir -p "${DIR_BAK}/etc"
mv "${TARGET}/etc/resolv.conf" "${DIR_BAK}/etc/resolv.conf.bak"
do_log "info" "false" "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.
if [[ "${network_autoconfig_enable,,}" == "false" ]]; then
cat << EOF >> "${TARGET}/etc/resolv.conf"
# 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
# Custom DNS IPv4 configuration
EOF
for ns in "${ary_ipv4_ns[@]}"; do
echo "nameserver ${ns}" >> "${TARGET}/etc/resolv.conf"
done
echo "" >> "${TARGET}/etc/resolv.conf"
do_log "info" "false" "IPv4 nameserver at: '${TARGET}/etc/resolv.conf' configured manually."
fi
### Create '/etc/resolv.conf' IPv6 entries for static configuration.
if [[ "${network_autoconfig_enable,,}" == "false" && -n "${network_static_ipv6address}" ]]; 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"
done
echo "" >> "${TARGET}/etc/resolv.conf"
do_log "info" "false" "IPv6 nameserver at: '${TARGET}/etc/resolv.conf' configured manually."
fi
cat << EOF >> "${TARGET}/etc/resolv.conf"
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
EOF
### Ensure Internet Systems Consortium DHCP Client is not overwriting the static nameserver settings.
if [[ -f "${TARGET}/etc/dhcp/dhclient.conf" ]]; then
mkdir -p "${DIR_BAK}/etc/dhcp"
cp "${TARGET}/etc/dhcp/dhclient.conf" "${DIR_BAK}/etc/dhcp/dhclient.conf.bak"
do_log "info" "false" "Existing '${TARGET}/etc/dhcp/dhclient.conf' saved."
fi
if [[ "${network_autoconfig_enable,,}" == "true" && -n "${network_static_ipv4nameserver_0}" ]]; then
cat << EOF >> "${TARGET}/etc/dhcp/dhclient.conf"
# Custom dhclient config to override DHCP DNS
EOF
declare var_supersede; var_supersede=$(printf "%s, " "${ary_ipv4_ns[@]}")
var_supersede="${var_supersede%, }"
echo "supersede domain-name-servers ${var_supersede};" >> "${TARGET}/etc/dhcp/dhclient.conf"
do_log "info" "false" "DHCP client configuration for IPv4: '${TARGET}/etc/dhcp/dhclient.conf' configured."
fi
if [[ "${network_autoconfig_enable,,}" == "false" && -n "${network_static_ipv6nameserver_0}" ]]; then
declare var_supersede_ipv6; var_supersede_ipv6=$(printf "%s, " "${ary_ipv6_ns[@]}")
var_supersede_ipv6="${var_supersede_ipv6%, }"
echo "supersede domain-name-servers ${var_supersede_ipv6};" >> "${TARGET}/etc/dhcp/dhclient.conf"
do_log "info" "false" "DHCP client configuration for IPv6: '${TARGET}/etc/dhcp/dhclient.conf' configured."
fi
if [[ "${network_autoconfig_enable,,}" == "true" && -n "${network_static_ipv4nameserver_0}" ]]; then
cat << EOF >> "${TARGET}/etc/dhcp/dhclient.conf"
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
EOF
fi
### Export hostname and IPv4 and IPv6 addresses for further processing according to dynamic results and preseed.yaml settings.
if [[ "${network_autoconfig_enable,,}" == "true" ]]; then
declare -grx VAR_FINAL_FQDN="${var_auto_fqdn}"
declare -grx VAR_FINAL_IPV4="${var_auto_ipv4}"
elif [[ "${network_autoconfig_enable,,}" == "false" ]]; then
declare -grx VAR_FINAL_FQDN="${network_hostname}"
declare -grx VAR_FINAL_IPV4="${network_static_ipv4address}"
fi
if [[ "${network_autoconfig_enable,,}" == "true" && "${var_link_ipv6,,}" == "true" ]]; then
declare -grx VAR_FINAL_IPV6="${var_auto_ipv6}"
declare -grx VAR_LINK_IPV6="${var_link_ipv6}"
elif [[ "${network_autoconfig_enable,,}" == "false" && -n "${network_static_ipv6address}" ]]; then
declare -grx VAR_FINAL_IPV6="${network_static_ipv6address}"
else
declare -grx VAR_FINAL_IPV6=""
fi
return 0
}
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh

View File

@@ -1,37 +0,0 @@
#!/bin/bash
# SPDX-Version: 3.0
# SPDX-CreationInfo: 2025-02-13; WEIDNER, Marc S.; <cendev@coresecret.eu>
# SPDX-ExternalRef: GIT https://cendev.eu/marc.weidner/CISS.2025.debian.installer.git
# SPDX-FileContributor: WEIDNER, Marc S.; Centurion Intelligence Consulting Agency
# SPDX-FileCopyrightText: 2024-2025; WEIDNER, Marc S.; <cendev@coresecret.eu>
# SPDX-FileType: SOURCE
# SPDX-License-Identifier: EUPL-1.2 OR LicenseRef-CCLA-1.0
# SPDX-LicenseComment: This file is part of the CISS.2025.hardened.installer framework.
# SPDX-PackageName: CISS.2025.hardened.installer
# SPDX-Security-Contact: security@coresecret.eu
###########################################################################################
# 3.7.7. Functions - installation - kernel #
###########################################################################################
###########################################################################################
# Installation of the specified kernel incl. dropbear SSH, LUKS Nuke.
# Globals:
# MODULE_ERR
# MODULE_TXT
# TARGET
# kernel
# Arguments:
# None
###########################################################################################
3_7_7_functions_installation_kernel() {
declare -g -x MODULE_ERR="3_7_7_functions_installation_kernel"
declare -g -x MODULE_TXT="Install kernel: '${kernel}'"
do_show_header "${MODULE_TXT}"
# Installing the chosen Kernel Image according to preseed.yaml
do_in_target "${TARGET}" apt-get install -y "${kernel}"
do_show_footer "${MODULE_TXT}"
}
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh:

View File

@@ -1,362 +0,0 @@
#!/bin/bash
# SPDX-Version: 3.0
# SPDX-CreationInfo: 2025-02-13; WEIDNER, Marc S.; <cendev@coresecret.eu>
# SPDX-ExternalRef: GIT https://cendev.eu/marc.weidner/CISS.2025.debian.installer.git
# SPDX-FileContributor: WEIDNER, Marc S.; Centurion Intelligence Consulting Agency
# SPDX-FileCopyrightText: 2024-2025; WEIDNER, Marc S.; <cendev@coresecret.eu>
# SPDX-FileType: SOURCE
# SPDX-License-Identifier: EUPL-1.2 OR LicenseRef-CCLA-1.0
# SPDX-LicenseComment: This file is part of the CISS.2025.hardened.installer framework.
# SPDX-PackageName: CISS.2025.hardened.installer
# SPDX-Security-Contact: security@coresecret.eu
###########################################################################################
# 3.7.8. Functions - installation - setup network #
###########################################################################################
# TODO collect Gateway and convert CCDIR ot n.n.n.n
###########################################################################################
# Setup network
# Globals:
# FINAL_FQDN
# FINAL_IPV4_ADDRESS
# FINAL_IPV6
# FINAL_IPV6_ADDRESS
# LOG_NIC
# MODULE_ERR
# MODULE_TXT
# TARGET
# network_autoconfig_enable
# network_choose_interface_auto
# network_choose_interface_static
# network_ipv6
# network_static_hostname
# network_static_ipv4address
# network_static_ipv4gateway
# network_static_ipv4nameserver_0
# network_static_ipv4nameserver_1
# network_static_ipv4nameserver_fallback_0
# network_static_ipv4netmask
# network_static_ipv6address
# network_static_ipv6gateway
# network_static_ipv6nameserver_0
# network_static_ipv6nameserver_1
# network_static_ipv6nameserver_fallback_0
# network_static_ipv6netmask
# network_timeout_dhcp
# Arguments:
# None
###########################################################################################
3_7_8_functions_installation_setup_network() {
declare -g -x MODULE_ERR="3_7_8_functions_installation_setup_network"
declare -g -x MODULE_TXT="Setup network"
do_show_header "${MODULE_TXT}"
# Initialize variables
declare ADDR_GI=""
declare ADDR_SI=""
declare ADDR_YI=""
declare DHCP_SRV=""
declare FQDN=""
declare HAS_NIC=""
declare HAS_IPV4=""
declare HAS_IPV6=""
declare HAS_IPV4_CCIDR=""
declare HAS_IPV6_CCIDR=""
declare HAS_LINKIPV4=""
declare HAS_LINKIPV6=""
declare NIC=""
# Check current network connection and configure variables
HAS_NIC=$(ip -o link show | awk -F': ' '/state UP/ {print $2; exit}')
HAS_IPV4_CCIDR=$(ip -4 -o addr show "${HAS_NIC}" | awk '{print $4; exit}')
HAS_IPV4_SUBNET=$(do_generate_subnet "${HAS_IPV4_CCIDR}")
HAS_IPV4=$(echo "$HAS_IPV4_CCIDR" | awk -F'/' '{print $1}')
HAS_IPV4_GATEWAY=$(ip route show default dev "${HAS_NIC}" | awk '/^default/ {print $3; exit}')
HAS_IPV6_CCIDR=$(ip -6 -o addr show "${HAS_NIC}" | awk '/scope global/ {print $4; exit}')
if [[ -n ${HAS_IPV6_CCIDR} ]]; then
HAS_IPV6=$(echo "${HAS_IPV6_CCIDR}" | awk -F'/' '{print $1}')
fi
HAS_LINKIPV4=$(ping -q -c 1 -W 1 -4 debian.org > /dev/null 2>&1 && echo "true" || echo "false")
HAS_LINKIPV6=$(ping -q -c 1 -W 1 -6 debian.org > /dev/null 2>&1 && echo "true" || echo "false")
do_log "info" "false" "Live environment DHCP information collection: timeout='${network_timeout_dhcp}' seconds."
dhclient -v -1 "${HAS_NIC}" 2>&1 | timeout "${network_timeout_dhcp}" dhcpdump -i "${HAS_NIC}" >> "${LOG_NIC}" || true
awk 'BEGIN {RS="---------------------------------------------------------------------------"; \
ORS="---------------------------------------------------------------------------"} \
NF {last=$0} END {print last}' "${LOG_NIC}" > "${LOG_NIC}".tmp && mv "${LOG_NIC}".tmp "${LOG_NIC}"
do_log "info" "false" "Live environment DHCP information collection: collection completed."
# Extract 'FQDN' from '${LOG_NIC}'
FQDN=$(awk -F 'Host name' '/Host name/ {print $2}' "${LOG_NIC}" | xargs)
# Extract 'YIADDR' (Your IP Address) from '${LOG_NIC}'
ADDR_YI=$(awk -F 'YIADDR:' '/YIADDR/ {print $2}' "${LOG_NIC}" | awk '{print $1}' | xargs)
# Extract 'SIADDR' (Server IP Address) from '${LOG_NIC}'
ADDR_SI=$(awk -F 'SIADDR:' '/SIADDR/ {print $2}' "${LOG_NIC}" | awk '{print $1}' | xargs)
# Extract 'Server Identifier' from '${LOG_NIC}'
DHCP_SRV=$(awk -F 'Server identifier' '/Server identifier/ {print $2}' "${LOG_NIC}" | xargs)
# Extract 'GIADDR' (Gateway IP Address) from '${LOG_NIC}'
ADDR_GI=$(awk -F 'GIADDR:' '/GIADDR/ {print $2}' "${LOG_NIC}" | awk '{print $1}' | xargs)
do_log "info" "false" "Live environment network check: HAS_NIC='${HAS_NIC}'."
do_log "info" "false" "Live environment network check: HAS_IPV4_CCIDR='${HAS_IPV4_CCIDR}'."
do_log "info" "false" "Live environment network check: HAS_IPV4_SUBNET='${HAS_IPV4_SUBNET}'."
do_log "info" "false" "Live environment network check: HAS_IPV4_GATEWAY='${HAS_IPV4_GATEWAY}'."
do_log "info" "false" "Live environment network check: HAS_IPV6_CCIDR='${HAS_IPV6_CCIDR}'."
do_log "info" "false" "Live environment network check: HAS_LINKIPV4='${HAS_LINKIPV4}'."
do_log "info" "false" "Live environment network check: HAS_LINKIPV6='${HAS_LINKIPV6}'."
do_log "info" "false" "Live environment network check: FQDN='${FQDN}'."
do_log "info" "false" "Live environment network check: ADDR_YI='${ADDR_YI}'."
do_log "info" "false" "Live environment network check: ADDR_SI='${ADDR_SI}'."
do_log "info" "false" "Live environment network check: DHCP_SRV='${DHCP_SRV}'."
do_log "info" "false" "Live environment network check: ADDR_GI='${ADDR_GI}'."
# Create network configuration file header.
if [[ -f "${TARGET}"/etc/network/interfaces ]]; then
rm "${TARGET}"/etc/network/interfaces
do_log "info" "false" "Existing '${TARGET}/etc/network/interfaces' removed."
fi
touch "${TARGET}"/etc/network/interfaces
chmod 0644 "${TARGET}"/etc/network/interfaces
cat << EOF >> "${TARGET}"/etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
EOF
do_log "info" "false" "Header '${TARGET}/etc/network/interfaces' created."
# Configure network interfaces based on 'preseed.yaml' and create network configuration files for IPv4.
if [[ ${network_autoconfig_enable,,} == "true" && ${network_choose_interface_auto,,} == "true" ]]; then
declare IFACE
for IFACE in $(ls /sys/class/net || true); do
if [[ -d "/sys/class/net/${IFACE}/device" ]]; then
NIC="${IFACE}"
break
fi
done
if [[ -z ${NIC} ]]; then
NIC="${network_choose_interface_static}"
do_log "notice" "false" "No physical NIC detected automatically. Use the specified static NIC instead: '${network_choose_interface_static}'."
else
do_log "info" "false" "The first physical auto-detected NIC is: '${NIC}'."
fi
### Reminder ###
# auto:
# For servers or systems with static interfaces that should always be available (e.g., eth0 on a server).
# For configurations where the interface should be active regardless of the cable status.
# allow-hotplug:
# For systems with dynamic or removable network devices (e.g., laptops or USB adapters).
# To avoid boot delays when interfaces are unavailable.
cat << EOF >> "${TARGET}"/etc/network/interfaces
# The primary network interface IPv4
auto "${NIC}"
iface "${NIC}" inet dhcp
EOF
do_log "info" "false" "IPv4 on the primary NIC: '${NIC}' configured with DHCP."
elif [[ ${network_autoconfig_enable,,} == "true" && ${network_choose_interface_auto,,} == "false" ]]; then
NIC="${network_choose_interface_static}"
cat << EOF >> "${TARGET}"/etc/network/interfaces
# The primary network interface IPv4
auto "${NIC}"
iface "${NIC}" inet dhcp
EOF
do_log "info" "false" "IPv4 on the primary NIC: '${NIC}' configured with DHCP."
else
do_log "warning" "false" "No NIC specified. 'network_choose_interface_static' was: '${network_choose_interface_static}'."
fi
if [[ ${network_autoconfig_enable,,} == "false" ]]; then
cat << EOF >> "${TARGET}"/etc/network/interfaces
# The primary network interface IPv4
auto "${network_choose_interface_static}"
iface "${network_choose_interface_static}" inet static
address "${network_static_ipv4address}"
netmask "${network_static_ipv4netmask}"
gateway "${network_static_ipv4gateway}"
dns-nameservers "${network_static_ipv4nameserver_0}" "${network_static_ipv4nameserver_1}" "${network_static_ipv4nameserver_fallback_0}"
EOF
do_log "info" "false" "IPv4 on the primary NIC: '${network_choose_interface_static}' configured manually."
else
do_log "error" "false" "Network autoconfiguration 'network_autoconfig_enable' must be either 'true' or 'false'."
fi
# Configure network interfaces based on 'preseed.yaml' and create network configuration files for IPv6.
if [[ ${network_autoconfig_enable} == "true" && ${HAS_LINKIPV6} == "true" ]]; then
cat << EOF >> "${TARGET}"/etc/network/interfaces
# The primary network interface IPv6
iface "${HAS_NIC}" inet6 dhcp
EOF
do_log "info" "false" "IPv6 on the primary NIC: '${HAS_NIC}' configured with DHCP."
fi
if [[ ${network_autoconfig_enable,,} == "false" && ${network_ipv6,,} == "true" ]]; then
cat << EOF >> "${TARGET}"/etc/network/interfaces
# The primary network interface IPv6
iface "${HAS_NIC}" inet6 static
address "${network_static_ipv6address}"/"${network_static_ipv6netmask}"
gateway "${network_static_ipv6gateway}"
dns-nameservers "${network_static_ipv6nameserver_0}" "${network_static_ipv6nameserver_1}" "${network_static_ipv6nameserver_fallback_0}"
EOF
do_log "info" "false" "IPv6 on the primary NIC: '${HAS_NIC}' configured manually."
fi
# Until now, neither 'NetworkManager' nor 'systemd-resolved' are installed.
# Therefore, '/etc/resolv.conf' is updated, too.
# Create '/etc/resolv.conf' IPv4 entries.
if [[ -f "${TARGET}"/etc/resolv.conf ]]; then
rm "${TARGET}"/etc/resolv.conf
do_log "info" "false" "Existing '${TARGET}/etc/resolv.conf' removed."
fi
touch "${TARGET}"/etc/resolv.conf
chmod 0644 "${TARGET}"/etc/resolv.conf
cat << EOF >> "${TARGET}"/etc/resolv.conf
# Custom DNS IPv4 configuration for DHCP
nameserver ${network_static_ipv4nameserver_0}
nameserver ${network_static_ipv4nameserver_1}
nameserver ${network_static_ipv4nameserver_fallback_0}
EOF
do_log "info" "false" "IPv4 nameserver at: '${TARGET}/etc/resolv.conf' configured manually."
# Create '/etc/resolv.conf' IPv6 entries.
if [[ ${network_autoconfig_enable,,} == "true" && ${HAS_LINKIPV6,,} == "true" ]]; then
cat << EOF >> "${TARGET}"/etc/resolv.conf
# Custom DNS IPv6 configuration for DHCP
nameserver ${network_static_ipv6nameserver_0}
nameserver ${network_static_ipv6nameserver_1}
nameserver ${network_static_ipv6nameserver_fallback_0}
EOF
do_log "info" "false" "IPv6 nameserver at: '${TARGET}/etc/resolv.conf' configured manually."
elif [[ ${network_autoconfig_enable,,} == "false" && ${network_ipv6,,} == "true" ]]; then
cat << EOF >> "${TARGET}"/etc/resolv.conf
# Custom DNS IPv6 configuration for DHCP
nameserver ${network_static_ipv6nameserver_0}
nameserver ${network_static_ipv6nameserver_1}
nameserver ${network_static_ipv6nameserver_fallback_0}
EOF
do_log "info" "false" "IPv6 nameserver at: '${TARGET}/etc/resolv.conf' configured manually."
fi
# Ensure Internet Systems Consortium DHCP Client is not overwriting the static nameserver settings.
if [[ ${network_autoconfig_enable,,} == "true" && ${HAS_LINKIPV6,,} == "true" ]]; then
cat << EOF > "${TARGET}"/etc/dhcp/dhclient.conf
# Custom DNS IPv4 and IPv6 configuration for DHCP
supersede domain-name-servers \
${network_static_ipv4nameserver_0}, \
${network_static_ipv4nameserver_1}, \
${network_static_ipv4nameserver_fallback_0}, \
${network_static_ipv6nameserver_0}, \
${network_static_ipv6nameserver_1}, \
${network_static_ipv6nameserver_fallback_0};
EOF
do_log "info" "false" "DHCP client configuration for IPv4 and IPv6 at: '${TARGET}/etc/dhcp/dhclient.conf' configured."
elif [[ ${network_autoconfig_enable,,} == "false" && ${network_ipv6,,} == "true" ]]; then
cat << EOF > "${TARGET}"/etc/dhcp/dhclient.conf
# Custom DNS IPv4 and IPv6 configuration for DHCP
supersede domain-name-servers \
${network_static_ipv4nameserver_0}, \
${network_static_ipv4nameserver_1}, \
${network_static_ipv4nameserver_fallback_0}, \
${network_static_ipv6nameserver_0}, \
${network_static_ipv6nameserver_1}, \
${network_static_ipv6nameserver_fallback_0};
EOF
do_log "info" "false" "DHCP client configuration IPv4 and IPv6 at: '${TARGET}/etc/dhcp/dhclient.conf' configured."
else
cat << EOF > "${TARGET}"/etc/dhcp/dhclient.conf
# Custom DNS IPv4 only configuration for DHCP
supersede domain-name-servers \
${network_static_ipv4nameserver_0}, \
${network_static_ipv4nameserver_1}, \
${network_static_ipv4nameserver_fallback_0};
EOF
do_log "info" "false" "DHCP client configuration IPv4 only at: '${TARGET}/etc/dhcp/dhclient.conf' configured."
fi
# Export hostname and IPv4 and IPv6 addresses for further processing according to dynamic results and preseed.yaml settings.
if [[ ${network_autoconfig_enable,,} == "true" ]]; then
declare -g -r -x FINAL_FQDN="${FQDN}"
declare -g -r -x FINAL_IPV4_ADDRESS="${ADDR_YI}"
elif [[ ${network_autoconfig_enable,,} == "false" ]]; then
declare -g -r -x FINAL_FQDN="${network_static_hostname}"
declare -g -r -x FINAL_IPV4_ADDRESS="${network_static_ipv4address}"
fi
if [[ ${network_autoconfig_enable,,} == "true" && ${HAS_LINKIPV6,,} == "true" ]]; then
declare -g -r -x FINAL_IPV6_ADDRESS="${HAS_IPV6}"
declare -g -r -x FINAL_IPV6="${HAS_LINKIPV6}"
elif [[ ${network_autoconfig_enable,,} == "false" && ${network_ipv6,,} == "true" ]]; then
declare -g -r -x FINAL_IPV6_ADDRESS="${network_static_ipv6address}"
fi
do_show_footer "${MODULE_TXT}"
}
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh: