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:
@@ -15,11 +15,13 @@ guard_sourcing
|
||||
#######################################
|
||||
# Configure the '/etc/hostname' | '/etc/hosts' | '/etc/mailname' files.
|
||||
# Globals:
|
||||
# RECOVERY
|
||||
# TARGET
|
||||
# VAR_FINAL_FQDN
|
||||
# VAR_FINAL_IPV4
|
||||
# VAR_FINAL_IPV6
|
||||
# VAR_LINK_IPV6
|
||||
# VAR_RUN_RECOVERY
|
||||
# network_ipv6
|
||||
# Arguments:
|
||||
# None
|
||||
@@ -27,36 +29,42 @@ guard_sourcing
|
||||
# 0: on success
|
||||
#######################################
|
||||
setup_hostname() {
|
||||
### Create the '${TARGET}/etc/hostname' file.
|
||||
cat << EOF >| "${TARGET}/etc/hostname"
|
||||
### Declare Arrays, HashMaps, and Variables.
|
||||
declare var_target="${TARGET}"
|
||||
|
||||
### Check for TARGET / RECOVERY.
|
||||
[[ "${VAR_RUN_RECOVERY}" == "true" ]] && var_target="${RECOVERY}"
|
||||
|
||||
### Create the '${var_target}/etc/hostname' file.
|
||||
cat << EOF >| "${var_target}/etc/hostname"
|
||||
${VAR_FINAL_FQDN}
|
||||
EOF
|
||||
chmod 0644 "${TARGET}/etc/hostname"
|
||||
do_log "info" "file_only" "4030() File generated: '${TARGET}/etc/hostname' | hostname '${VAR_FINAL_FQDN}'."
|
||||
chmod 0644 "${var_target}/etc/hostname"
|
||||
do_log "info" "file_only" "4030() File generated: '${var_target}/etc/hostname' | hostname '${VAR_FINAL_FQDN}'."
|
||||
|
||||
|
||||
### Create the '${TARGET}/etc/mailname' file.
|
||||
cat << EOF >| "${TARGET}/etc/mailname"
|
||||
### Create the '${var_target}/etc/mailname' file.
|
||||
cat << EOF >| "${var_target}/etc/mailname"
|
||||
${VAR_FINAL_FQDN}
|
||||
EOF
|
||||
chmod 0644 "${TARGET}/etc/mailname"
|
||||
do_log "info" "file_only" "4030() File generated: '${TARGET}/etc/mailname' | mailname '${VAR_FINAL_FQDN}'."
|
||||
chmod 0644 "${var_target}/etc/mailname"
|
||||
do_log "info" "file_only" "4030() File generated: '${var_target}/etc/mailname' | mailname '${VAR_FINAL_FQDN}'."
|
||||
|
||||
|
||||
### Generate '${TARGET}/etc/hosts' basic IPv4 entries
|
||||
cat << EOF >| "${TARGET}/etc/hosts"
|
||||
### Generate '${var_target}/etc/hosts' basic IPv4 entries
|
||||
cat << EOF >| "${var_target}/etc/hosts"
|
||||
127.0.0.1 localhost
|
||||
${VAR_FINAL_IPV4} ${VAR_FINAL_FQDN}
|
||||
|
||||
EOF
|
||||
chmod 0644 "${TARGET}/etc/hosts"
|
||||
do_log "info" "file_only" "4030() File generated: '${TARGET}/etc/hosts' with basic IPv4 entries."
|
||||
chmod 0644 "${var_target}/etc/hosts"
|
||||
do_log "info" "file_only" "4030() File generated: '${var_target}/etc/hosts' with basic IPv4 entries."
|
||||
|
||||
|
||||
### Generate '${TARGET}/etc/hosts' basic IPv6 entries
|
||||
### Generate '${var_target}/etc/hosts' basic IPv6 entries
|
||||
if [[ "${VAR_LINK_IPV6,,}" == "true" || "${network_ipv6,,}" == "true" ]]; then
|
||||
|
||||
cat << EOF >> "${TARGET}/etc/hosts"
|
||||
cat << EOF >> "${var_target}/etc/hosts"
|
||||
# The following lines are desirable for IPv6 capable hosts
|
||||
::1 localhost ip6-localhost ip6-loopback
|
||||
fe00::0 ip6-localnet
|
||||
@@ -68,10 +76,13 @@ ${VAR_FINAL_IPV6} ${VAR_FINAL_FQDN}
|
||||
|
||||
EOF
|
||||
|
||||
do_log "info" "file_only" "4030() File updated: '${TARGET}/etc/hosts' with basic IPv6 entries."
|
||||
do_log "info" "file_only" "4030() File updated: '${var_target}/etc/hosts' with basic IPv6 entries."
|
||||
|
||||
fi
|
||||
|
||||
guard_dir && return 0
|
||||
}
|
||||
### Prevents accidental 'unset -f'.
|
||||
# shellcheck disable=SC2034
|
||||
readonly -f setup_hostname
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||
|
||||
Reference in New Issue
Block a user