Proposed hook system to allow further customization at specific steps of the installation process.

- before/after_prepare_environment
- before/after_disk_configuration
- before/after_download_stage3
- before/after_extract_stage3

- before/after_install
- before/after_configure_base_system
- before/after_configure_portage
- before/after_install_kernel
This commit is contained in:
Carlos Prado 2023-01-06 22:42:05 +01:00
parent e5067f0c43
commit cd4c2de711
No known key found for this signature in database
GPG Key ID: AF40FF1711925DB8
3 changed files with 32 additions and 0 deletions

View File

@ -64,6 +64,8 @@ function preprocess_config() {
}
function prepare_installation_environment() {
maybe_exec 'before_prepare_environment'
einfo "Preparing installation environment"
local wanted_programs=(
@ -94,6 +96,8 @@ function prepare_installation_environment() {
# Sync time now to prevent issues later
sync_time
maybe_exec 'after_prepare_environment'
}
function check_encryption_key() {
@ -735,6 +739,8 @@ function apply_disk_configuration() {
|| die "Aborted"
countdown "Applying in " 5
maybe_exec 'before_disk_configuration'
einfo "Applying disk configuration"
apply_disk_actions
@ -742,6 +748,8 @@ function apply_disk_configuration() {
elog "New lsblk output:"
for_line_in <(lsblk \
|| die "Error in lsblk") elog
maybe_exec 'after_disk_configuration'
}
function mount_efivars() {
@ -819,6 +827,8 @@ function download_stage3() {
# File to indiciate successful verification
CURRENT_STAGE3_VERIFIED="${CURRENT_STAGE3}.verified"
maybe_exec 'before_download_stage3' "$STAGE3_BASENAME"
# Download file if not already downloaded
if [[ -e $CURRENT_STAGE3_VERIFIED ]]; then
einfo "$STAGE3_BASENAME tarball already downloaded and verified"
@ -855,6 +865,8 @@ function download_stage3() {
# Create verification file in case the script is restarted
touch_or_die 0644 "$CURRENT_STAGE3_VERIFIED"
fi
maybe_exec 'after_download_stage3' "${CURRENT_STAGE3}"
}
function extract_stage3() {
@ -865,6 +877,8 @@ function extract_stage3() {
[[ -e "$TMP_DIR/$CURRENT_STAGE3" ]] \
|| die "stage3 file does not exist"
maybe_exec 'before_extract_stage3' "$TMP_DIR/$CURRENT_STAGE3" "$ROOT_MOUNTPOINT"
# Go to root directory
cd "$ROOT_MOUNTPOINT" \
|| die "Could not move to '$ROOT_MOUNTPOINT'"
@ -879,6 +893,8 @@ function extract_stage3() {
|| die "Error while extracting tarball"
cd "$TMP_DIR" \
|| die "Could not cd into '$TMP_DIR'"
maybe_exec 'after_extract_stage3' "$TMP_DIR/$CURRENT_STAGE3" "$ROOT_MOUNTPOINT"
}
function gentoo_umount() {

View File

@ -320,6 +320,8 @@ function generate_fstab() {
function main_install_gentoo_in_chroot() {
[[ $# == 0 ]] || die "Too many arguments"
maybe_exec 'before_install'
# Remove the root password, making the account accessible for automated
# tasks during the period of installation.
einfo "Clearing root password"
@ -342,9 +344,12 @@ function main_install_gentoo_in_chroot() {
try emerge-webrsync
# Configure basic system things like timezone, locale, ...
maybe_exec 'before_configure_base_system'
configure_base_system
maybe_exec 'after_configure_base_system'
# Prepare portage environment
maybe_exec 'before_configure_portage'
configure_portage
# Install git (for git portage overlays)
@ -372,6 +377,7 @@ EOF
|| die "Could not delete obsolete rsync gentoo repository"
try emerge --sync
fi
maybe_exec 'after_configure_portage'
einfo "Generating ssh host keys"
try ssh-keygen -A
@ -421,7 +427,9 @@ EOF
fi
# Install kernel and initramfs
maybe_exec 'before_install_kernel'
install_kernel
maybe_exec 'after_install_kernel'
# Generate a valid fstab file
generate_fstab
@ -487,6 +495,8 @@ EOF
|| die "Could not modify /etc/portage/make.conf"
fi
maybe_exec 'after_install'
einfo "Gentoo installation complete."
[[ $USED_LUKS == "true" ]] \
&& einfo "A backup of your luks headers can be found at '$LUKS_HEADER_BACKUP_DIR', in case you want to have a backup."

View File

@ -445,3 +445,9 @@ function check_wanted_programs() {
ask "Continue without recommended programs?"
fi
}
# exec function if defined
# $1 function name
function maybe_exec() {
type "$1" >/dev/null 2>&1 && eval "$*"
}