From e2da4a1138bd4eb612228351732799d61a3cee7b Mon Sep 17 00:00:00 2001 From: langfingaz Date: Sun, 2 May 2021 16:13:39 +0200 Subject: [PATCH] installer script: work in progress (11) --- pkg/de-p1st-installer/de-p1st-installer.sh | 40 +++++++++++++++++++++- pkg/de-p1st-installer/installer.cfg | 3 ++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/pkg/de-p1st-installer/de-p1st-installer.sh b/pkg/de-p1st-installer/de-p1st-installer.sh index 61a06e8..fd85f09 100755 --- a/pkg/de-p1st-installer/de-p1st-installer.sh +++ b/pkg/de-p1st-installer/de-p1st-installer.sh @@ -242,6 +242,40 @@ function run_genfstab() { printf "%s" "${fstab}" > /mnt/etc/fstab || return $? } +function config_hostname_and_hosts() { + # @pre + # HOSTNAME + # FQDN (optional, e.g. sub.domain.de) + # STATIC_IP (optional, e.g. 93.133.433.133) + # IPV6_CAPABLE (optional, e.g. 1) + + echo "${HOSTNAME}" >/mnt/etc/hostname || return $? + + # If the system has a permanent IP address, it should be used instead of 127.0.1.1. + # * https://wiki.archlinux.org/index.php/Installation_guide#Network_configuration + + # Desirable entries IPv4/IPv6: + # * https://man.archlinux.org/man/hosts.5#EXAMPLES + + # If FQDN not given, use $HOSTNAME.localdomain instead + FQDN="${FQDN:="${HOSTNAME}.localdomain"}" + # If STATIC_IP not given, use 127.0.1.1 instead + STATIC_IP="${STATIC_IP:='127.0.1.1'}" + + echo "# The following lines are desirable for IPv4 capable hosts +127.0.0.1 localhost +# 127.0.1.1 is often used for the FQDN of the machine +${STATIC_IP} ${FQDN} ${HOSTNAME}" > /mnt/etc/hosts || return $? + + if [ "${IPV6_CAPABLE}" = "1" ]; then + echo " +# The following lines are desirable for IPv6 capable hosts +::1 localhost ip6-localhost ip6-loopback +ff02::1 ip6-allnodes +ff02::2 ip6-allrouters" >> /mnt/etc/hosts || return $? + fi +} + function main() { # @pre # bash libraries imported @@ -280,10 +314,14 @@ function main() { mkdir /mnt/boot || return $? mount "$BOOT_PART" /mnt/boot || return $? + # in: BIOS_TYPE, KERNEL, CPU_VENDOR run_pacstrap || return $? + # in: FS run_genfstab || return $? - echo "${HOSTNAME}" >/mnt/etc/hostname || return $? + # in: HOSTNAME, FQDN (optional), STATIC_IP (optional), IPV6_CAPABLE (optional) + config_hostname_and_hosts || return $? + } main "$@" diff --git a/pkg/de-p1st-installer/installer.cfg b/pkg/de-p1st-installer/installer.cfg index f70b824..311cd98 100644 --- a/pkg/de-p1st-installer/installer.cfg +++ b/pkg/de-p1st-installer/installer.cfg @@ -1,6 +1,9 @@ # Example config # for test in virtual machine +# FQDN=domain.name.of.this.host.de +# STATIC_IP=123.456.789.012 +# IPV6_CAPABLE=1 HOSTNAME=yodaTest USERNAME=arch