installer script: work in progress (11)

This commit is contained in:
Daniel Langbein 2021-05-02 16:13:39 +02:00
parent 338705b4e5
commit e2da4a1138
2 changed files with 42 additions and 1 deletions

View File

@ -242,6 +242,40 @@ function run_genfstab() {
printf "%s" "${fstab}" > /mnt/etc/fstab || return $? 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() { function main() {
# @pre # @pre
# bash libraries imported # bash libraries imported
@ -280,10 +314,14 @@ function main() {
mkdir /mnt/boot || return $? mkdir /mnt/boot || return $?
mount "$BOOT_PART" /mnt/boot || return $? mount "$BOOT_PART" /mnt/boot || return $?
# in: BIOS_TYPE, KERNEL, CPU_VENDOR
run_pacstrap || return $? run_pacstrap || return $?
# in: FS
run_genfstab || return $? 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 "$@" main "$@"

View File

@ -1,6 +1,9 @@
# Example config # Example config
# for test in virtual machine # for test in virtual machine
# FQDN=domain.name.of.this.host.de
# STATIC_IP=123.456.789.012
# IPV6_CAPABLE=1
HOSTNAME=yodaTest HOSTNAME=yodaTest
USERNAME=arch USERNAME=arch