Prompt for hostname, better logging

This commit is contained in:
Salt 2020-12-04 01:49:17 -06:00
parent 99fbab1ee8
commit 62a0b3bf19
1 changed files with 15 additions and 5 deletions

View File

@ -129,6 +129,7 @@ build-gentoo() {
pushd "$_optdest" > /dev/null 2>&1
# These is a very generic make.conf to get the system up and running
# We use march of x86-64 to ensure compatibility if we're bootstrapping on a host other than the target
log "Building make.conf"
cat <<-EOF > "$_optdest/etc/portage/make.conf"
# ABI_X86 is used to control multilib support
ABI_X86="64 32"
@ -143,6 +144,7 @@ build-gentoo() {
USE="networkmanager systemd -elogind -test"
EOF
# This is required on >=17.1 to unroll some circular dependencies
log "Setting package.use settings for gentoostrap"
cat <<-EOF > "$_optdest/etc/portage/package.use/gentoostrap"
# These solve circular dependency issues
dev-lang/python -bluetooth -sqlite
@ -150,26 +152,36 @@ build-gentoo() {
sys-libs/ncurses -gpm
EOF
# Configure default ebuild repositories
log "Syncing ebuild repos"
mkdir -p "$_optdest/etc/portage/repos.conf"
cp "$_optdest/usr/share/portage/config/repos.conf" \
"$_optdest/etc/portage/repos.conf/gentoo.conf"
# DNS
log "Configuring DNS"
cat <<-EOF > "$_optdest/etc/resolv.conf"
nameserver 8.8.8.8
nameserver 8.8.4.4
EOF
# Hostname
echo "$(hostname -s)" > "$_optdest/etc/conf.d/hostname"
read -p "Enter system hostname: " hostname
echo "$hostname" > "$_optdest/etc/conf.d/hostname"
# hosts
echo "127.0.0.1 $(hostname -s)" > "$_optdest/etc/hosts"
log "Configuring hosts"
cat <<-EOF > "$_optdest/etc/hosts"
127.0.0.1 $hostname
::1 $hostname
EOF
# Timezone
log "Configuring timezone"
cp /etc/timezone "$_optdest/etc/timezone"
# Locale
log "Configuring locale"
cat <<-EOF > "$_optdest/etc/locale.gen"
en_US ISO-8859-1
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
@ -181,6 +193,7 @@ build-gentoo() {
# Now we need to pivot into a chroot and finish configuration natively
# Buuuut... since we're using systemd, we get to just spawn a systemd-nspawn container
popd
log "Pivoting to container for more setup"
cp "$0" "$_optdest/gentoostrap.sh"
sudo systemd-nspawn --directory="$_optdest" /gentoostrap.sh -c
@ -256,9 +269,6 @@ build-gentoo-chroot() {
* Install and configure grub
* Reboot and pray
Other things you may want to do:
* Change the system hostname
Dumping to a shell now. Have fun!
EOF
exec bash