Only modify hostname and fstab if we need to still

This commit is contained in:
Salt 2020-12-04 06:29:55 -06:00
parent 479cc5a705
commit 9f91f0afdc

View File

@ -168,8 +168,13 @@ configure-gentoo() {
nameserver 8.8.4.4
EOF
# Hostname
if [ -f "$_optdest/etc/conf.d/hostname" ]; then
hostname="$(<"$_optdest/etc/conf.d/hostname")"
log "Detected hostname $hostname"
else
read -p "Enter system hostname: " hostname
echo "$hostname" > "$_optdest/etc/conf.d/hostname"
fi
# hosts
log "Configuring hosts"
cat <<-EOF > "$_optdest/etc/hosts"
@ -186,6 +191,9 @@ configure-gentoo() {
en_US.UTF-8 UTF-8
EOF
# fstab
if grep "$_optdest/etc/fstab" -ie '^[[:blank:]]*[^[:blank:]#]' > /dev/null 2>&1; then
log "Configured fstab detected"
else
log "Dropping to editor to configure fstab"
cat <<-EOF > "$_optdest/etc/fstab"
# fstab - Filesystem table
@ -194,6 +202,7 @@ configure-gentoo() {
#LABEL=gentoo / ext4 defaults,noatime,errors=remount-ro 0 1
EOF
"${EDITOR:-vim}" "$_optdest/etc/fstab"
fi
# Now we need to pivot into a chroot and finish configuration natively
popd > /dev/null 2>&1