Work on automating GRUB install
This commit is contained in:
parent
fce752a017
commit
5bdd634354
@ -79,6 +79,8 @@ Usage: $_name [OPTION]...
|
|||||||
|
|
||||||
-h Print this help text
|
-h Print this help text
|
||||||
-c Perform the Gentoo half of installation. Must be invoked from a chroot
|
-c Perform the Gentoo half of installation. Must be invoked from a chroot
|
||||||
|
or a systemd-nspawn container
|
||||||
|
-d Perform the second Gentoo half of installation from a chroot
|
||||||
-v Print more status messages. Stacks
|
-v Print more status messages. Stacks
|
||||||
|
|
||||||
Copyright (c) 2020 rehashedsalt@cock.li
|
Copyright (c) 2020 rehashedsalt@cock.li
|
||||||
@ -198,7 +200,13 @@ build-gentoo() {
|
|||||||
sudo systemd-nspawn --directory="$_optdest" /gentoostrap.sh -c
|
sudo systemd-nspawn --directory="$_optdest" /gentoostrap.sh -c
|
||||||
|
|
||||||
# The nspawn container sadly cannot manipulate the environment entirely, so we need to now do an ACTUAL chroot to install GRUB
|
# The nspawn container sadly cannot manipulate the environment entirely, so we need to now do an ACTUAL chroot to install GRUB
|
||||||
|
mount --types proc /proc "$_optdest/proc"
|
||||||
|
mount --rbind /sys "$_optdest/sys"
|
||||||
|
mount --make-rslave "$_optdest/sys"
|
||||||
|
mount --rbind /dev "$_optdest/dev"
|
||||||
|
mount --make-rslave "$_optdest/dev"
|
||||||
|
chroot "$_optdest" /gentoostrap.sh -d
|
||||||
|
log "Configuration complete! You should be good to reboot now."
|
||||||
}
|
}
|
||||||
build-gentoo-chroot() {
|
build-gentoo-chroot() {
|
||||||
# Build Gentoo, but from within the chroot environment
|
# Build Gentoo, but from within the chroot environment
|
||||||
@ -235,6 +243,7 @@ build-gentoo-chroot() {
|
|||||||
emerge --jobs --quiet-build y \
|
emerge --jobs --quiet-build y \
|
||||||
app-admin/sudo \
|
app-admin/sudo \
|
||||||
app-editors/vim \
|
app-editors/vim \
|
||||||
|
sys-boot/grub:2 \
|
||||||
sys-fs/{e2fs,xfs}progs \
|
sys-fs/{e2fs,xfs}progs \
|
||||||
sys-process/cronie
|
sys-process/cronie
|
||||||
|
|
||||||
@ -252,7 +261,6 @@ build-gentoo-chroot() {
|
|||||||
#emerge --jobs --quiet-build y @module-rebuild
|
#emerge --jobs --quiet-build y @module-rebuild
|
||||||
|
|
||||||
# Install the bootloader
|
# Install the bootloader
|
||||||
emerge --jobs --quiet-build y sys-boot/grub:2
|
|
||||||
mkdir -p /boot/efi
|
mkdir -p /boot/efi
|
||||||
chmod 0700 /boot/efi
|
chmod 0700 /boot/efi
|
||||||
|
|
||||||
@ -267,13 +275,21 @@ build-gentoo-chroot() {
|
|||||||
cat <<-EOF
|
cat <<-EOF
|
||||||
Initial system configuration is complete. There are now just a few tasks left:
|
Initial system configuration is complete. There are now just a few tasks left:
|
||||||
* Mount the ESP under /boot/efi
|
* Mount the ESP under /boot/efi
|
||||||
* Install and configure grub
|
* Make sure everything looks good before we install GRUB
|
||||||
* Reboot and pray
|
|
||||||
|
|
||||||
Dumping to a shell now. Have fun!
|
Dumping to a shell now. Have fun!
|
||||||
EOF
|
EOF
|
||||||
exec bash
|
exec bash
|
||||||
}
|
}
|
||||||
|
build-gentoo-chroot2() {
|
||||||
|
# Last few chroot steps, mostly involving GRUB
|
||||||
|
log "Configuring GRUB"
|
||||||
|
grub-mkconfig -o /boot/grub
|
||||||
|
log "Installing GRUB"
|
||||||
|
grub-install
|
||||||
|
cat <<-EOF
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
# Main
|
# Main
|
||||||
main() {
|
main() {
|
||||||
@ -282,6 +298,9 @@ main() {
|
|||||||
# Parse out flags
|
# Parse out flags
|
||||||
while getopts ":chv" opt; do
|
while getopts ":chv" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
|
d)
|
||||||
|
_optchroot2=1
|
||||||
|
;;
|
||||||
c)
|
c)
|
||||||
_optchroot=1
|
_optchroot=1
|
||||||
;;
|
;;
|
||||||
@ -313,15 +332,17 @@ main() {
|
|||||||
# TODO: That
|
# TODO: That
|
||||||
# Validate core program dependencies
|
# Validate core program dependencies
|
||||||
log "Validating dependencies" 2
|
log "Validating dependencies" 2
|
||||||
if ! has basename curl sha512sum systemd-nspawn tar; then
|
if ! has basename chroot curl sha512sum systemd-nspawn tar; then
|
||||||
error "Failed to find program: $_return" 1
|
error "Failed to find program: $_return" 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Do the do
|
# Do the do
|
||||||
if [ -z "$_optchroot" ]; then
|
if [ -n "$_optchroot2" ]; then
|
||||||
build-gentoo
|
build-gentoo-chroot2
|
||||||
else
|
elif [ -n "$_optchroot" ]; then
|
||||||
build-gentoo-chroot
|
build-gentoo-chroot
|
||||||
|
else
|
||||||
|
build-gentoo
|
||||||
fi
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user