V8.00.000.2025.06.17
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 1m46s

Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
2025-07-15 11:18:34 +02:00
parent c6fb626204
commit be61f50318
3 changed files with 109 additions and 104 deletions

View File

@@ -12,13 +12,46 @@
guard_sourcing guard_sourcing
# Setup network #######################################
# Setup network.
# Globals:
# DIR_BAK
# TARGET
# VAR_FINAL_FQDN
# VAR_FINAL_IPV4
# VAR_FINAL_IPV6
# VAR_LINK_IPV6
# network_autoconfig_enable
# network_choose_interface_auto
# network_choose_interface_static
# network_hostname
# network_static_ipv4address
# network_static_ipv4gateway
# network_static_ipv4nameserver_0
# network_static_ipv4nameserver_1
# network_static_ipv4nameserver_2
# network_static_ipv4nameserver_fallback_0
# network_static_ipv4nameserver_fallback_1
# network_static_ipv4netmask
# network_static_ipv6address
# network_static_ipv6gateway
# network_static_ipv6nameserver_0
# network_static_ipv6nameserver_1
# network_static_ipv6nameserver_2
# network_static_ipv6nameserver_fallback_0
# network_static_ipv6nameserver_fallback_1
# network_static_ipv6netmask
# Arguments:
# None
# Returns:
# 0: Successfully executed commands.
#######################################
setup_network() { setup_network() {
do_in_target "${TARGET}" apt-get install -y isc-dhcp-client ifupdown do_in_target "${TARGET}" apt-get install -y isc-dhcp-client ifupdown
mkdir -p "${TARGET}/etc/network/interfaces/interfaces.d" 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="" \ 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="" var_auto_ipv6_ccidr="" var_auto_ipv6="" var_auto_ipv6_gw="" var_link_ipv4="" var_link_ipv6="" var_auto_fqdn="" ns=""
declare -a ary_ipv4_ns ary_ipv6_ns declare -a ary_ipv4_ns ary_ipv6_ns
ary_ipv4_ns+=("${network_static_ipv4nameserver_0}") ary_ipv4_ns+=("${network_static_ipv4nameserver_0}")

View File

@@ -0,0 +1,74 @@
#!/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
#######################################
# Generate files: '/etc/hostname' | '/etc/hosts' | '/etc/mailname'
# Globals:
# TARGET
# VAR_FINAL_FQDN
# VAR_FINAL_IPV4
# VAR_FINAL_IPV6
# VAR_LINK_IPV6
# network_ipv6
# Arguments:
# None
# Returns:
# 0: Successfully executed commands.
#######################################
setup_hostname() {
### Create '${TARGET}/etc/hostname' file.
cat << EOF >| "${TARGET}/etc/hostname"
${VAR_FINAL_FQDN}
EOF
chmod 0644 "${TARGET}/etc/hostname"
do_log "info" "true" "File generated: '${TARGET}/etc/hostname' | hostname '${VAR_FINAL_FQDN}'."
### Create '${TARGET}/etc/mailname' file.
cat << EOF >| "${TARGET}/etc/mailname"
${VAR_FINAL_FQDN}
EOF
chmod 0644 "${TARGET}/etc/mailname"
do_log "info" "true" "File generated: '${TARGET}/etc/mailname' | mailname '${VAR_FINAL_FQDN}'."
### Generate '${TARGET}/etc/hosts' basic IPv4 entries
cat << EOF >| "${TARGET}/etc/hosts"
127.0.0.1 localhost
${VAR_FINAL_IPV4} ${VAR_FINAL_FQDN}
EOF
chmod 0644 "${TARGET}/etc/hosts"
do_log "info" "true" "File generated: '${TARGET}/etc/hosts' with basic IPv4 entries."
### Generate '${TARGET}/etc/hosts' basic IPv6 entries
if [[ "${VAR_LINK_IPV6,,}" == "true" || "${network_ipv6,,}" == "true" ]]; then
cat << EOF >> "${TARGET}/etc/hosts"
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
${VAR_FINAL_IPV6} ${VAR_FINAL_FQDN}
EOF
do_log "info" "true" "File updated: '${TARGET}/etc/hosts' with basic IPv6 entries."
fi
return 0
}
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh

View File

@@ -1,102 +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.9. Functions - installation - setup hostname #
###########################################################################################
###########################################################################################
# Generate files: '/etc/hostname' | '/etc/hosts' | '/etc/mailname'
# Globals:
# FINAL_FQDN
# FINAL_IPV4_ADDRESS
# FINAL_IPV6
# FINAL_IPV6_ADDRESS
# MODULE_ERR
# MODULE_TXT
# TARGET
# network_hostname
# network_ipv6
# Arguments:
# None
###########################################################################################
3_7_9_functions_installation_setup_hostname() {
declare -g -x MODULE_ERR="3_7_9_functions_installation_setup_hostname"
declare -g -x MODULE_TXT="Setup hostname '${network_hostname}'"
do_show_header "${MODULE_TXT}"
# Create '${TARGET}/etc/hostname' file.
if [[ -f "${TARGET}"/etc/hostname ]]; then
rm "${TARGET}"/etc/hostname
do_log "info" "false" "Existing '${TARGET}/etc/hostname' removed."
fi
touch "${TARGET}"/etc/hostname
chmod 0644 "${TARGET}"/etc/hostname
cat << EOF >> "${TARGET}"/etc/hostname
"${FINAL_FQDN}"
EOF
do_log "info" "false" "File generated: '${TARGET}/etc/hostname' | hostname '${network_hostname}'."
# Create '${TARGET}/etc/mailname' file.
if [[ -f "${TARGET}"/etc/mailname ]]; then
rm "${TARGET}"/etc/mailname
do_log "info" "false" "Existing '${TARGET}/etc/mailname' removed."
fi
touch "${TARGET}"/etc/mailname
chmod 0644 "${TARGET}"/etc/mailname
cat << EOF >> "${TARGET}"/etc/mailname
"${FINAL_FQDN}"
EOF
do_log "info" "false" "File generated: '${TARGET}/etc/mailname' | mailname '${network_hostname}'."
# Generate '${TARGET}/etc/hosts' basic IPv4 entries
if [[ -f "${TARGET}"/etc/hosts ]]; then
rm "${TARGET}"/etc/hosts
do_log "info" "false" "Existing '${TARGET}/etc/hosts' removed."
fi
touch "${TARGET}"/etc/hosts
chmod 0644 "${TARGET}"/etc/hosts
cat << EOF >> "${TARGET}"/etc/hosts
127.0.0.1 localhost
"${FINAL_IPV4_ADDRESS}" "${FINAL_FQDN}"
EOF
do_log "info" "false" "File generated: '${TARGET}/etc/hosts' with basic IPv4 entries."
# Generate '${TARGET}/etc/hosts' basic IPv6 entries
if [[ ${FINAL_IPV6,,} == "true" || ${network_ipv6,,} == "true" ]]; then
cat << EOF >> "${TARGET}"/etc/hosts
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
"${FINAL_IPV6_ADDRESS}" "${FINAL_FQDN}"
EOF
do_log "info" "false" "File updated: '${TARGET}/etc/hosts' with basic IPv6 entries."
fi
do_show_footer "${MODULE_TXT}"
}
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh: