diff --git a/gentoostrap.sh b/gentoostrap.sh index a711865..72db496 100755 --- a/gentoostrap.sh +++ b/gentoostrap.sh @@ -168,8 +168,13 @@ configure-gentoo() { nameserver 8.8.4.4 EOF # Hostname - read -p "Enter system hostname: " hostname - echo "$hostname" > "$_optdest/etc/conf.d/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,14 +191,18 @@ configure-gentoo() { en_US.UTF-8 UTF-8 EOF # fstab - log "Dropping to editor to configure fstab" - cat <<-EOF > "$_optdest/etc/fstab" - # fstab - Filesystem table - # See fstab(5) for syntax and configuration information - # Example: - #LABEL=gentoo / ext4 defaults,noatime,errors=remount-ro 0 1 - EOF - "${EDITOR:-vim}" "$_optdest/etc/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 + # See fstab(5) for syntax and configuration information + # 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 popd > /dev/null 2>&1