V8.00.000.2025.06.17
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 1m46s
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:
@@ -12,13 +12,46 @@
|
||||
|
||||
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() {
|
||||
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=""
|
||||
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
|
||||
|
||||
ary_ipv4_ns+=("${network_static_ipv4nameserver_0}")
|
||||
|
||||
74
func/4140_setup_hostname.sh
Normal file
74
func/4140_setup_hostname.sh
Normal 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
|
||||
Reference in New Issue
Block a user