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