feat: generate ssh keys before generating initramfs in case sshd needs them

This commit is contained in:
oddlama 2022-07-01 14:10:38 +02:00
parent 01c73895dd
commit b3324498fb
No known key found for this signature in database
GPG Key ID: 14EFE510775FE39A
2 changed files with 17 additions and 12 deletions

View File

@ -950,10 +950,8 @@ function gentoo_chroot() {
function enable_service() { function enable_service() {
if [[ $SYSTEMD == "true" ]]; then if [[ $SYSTEMD == "true" ]]; then
systemctl enable "$1" \ try systemctl enable "$1"
|| die "Could not enable $1 service"
else else
rc-update add "$1" default \ try rc-update add "$1" default
|| die "Could not add $1 to default services"
fi fi
} }

View File

@ -167,6 +167,7 @@ dracut \\
--no-hostonly \\ --no-hostonly \\
--ro-mnt \\ --ro-mnt \\
--add "bash ${modules[*]}" \\ --add "bash ${modules[*]}" \\
${dracut_opts[@]@Q} \\
--force \\ --force \\
"$output" "$output"
EOF EOF
@ -266,7 +267,6 @@ function install_kernel_bios() {
function install_kernel() { function install_kernel() {
# Install vanilla kernel # Install vanilla kernel
einfo "Installing vanilla kernel and related tools" einfo "Installing vanilla kernel and related tools"
try emerge --verbose sys-kernel/dracut sys-kernel/gentoo-kernel-bin app-arch/zstd
if [[ $IS_EFI == "true" ]]; then if [[ $IS_EFI == "true" ]]; then
install_kernel_efi install_kernel_efi
@ -353,9 +353,16 @@ EOF
try emerge --sync try emerge --sync
fi fi
einfo "Generating ssh host keys"
try ssh-keygen -A
# Install authorized_keys before dracut, which might need them for remote unlocking. # Install authorized_keys before dracut, which might need them for remote unlocking.
install_authorized_keys install_authorized_keys
# Install required programs and kernel now, in oder to
# prevent emerging module before an imminent kernel upgrade
try emerge --verbose sys-kernel/dracut sys-kernel/gentoo-kernel-bin app-arch/zstd
# Install mdadm if we used raid (needed for uuid resolving) # Install mdadm if we used raid (needed for uuid resolving)
if [[ $USED_RAID == "true" ]]; then if [[ $USED_RAID == "true" ]]; then
einfo "Installing mdadm" einfo "Installing mdadm"
@ -381,13 +388,13 @@ EOF
einfo "Enabling zfs services" einfo "Enabling zfs services"
if [[ $SYSTEMD == "true" ]]; then if [[ $SYSTEMD == "true" ]]; then
systemctl enable zfs.target || die "Could not enable zfs.target service" try systemctl enable zfs.target
systemctl enable zfs-import-cache || die "Could not enable zfs-import-cache service" try systemctl enable zfs-import-cache
systemctl enable zfs-mount || die "Could not enable zfs-mount service" try systemctl enable zfs-mount
systemctl enable zfs-import.target || die "Could not enable zfs-import.target service" try systemctl enable zfs-import.target
else else
rc-update add zfs-import boot || die "Could not add zfs-import to boot services" try rc-update add zfs-import boot
rc-update add zfs-mount boot || die "Could not add zfs-mount to boot services" try rc-update add zfs-mount boot
fi fi
fi fi
@ -412,7 +419,7 @@ EOF
else else
addresses="" addresses=""
for addr in "${SYSTEMD_NETWORKD_ADDRESSES[@]}"; do for addr in "${SYSTEMD_NETWORKD_ADDRESSES[@]}"; do
addresses="Address=$addr\n" addresses="${addresses}Address=$addr\n"
done done
echo -en "[Match]\nName=${SYSTEMD_NETWORKD_INTERFACE_NAME}\n\n[Network]\n${addresses}Gateway=$SYSTEMD_NETWORKD_GATEWAY" > /etc/systemd/network/20-wired.network \ echo -en "[Match]\nName=${SYSTEMD_NETWORKD_INTERFACE_NAME}\n\n[Network]\n${addresses}Gateway=$SYSTEMD_NETWORKD_GATEWAY" > /etc/systemd/network/20-wired.network \
|| die "Could not write dhcp network config to '/etc/systemd/network/20-wired.network'" || die "Could not write dhcp network config to '/etc/systemd/network/20-wired.network'"