Compare commits

..

69 Commits
v1.2.1 ... main

Author SHA1 Message Date
9f5889764f Modificar gentoo.conf.example 2024-02-22 12:04:45 -01:00
ab713b917c Modificar configure 2024-02-22 12:01:52 -01:00
c710af26b6 Modificar configure 2024-02-22 11:58:33 -01:00
oddlama
039d1a8b35
docs: update kernel name in docs 2024-02-05 01:02:18 +01:00
oddlama
93e1aa3a9c
Merge pull request #111 from kasperfm/develop
Add option to enable binary packages in make.conf
2024-02-04 17:17:07 +01:00
Kasper Færch Mikkelsen
87d508455d
Update main.sh
Fixed gnupg key file not readable by portage
2024-02-04 01:09:42 +01:00
Kasper Færch Mikkelsen
248e8cd375 Added support for binary portage packages 2024-02-04 00:30:58 +01:00
oddlama
3daf3132e7
fix: also search for kernel images named kernel-* 2024-02-03 15:58:16 +01:00
oddlama
d1ddab6038
Merge pull request #110 from OskiBoski483/main
Add dracut use flag
2024-02-03 15:56:44 +01:00
Oskar Nizioł
5fc7bfdcab
Add dracut use flag 2024-02-03 13:35:07 +01:00
oddlama
353d4d6af0
Merge pull request #106 from thiblizz/patch-10
fix: minor typos
2023-11-20 02:03:53 +01:00
thiblizz
1ca6b53d0f
fix: minor typos 2023-11-20 01:03:53 +01:00
oddlama
1fe44e7218
Merge pull request #104 from thiblizz/patch-9
fix: musl stage3 installation on the stable branch
2023-11-13 13:41:30 +01:00
thiblizz
d0e8078927
fix: musl stage3 installation on the stable branch 2023-11-12 18:55:36 +01:00
oddlama
403c5ef3d7
Merge pull request #103 from thiblizz/patch-8
fix: "error: format: Identifier id='part_root' not found"
2023-11-12 16:58:27 +01:00
thiblizz
c816559958
fix: "error: format: Identifier id='part_root' not found" 2023-11-12 15:26:01 +01:00
oddlama
1815d710ff
Merge pull request #102 from thiblizz/patch-7
feat: support musl timezone
2023-11-06 11:52:16 +01:00
thiblizz
de8c16211b feat: support musl timezone 2023-11-05 15:51:12 +01:00
oddlama
f5ba6e5147
Merge pull request #101 from thiblizz/patch-6
feat: more flexible default layout
2023-10-29 14:21:58 +01:00
thiblizz
4309e3b17b feat: more flexible default layout 2023-10-23 00:05:27 +02:00
oddlama
f2f3e96211
Merge pull request #99 from thiblizz/patch-5
feat: increase the boot/EFI partition to 1GiB (closes oddlama#98)
2023-10-22 13:02:19 +02:00
thiblizz
7681d73bcb feat: increase the boot/EFI partition to 1GiB (closes oddlama#98) 2023-10-22 12:51:22 +02:00
oddlama
1ea9489566
Merge pull request #97 from thiblizz/main
feat: add raid1 support
2023-10-22 12:49:49 +02:00
thiblizz
d8c8096b85 Revert "feat: increase the boot/EFI partition to 1GiB (closes #98)"
This reverts commit 0c790740f3.
2023-10-21 17:02:59 +02:00
thiblizz
0c790740f3
feat: increase the boot/EFI partition to 1GiB (closes #98) 2023-10-21 16:54:52 +02:00
thiblizz
fa7d0df609
fix: unused variable 2023-10-21 16:45:24 +02:00
thiblizz
647da12b43
fix: address review comments 2023-10-21 16:36:28 +02:00
thiblizz
e5b0fe6313
feat: add raid1 support 2023-10-20 23:39:49 +02:00
oddlama
dfabf41185
Merge pull request #96 from thiblizz/patch-4
fix: minor typos
2023-10-15 14:18:51 +02:00
oddlama
b15f89eec1
Merge branch 'main' into patch-4 2023-10-15 12:28:51 +02:00
oddlama
b2880b08f3
Merge pull request #95 from thiblizz/patch-3
fix: use UTF-8 as the default locale instead of utf8 (closes #92)
2023-10-15 12:26:09 +02:00
oddlama
c8bbcb8333
Merge pull request #94 from thiblizz/patch-2
fix: adjust wrong root_fs check
2023-10-15 12:25:18 +02:00
thiblizz
dcd8b8b5cd
fix: minor typos 2023-10-15 04:01:05 +02:00
thiblizz
0ebe7915a6
fix: use UTF-8 as the default locale instead of utf8 (closes #92) 2023-10-15 02:18:09 +02:00
thiblizz
c6b2d52ff7
fix: adjust wrong root_fs check 2023-10-14 23:47:48 +02:00
oddlama
716e062661
Merge pull request #90 from thiblizz/patch-1
Fix musl stage3 variant
2023-10-13 19:15:52 +02:00
thiblizz
e9f7f6603c
Revert to initial logic 2023-10-13 02:47:14 +02:00
thiblizz
5d27a4c1c9
Make musl variant optional 2023-10-13 02:28:23 +02:00
thiblizz
d7ef780331
Fix musl stage3 variant 2023-10-13 01:18:00 +02:00
Nick Booker
1321769bb5
Fix booting from encrypted root filesystem with systemd (#78)
* Fix booting from encrypted root filesystem with systemd

systemd needs to be built with cryptsetup for it to work

* Limit cryptsetup USE flag and emerge to systemd
2023-03-28 16:10:41 +02:00
Carlos Prado
b2ea9b360d
feat: hooks (#70)
* Hooks

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

* add hook examples

* fix: remove eval
2023-01-07 14:02:15 +01:00
Carlos Prado
e5067f0c43 add all stage3 options available in gentoo.org
Also, variants description are updated to 'explain' the differences between them.
2023-01-05 15:18:09 +01:00
Mathieu Gouttenoire
2036d785f1 Fix stage3 download on other architectures 2022-12-22 15:01:56 +01:00
oddlama
dbb8b81c26
fix: missing /sys prefix when determining partition numbers 2022-12-21 14:10:47 +01:00
oddlama
2a2ef9abd7
fix: more robust way to extract efi partition and parent device (fixes #63) 2022-12-20 13:07:48 +01:00
oddlama
133fe3901a
fix: use 644 permissions on /etc/timezone, apparently some builds depend on it. Fixes #66 2022-12-20 12:51:25 +01:00
oddlama
2397569412
chore: adhere to shellcheck rules 2022-10-05 15:49:37 +02:00
oddlama
6c1a7e846b
fix: disable swap after creating to prevent some live environments from using the swap immediately (fixes #57) 2022-10-05 15:47:48 +02:00
oddlama
8919c61568
chore: clean ouput and add comments to installed scripts 2022-10-05 15:44:52 +02:00
oddlama
551423eb4a
docs: add link to efibootmgr wiki (closes #58) 2022-10-05 15:44:07 +02:00
Min Xu
3888a552fa
fix: Wait for device symlink after partitioning (#56)
Co-authored-by: Min Xu <min.xu.public@gmail.com>
2022-10-05 15:32:02 +02:00
oddlama
d46010ba7b
fix(syntax): missing && (closes #55) 2022-10-01 13:33:55 +02:00
oddlama
7b9586ad30
fix: checkfile set even if tuple is not a expression (fixes #51) 2022-09-28 17:55:13 +02:00
oddlama
1975f75d02
feat: always install linux-firmware (fixes #50) 2022-09-28 17:51:53 +02:00
oddlama
3e18167a06
fix: always use included locale file to prevent mismatches (closes #52) 2022-09-28 17:45:34 +02:00
oddlama
c56f1766cc
chore: update eoli3n zfs init script location
see 4d726eafbb
2022-08-31 20:55:44 +02:00
oddlama
b22ff29173
fix: stage3 menu label confusion (fixes #46) 2022-07-01 20:34:19 +02:00
oddlama
70e51eaad8
fix: change into /tmp before downloading dracut-sshd 2022-07-01 19:55:13 +02:00
oddlama
b78dea2dc7
fix: make all rbound mountpoints also rslaves. 2022-07-01 19:54:26 +02:00
oddlama
b3324498fb
feat: generate ssh keys before generating initramfs in case sshd needs them 2022-07-01 14:10:38 +02:00
oddlama
01c73895dd
chore: clarify that CIDR masks are required for network addresses 2022-07-01 02:11:30 +02:00
oddlama
7efb6886d0
fix: don't wipe inputbox options when cancelling 2022-07-01 02:08:13 +02:00
oddlama
998828fe9a
feat: networkd options and remote crypt unlocking 2022-07-01 02:04:23 +02:00
oddlama
a97fcaabc8
feat: mount /run to suppress warnings (closes #44) 2022-06-30 21:22:57 +02:00
oddlama
0350ada8c3
fix: ZFS compression was not properly enabled on the rpool dataset 2022-06-29 02:15:32 +02:00
oddlama
81fc06784e
chore: add warning about changing mirrors 2022-06-28 17:32:13 +02:00
oddlama
2d5b04dcc7
fix: mirror selections were not applied 2022-06-28 17:29:38 +02:00
oddlama
b8134d4a50
docs: add troubleshooting for ZFS kernel mismatch 2022-06-28 17:29:02 +02:00
oddlama
944c745ce7
chore: enable portage testing after installation to hopefully ensure a better installation experience. 2022-06-09 18:44:08 +02:00
9 changed files with 659 additions and 165 deletions

View File

@ -22,7 +22,7 @@ This installer might appeal to you if
- you want to try gentoo without initially investing a lot of time, or fully committing to it yet.
- you already are a gentoo expert but want an automatic and repeatable best-practices installation.
Of course we do encourage everyone to install gentoo manually. You will learn a lot if you
Of course, we do encourage everyone to install gentoo manually. You will learn a lot if you
haven't done so already.
## Usage
@ -43,11 +43,15 @@ Every option is explained in detail in `gentoo.conf.example` and in the help men
When installing, you will be asked to review the partitioning before anything critical is done.
The installer should be able to run without any user supervision after partitioning, but depending
on the current state of the gentoo repository you might need to intervene in case a package fails
on the current state of the gentoo repository, you might need to intervene in case a package fails
to emerge. The critical commands will ask you what to do in case of a failure. If you encounter a
problem you cannot solve, you might want to consider getting in contact with some experienced people
on [IRC](https://www.gentoo.org/get-involved/irc-channels/) or [Discord](https://discord.com/invite/gentoolinux).
If you need to enter an installed system in a chroot to fix something (e.g. after rebooting your live system),
you can always clone the installer, mount your main drive under `/mnt` and use `./install --chroot /mnt` to
just chroot into your system.
## Overview
The installer performs the following main steps (in roughly this order),
@ -71,7 +75,7 @@ Here are some things that you might want to consider doing after the system inst
1. Read the news with `eselect news read`.
2. Compile a custom kernel and remove `gentoo-kernel-bin`
3. Adjust `/etc/portage/make.conf`
- Set `CFLAGS` to `-O2 -pipe <march_native_flags>` for native builds by useing the `resolve-march-native` tool
- Set `CFLAGS` to `<march_native_flags> -O2 -pipe` for native builds by using the `resolve-march-native` tool
- Set `CPU_FLAGS_X86` using the `cpuid2cpuflags` tool
4. Use a safe umask like `umask 077`
@ -96,7 +100,7 @@ this to a minimum, because of the quite "interactive" nature of gentoo package m
By default, the installed system uses gentoo's binary kernel distribution (`sys-kernel/gentoo-kernel-bin`)
together with an initramfs generated by dracut. This ensures that the installed system works on all common hardware configurations.
Feel free to replace this with a custom built kernel (and possibly remove/adjust the initramfs) when the system is booted.
Feel free to replace this with a custom-built kernel (and possibly remove/adjust the initramfs) when the system is booted.
The installer will provide the convenience script `generate_initramfs.sh` in `/boot/efi/`
or `/boot/bios` which may be used to generate a new initramfs for the given kernel version.
@ -117,7 +121,7 @@ In both cases, the update procedure is as follows:
2. `eselect kernel set <kver>`
3. Backup old kernel and initramfs (`mv "$kernel"{,.bak}`, `mv "$initrd"{,.bak}`)
4. Generate new initramfs for this kernel `generate_initramfs.sh <kver> "$initrd"`
5. Copy new kernel `cp /boot/vmlinuz-<kver> "$kernel"`
5. Copy new kernel `cp /boot/kernel-<kver> "$kernel"` (for systemd) or `cp /boot/vmlinuz-<kver> "$kernel"` (for openrc)
## Recommendations
@ -138,16 +142,18 @@ Only certain VPS hosters may require you to use BIOS still (time to write to the
Don't install a bootloader when this script is done, except you absolutely need one.
The kernel can directly be booted by EFI without need for a bootloader.
By default, this script will use efibootmgr to add a bootentry directly to your "mainboard's bootselect" (typically F12).
Nowadays, there's just no reason use GRUB, syslinux, or similar bootloaders by default.
Nowadays, there's just no reason to use GRUB, syslinux, or similar bootloaders by default.
They only add additional time to your boot, and even dualbooting Windows works just fine without one.
Only if you require frequent editing of kernel parameters, or want kernel autodiscovery from attached media
you might want to consider using one of these. For the average (advanced) user this isn't necessary.
If you want to add more boot options or want to learn about efibootmgr, refer to [this page on the gentoo wiki](https://wiki.gentoo.org/wiki/Efibootmgr).
#### Modern file systems
I recommend using a modern file system like ZFS. It provides transparent block-level compression,
instant snapshots and full-disk encryption. Generally encrypting your root fs doesn't cost you
anything and protects your data in case you lose your device.
I recommend using a modern file system like ZFS, both on desktops and servers.
It provides transparent block-level compression, instant snapshots and full-disk encryption.
Generally, encrypting your root fs doesn't cost you anything and protects your data in case you lose your device.
#### Systemd vs OpenRC
@ -165,7 +171,7 @@ Make of this what you will, both have their own quirks. Choose your poison.
#### Miscellaneous
- Use the newer iwd for WIFI instead of wpa_supplicant
- Use the newer iwd for WiFi instead of wpa_supplicant
- (If systemd) Use timers instead of cron jobs
## Troubleshooting and FAQ
@ -185,6 +191,20 @@ or [Discord](https://discord.com/invite/gentoolinux).
If you experience any issues after rebooting and need to fix something inside the chroot,
you can use the installer to chroot into an existing system. Run `./install --help` for more infos.
#### Q: ZFS cannot be installed in the chroot due to an unsupported kernel version
**A:** The newest stable ZFS module may require a kernel version that is newer than what is provided on gentoo stable.
If you encounter this problem, you might be able to fix the problem by switching to testing by dropping to a shell temporarily:
```
# Press S<Enter> when asked about what to do next.
# This opens an emergency shell in the chroot.
echo 'ACCEPT_KEYWORDS="~amd64"' >> /etc/portage/make.conf # Enable testing for your architecture.
emerge -v gentoo-kernel-bin # Update kernel to newest version
exit # Ctrl-D
# Now select 'retry' when asked about what to do next.
```
#### Q: I get errors after partitioning about blkid not being able to find a UUID
**A:** Be sure that all devices are unmounted and not in use before starting the script.

234
configure vendored
View File

@ -43,7 +43,7 @@ while [[ $# -gt 0 ]]; do
shift
done
check_wanted_programs dialog ncurses=ncursesw6-config
check_wanted_programs dialog libncurses-dev=ncursesw6-config
# Determine whether EFI is available
HAS_EFI_SUPPORT=$([[ -d /sys/firmware/efi ]] && echo -n "true" || echo -n "false")
@ -67,7 +67,7 @@ function get_timezone() {
timezone=${file#*zoneinfo/}
if [[ $timezone == "$file" ]]; then
# not pointing to expected location or not Region/City
echo "Europe/London"
echo "Atlantic/Azores"
else
echo "$timezone"
fi
@ -108,14 +108,6 @@ function get_all_timezones() {
readarray -t ALL_TIMEZONES < <(find /usr/share/zoneinfo -type f -printf "%P\n" | sort -u)
}
function get_supported_locales() {
if [[ -e /usr/share/i18n/SUPPORTED ]]; then
echo /usr/share/i18n/SUPPORTED
else
echo "$GENTOO_INSTALL_REPO_DIR/contrib/i18n_supported"
fi
}
function recalculate_locales() {
LOCALES=""
N_LOCALES=0
@ -176,7 +168,8 @@ function define_disk_layout() {
define_disk_configuration_function "create_existing_partitions_layout boot=${PARTITIONING_BOOT_DEVICE@Q} swap=${swapdev@Q} type=${PARTITIONING_BOOT_TYPE@Q}" "${PARTITIONING_DEVICE@Q}" ;;
"zfs_centric") define_disk_configuration_function "create_zfs_centric_layout swap=$(define_swap) type=${PARTITIONING_BOOT_TYPE@Q} encrypt=${PARTITIONING_ZFS_USE_ENCRYPTION@Q} compress=$(define_zfs_compression) pool_type=${PARTITIONING_ZFS_POOL_TYPE@Q}" "${PARTITIONING_DEVICES[@]@Q}" ;;
"btrfs_centric") define_disk_configuration_function "create_btrfs_centric_layout swap=$(define_swap) type=${PARTITIONING_BOOT_TYPE@Q} raid_type=${PARTITIONING_BTRFS_RAID_TYPE@Q} luks=${PARTITIONING_USE_LUKS@Q}" "${PARTITIONING_DEVICES[@]@Q}" ;;
"raid0_luks") define_disk_configuration_function "create_raid0_luks_layout swap=$(define_swap) type=${PARTITIONING_BOOT_TYPE@Q} root_fs=${PARTITIONING_ROOT_FS@Q}" "${PARTITIONING_DEVICES[@]@Q}" ;;
"raid0_luks") define_disk_configuration_function "create_raid0_luks_layout swap=$(define_swap) type=${PARTITIONING_BOOT_TYPE@Q} luks=${PARTITIONING_USE_LUKS@Q} root_fs=${PARTITIONING_ROOT_FS@Q}" "${PARTITIONING_DEVICES[@]@Q}" ;;
"raid1_luks") define_disk_configuration_function "create_raid1_luks_layout swap=$(define_swap) type=${PARTITIONING_BOOT_TYPE@Q} luks=${PARTITIONING_USE_LUKS@Q} root_fs=${PARTITIONING_ROOT_FS@Q}" "${PARTITIONING_DEVICES[@]@Q}" ;;
"custom")
# Show current function declaration, trim trailing whitespace
declare -f disk_configuration \
@ -187,16 +180,27 @@ function define_disk_layout() {
ALL_GENTOO_ARCHS=("x86" "amd64" "arm" "arm64")
ALL_STAGE3_VARIANTS=(
"systemd" "systemd | Minimal systemd base (recommended)"
"openrc" "openrc | Minimal OpenRC base (recommended)"
"desktop-systemd" "desktop-systemd | OpenRC, desktop profile, might have blockers"
"desktop-openrc" "desktop-openrc | systemd, desktop profile, might have blockers"
"nomultilib-systemd" "nomultilib-systemd | Untested. Might work, but not explicitly tested"
"nomultilib-openrc" "nomultilib-openrc | Untested. Might work, but not explicitly tested"
"hardened-nomultilib-openrc" "hardened-nomultilib-openrc | Untested. Might work, but not explicitly tested"
"hardened-nomultilib-selinux-openrc" "hardened-nomultilib-selinux-openrc | Untested. Might work, but not explicitly tested"
"hardened-openrc" "hardened-openrc | Untested. Might work, but not explicitly tested"
"hardened-selinux-openrc" "hardened-selinux-openrc | Untested. Might work, but not explicitly tested"
"desktop-openrc" "openrc-desktop | OpenRC, desktop profile, might have blockers"
"systemd" "systemd | Minimal systemd base (recommended)"
"systemd-mergedusr" "systemd-mergedusr | Minimal systemd base with merged filesystem layout"
"desktop-systemd" "systemd-desktop | systemd, desktop profile, might have blockers"
"nomultilib-openrc" "nomultilib-openrc | Minimal OpenRC base without 32bits support (Experimental)"
"nomultilib-systemd" "nomultilib-systemd | Minimal systemd base without 32bits support (Experimental)"
"nomultilib-systemd-mergedusr" "nomultilib-systemd-mergedusr | Minimal systemd base with merged filesystem layout and without 32bits support (Experimental)"
"x32-openrc" "x32-openrc | Minimal OpenRC base without 64bits support (Experimental)"
"x32-systemd" "x32-systemd | Minimal systemd base without 64bits support (Experimental)"
"x32-systemd-mergedusr" "x32-systemd-mergedusr | Minimal systemd base with merged filesystem layout and without 64bits support (Experimental)"
"llvm-openrc" "llvm-openrc | Minimal OpenRC base compiled with LLVM (Experimental)"
"llvm-systemd" "llvm-systemd | Minimal systemd base compiled with LLVM (Experimental)"
"llvm-systemd-mergedusr" "llvm-systemd-mergedusr | Minimal systemd base with merged filesystem layout compiled with LLVM (Experimental)"
"hardened-openrc" "hardened-openrc | Hardened OpenRC base (Experimental)"
"hardened-nomultilib-openrc" "hardened-nomultilib-openrc | Hardened OpenRC base without 32bits support (Experimental)"
"hardened-selinux-openrc" "hardened-selinux-openrc | Hardened OpenRC base with SELinux (Experimental)"
"hardened-nomultilib-selinux-openrc" "hardened-nomultilib-selinux-openrc | Hardened OpenRC base with SELinux and without 32bits support (Experimental)"
"musl" "musl-openrc | Minimal OpenRC base using musl (Experimental)"
"musl-llvm" "musl-llvm-openrc | Minimal OpenRC base using musl compiled with LLVM (Experimental)"
"musl-hardened" "musl-hardened-openrc | Hardened OpenRC base using musl (Experimental)"
)
ALL_PARTITIONING_SCHEMES=(
@ -205,6 +209,7 @@ ALL_PARTITIONING_SCHEMES=(
"zfs_centric" "ZFS centric (optional ZFS compression and encryption)"
"btrfs_centric" "Btrfs centric (optional raid0/1 via btrfs)"
"raid0_luks" "Raid0 (N>=2 disks) and luks for root"
"raid1_luks" "Raid1 (N>=2 disks) and luks for root"
"custom" "Custom (expert option; edit the config manually later)"
)
@ -279,13 +284,28 @@ function create_existing_partitions_layout() {
function create_raid0_luks_layout() {
PARTITIONING_SCHEME="raid0_luks"
local known_arguments=('+swap' '?type' '?root_fs')
local known_arguments=('+swap' '?type' '?luks' '?root_fs')
local extra_arguments=()
declare -A arguments; parse_arguments "$@"
PARTITIONING_DEVICES=("${extra_arguments[@]}")
parse_swap "${arguments[swap]}"
PARTITIONING_BOOT_TYPE="${arguments[type]}"
PARTITIONING_USE_LUKS="${arguments[luks]:-true}"
PARTITIONING_ROOT_FS="${arguments[root_fs]:-ext4}"
}
function create_raid1_luks_layout() {
PARTITIONING_SCHEME="raid1_luks"
local known_arguments=('+swap' '?type' '?luks' '?root_fs')
local extra_arguments=()
declare -A arguments; parse_arguments "$@"
PARTITIONING_DEVICES=("${extra_arguments[@]}")
parse_swap "${arguments[swap]}"
PARTITIONING_BOOT_TYPE="${arguments[type]}"
PARTITIONING_USE_LUKS="${arguments[luks]:-true}"
PARTITIONING_ROOT_FS="${arguments[root_fs]:-ext4}"
}
@ -329,7 +349,7 @@ function create_btrfs_centric_layout() {
get_all_keymaps
get_all_timezones
readarray -t SUPPORTED_LOCALES < "$(get_supported_locales)"
readarray -t SUPPORTED_LOCALES < "$GENTOO_INSTALL_REPO_DIR/contrib/i18n_supported"
readarray -t LOCALE_A < <(locale -a)
@ -379,7 +399,7 @@ function load_config() {
# shellcheck disable=SC1090
source "$1" || die "Could not load given configuration."
# After loading a config no unsaved changes exist.
# After loading a config, no unsaved changes exist.
UNSAVED_CHANGES=false
}
@ -389,7 +409,14 @@ function load_default_config() {
KEYMAP="$(get_default_keymap)"
KEYMAP_INITRAMFS="$KEYMAP"
LOCALES="C.UTF-8 UTF-8"
LOCALE="C.utf8"
LOCALE="C.UTF-8"
SYSTEMD_NETWORKD=true
SYSTEMD_NETWORKD_INTERFACE_NAME="en*"
SYSTEMD_NETWORKD_DHCP=true
SYSTEMD_NETWORKD_ADDRESSES=("192.168.1.100/32" "fd00::1/64")
SYSTEMD_NETWORKD_GATEWAY="192.168.1.1"
SYSTEMD_INITRAMFS_SSHD=false
function disk_configuration() {
#create_zfs_centric_layout swap=8GiB type="$DEFAULT_BOOT_TYPE" encrypt=true compress=zstd pool_type=standard /dev/sdX
@ -409,8 +436,10 @@ function load_default_config() {
SELECT_MIRRORS_LARGE_FILE=false
ADDITIONAL_PACKAGES=()
INSTALL_SSHD=true
ENABLE_SSHD=true
ENABLE_BINPKG=false
ROOT_SSH_AUTHORIZED_KEYS=""
# All settings are unsaved.
UNSAVED_CHANGES=true
@ -467,6 +496,12 @@ function on_off_label() {
on_off_str "$1" "${prefix}[*]" "${prefix}[ ]"
}
function on_off_label_inverted() {
local var=$1
shift
on_off_label "$(is_on "$var" && echo false || echo true)" "$@"
}
function is_on() {
[[ "$1" == true ]]
}
@ -843,6 +878,12 @@ MENU_ITEMS=(
"KEYMAP_INITRAMFS"
"LOCALES"
"LOCALE"
"SYSTEMD_NETWORKD"
"SYSTEMD_INITRAMFS_SSHD"
"SYSTEMD_NETWORKD_INTERFACE_NAME"
"SYSTEMD_NETWORKD_DHCP"
"SYSTEMD_NETWORKD_ADDRESSES"
"SYSTEMD_NETWORKD_GATEWAY"
"--------"
"STAGE3_VARIANT"
"PORTAGE_SYNC_TYPE"
@ -854,7 +895,8 @@ MENU_ITEMS=(
"SELECT_MIRRORS"
"SELECT_MIRRORS_LARGE_FILE"
"--------"
"INSTALL_SSHD"
"ENABLE_SSHD"
"ENABLE_BINPKG"
"ROOT_SSH_AUTHORIZED_KEYS"
"ADDITIONAL_PACKAGES"
)
@ -882,7 +924,8 @@ function PARTITIONING_SCHEME_menu() {
"existing_partitions") create_existing_partitions_layout boot=/dev/sdA swap=false type="$DEFAULT_BOOT_TYPE" /dev/sdX ;;
"zfs_centric") create_zfs_centric_layout swap=8GiB type="$DEFAULT_BOOT_TYPE" encrypt=true compress=zstd pool_type=standard /dev/sdX ;;
"btrfs_centric") create_btrfs_centric_layout swap=8GiB type="$DEFAULT_BOOT_TYPE" raid_type=raid0 luks=false /dev/sdX ;;
"raid0_luks") create_raid0_luks_layout swap=8GiB type="$DEFAULT_BOOT_TYPE" root_fs=ext4 /dev/sdX /dev/sdY ;;
"raid0_luks") create_raid0_luks_layout swap=8GiB type="$DEFAULT_BOOT_TYPE" luks=true root_fs=ext4 /dev/sdX /dev/sdY ;;
"raid1_luks") create_raid1_luks_layout swap=8GiB type="$DEFAULT_BOOT_TYPE" luks=true root_fs=ext4 /dev/sdX /dev/sdY ;;
"custom") PARTITIONING_SCHEME="$dialog_out" ;;
esac
UNSAVED_CHANGES=true
@ -899,7 +942,7 @@ function PARTITIONING_BOOT_TYPE_help() { echo "Select whether to use EFI or BIO
function PARTITIONING_BOOT_TYPE_menu() {
if menu_radiolist_labeled \
"Select boot type" \
"Select whether your want to use EFI or BIOS boot.$(on_off_str "$HAS_EFI_SUPPORT" "" " \Z1$EFI_UNSUPPORTED_MESSAGE\Zn")" \
"Select whether you want to use EFI or BIOS boot.$(on_off_str "$HAS_EFI_SUPPORT" "" " \Z1$EFI_UNSUPPORTED_MESSAGE\Zn")" \
"$PARTITIONING_BOOT_TYPE" \
"${PARTITIONING_BOOT_TYPES[@]}"
then
@ -954,7 +997,8 @@ function PARTITIONING_SWAP_menu() {
dialog \
--title "Select swap amount" \
--inputbox "Enter the amount of swap for the new system. Use the correct suffix (e.g. 16GiB, 1000MB)." \
"${INPUTBOX_SIZE[@]}" "$PARTITIONING_SWAP"
"${INPUTBOX_SIZE[@]}" "$PARTITIONING_SWAP" \
|| return 0
PARTITIONING_SWAP="$dialog_out"
UNSAVED_CHANGES=true
}
@ -989,7 +1033,7 @@ function PARTITIONING_SWAP_DEVICE_menu() {
function PARTITIONING_ROOT_FS_tag() { echo " ├ Root filesystem"; }
function PARTITIONING_ROOT_FS_label() { echo " ├ ($PARTITIONING_ROOT_FS)"; }
function PARTITIONING_ROOT_FS_show() { [[ $PARTITIONING_SCHEME != "custom" ]] && one_of "$PARTITIONING_SCHEME" "classic_single_disk" "raid0_luks"; }
function PARTITIONING_ROOT_FS_show() { [[ $PARTITIONING_SCHEME != "custom" ]] && one_of "$PARTITIONING_SCHEME" "classic_single_disk" "raid0_luks" "raid1_luks"; }
function PARTITIONING_ROOT_FS_help() { echo "Select the amount of swap to use."; }
function PARTITIONING_ROOT_FS_menu() {
if menu_radiolist \
@ -1129,7 +1173,7 @@ function PARTITIONING_DEVICES_label() {
if [[ "$invalid" -gt 0 ]]; then
echo " └ (${#PARTITIONING_DEVICES[@]} devices, \Z1$invalid invalid\Zn)"
elif [[ "${#PARTITIONING_DEVICES[@]}" -eq 1 && "$PARTITIONING_SCHEME" == "raid0_luks" ]]; then
elif [[ "${#PARTITIONING_DEVICES[@]}" -eq 1 && ("$PARTITIONING_SCHEME" == "raid0_luks" || "$PARTITIONING_SCHEME" == "raid1_luks") ]]; then
echo " └ (${#PARTITIONING_DEVICES[@]} devices, \Z1need at least 2\Zn)"
elif [[ "${#PARTITIONING_DEVICES[@]}" -eq 0 ]]; then
echo " └ (${#PARTITIONING_DEVICES[@]} devices, \Z1need at least 1\Zn)"
@ -1137,7 +1181,7 @@ function PARTITIONING_DEVICES_label() {
echo " └ (${#PARTITIONING_DEVICES[@]} devices)"
fi
}
function PARTITIONING_DEVICES_show() { [[ $PARTITIONING_SCHEME != "custom" ]] && one_of "$PARTITIONING_SCHEME" "raid0_luks" "zfs_centric" "btrfs_centric"; }
function PARTITIONING_DEVICES_show() { [[ $PARTITIONING_SCHEME != "custom" ]] && one_of "$PARTITIONING_SCHEME" "raid0_luks" "raid1_luks" "zfs_centric" "btrfs_centric"; }
function PARTITIONING_DEVICES_help() { echo "The block devices to which the layout will be applied."; }
function PARTITIONING_DEVICES_menu() {
local invalid=()
@ -1154,7 +1198,8 @@ function PARTITIONING_DEVICES_menu() {
dialog \
--title "Select devices" \
--inputbox "Enter the path of all devices which you want to partition, separated by space. (e.g. /dev/sda /dev/sdb).$invalid_line" \
"${INPUTBOX_SIZE[@]}" "${PARTITIONING_DEVICES[*]}"
"${INPUTBOX_SIZE[@]}" "${PARTITIONING_DEVICES[*]}" \
|| return 0
read -ra PARTITIONING_DEVICES <<< "$dialog_out"
UNSAVED_CHANGES=true
}
@ -1167,7 +1212,8 @@ function HOSTNAME_menu() {
dialog \
--title "Select hostname" \
--inputbox "Enter the hostname for your new system." \
"${INPUTBOX_SIZE[@]}" "$HOSTNAME"
"${INPUTBOX_SIZE[@]}" "$HOSTNAME" \
|| return 0
HOSTNAME="$dialog_out"
UNSAVED_CHANGES=true
}
@ -1243,7 +1289,7 @@ function KEYMAP_INITRAMFS_menu() {
function LOCALES_tag() { echo "Locales"; }
function LOCALES_label() { echo "$N_LOCALES selected"; }
function LOCALES_show() { return 0; }
function LOCALES_help() { echo "The locales to generate for the new system. Be careful that the syntax for locales is a different from the resulting name of the genereated locales of locale-gen. For example the locale 'en_US.utf8' is enabled via 'en_US.UTF-8 UTF-8')."; }
function LOCALES_help() { echo "The locales to generate for the new system. Be careful that the syntax for locales is a different from the resulting name of the generated locales of locale-gen. For example, the locale 'en_US.utf8' is enabled via 'en_US.UTF-8 UTF-8')."; }
function LOCALES_menu() {
if menu_splitlist "Select locales" "Select which locales to generate." "$SELECTED_LOCALES" "${SUPPORTED_LOCALES[@]}"; then
SELECTED_LOCALES="$dialog_out"
@ -1274,14 +1320,84 @@ function LOCALE_menu() {
fi
}
function SYSTEMD_NETWORKD_tag() { echo "Configure network"; }
function SYSTEMD_NETWORKD_label() { on_off_label "$SYSTEMD_NETWORKD"; }
function SYSTEMD_NETWORKD_show() { [[ $STAGE3_VARIANT == *systemd* ]]; }
function SYSTEMD_NETWORKD_help() { echo "Enable systemd-network to configure networking on the new system."; }
function SYSTEMD_NETWORKD_menu() {
on_off_toggle "SYSTEMD_NETWORKD"
UNSAVED_CHANGES=true
}
function SYSTEMD_INITRAMFS_SSHD_tag() { echo " ├ Enable sshd in initramfs"; }
function SYSTEMD_INITRAMFS_SSHD_label() { on_off_label "$SYSTEMD_INITRAMFS_SSHD" " ├ "; }
function SYSTEMD_INITRAMFS_SSHD_show() { [[ $STAGE3_VARIANT == *systemd* ]] && is_on "$SYSTEMD_NETWORKD"; }
function SYSTEMD_INITRAMFS_SSHD_help() { echo "Install and enable sshd in the initramfs. This can be used to unlock encrypted partitions / ZFS via ssh, or to get an emergency shell. Visit https://github.com/gsauthof/dracut-sshd for more information."; }
function SYSTEMD_INITRAMFS_SSHD_menu() {
on_off_toggle "SYSTEMD_INITRAMFS_SSHD"
UNSAVED_CHANGES=true
}
function SYSTEMD_NETWORKD_INTERFACE_NAME_tag() { echo " ├ Interface Name"; }
function SYSTEMD_NETWORKD_INTERFACE_NAME_label() { echo " ├ ($(ellipsis 20 "$SYSTEMD_NETWORKD_INTERFACE_NAME"))"; }
function SYSTEMD_NETWORKD_INTERFACE_NAME_show() { [[ $STAGE3_VARIANT == *systemd* ]] && is_on "$SYSTEMD_NETWORKD"; }
function SYSTEMD_NETWORKD_INTERFACE_NAME_help() { echo "The network interface(s) to configure. Defaults to all interfaces matching en*."; }
function SYSTEMD_NETWORKD_INTERFACE_NAME_menu() {
dialog \
--title "Network Interface Name" \
--inputbox "Enter the network interface name which should be configured. Can include wildcards." \
"${INPUTBOX_SIZE[@]}" "$SYSTEMD_NETWORKD_INTERFACE_NAME" \
|| return 0
SYSTEMD_NETWORKD_INTERFACE_NAME="$dialog_out"
UNSAVED_CHANGES=true
}
function SYSTEMD_NETWORKD_DHCP_tag() { echo " └ Static IP"; }
function SYSTEMD_NETWORKD_DHCP_label() { on_off_label_inverted "$SYSTEMD_NETWORKD_DHCP" " └ "; }
function SYSTEMD_NETWORKD_DHCP_show() { [[ $STAGE3_VARIANT == *systemd* ]] && is_on "$SYSTEMD_NETWORKD"; }
function SYSTEMD_NETWORKD_DHCP_help() { echo "Use DHCP to obtain network configuration."; }
function SYSTEMD_NETWORKD_DHCP_menu() {
on_off_toggle "SYSTEMD_NETWORKD_DHCP"
UNSAVED_CHANGES=true
}
function SYSTEMD_NETWORKD_ADDRESSES_tag() { echo " ├ Addresses"; }
function SYSTEMD_NETWORKD_ADDRESSES_label() { echo " ├ ($(ellipsis 20 "${SYSTEMD_NETWORKD_ADDRESSES[*]}"))"; }
function SYSTEMD_NETWORKD_ADDRESSES_show() { [[ $STAGE3_VARIANT == *systemd* ]] && is_on "$SYSTEMD_NETWORKD" && is_off "$SYSTEMD_NETWORKD_DHCP"; }
function SYSTEMD_NETWORKD_ADDRESSES_help() { echo "A space-separated list of addresses with CIDR mask to assign to the network interface."; }
function SYSTEMD_NETWORKD_ADDRESSES_menu() {
dialog \
--title "Network Addresses" \
--inputbox "A space-separated list of addresses with CIDR mask to assign to the network interface." \
"${INPUTBOX_SIZE[@]}" "${SYSTEMD_NETWORKD_ADDRESSES[*]}" \
|| return 0
# shellcheck disable=SC2206
SYSTEMD_NETWORKD_ADDRESSES=($dialog_out)
UNSAVED_CHANGES=true
}
function SYSTEMD_NETWORKD_GATEWAY_tag() { echo " └ Gateway"; }
function SYSTEMD_NETWORKD_GATEWAY_label() { echo " └ ($(ellipsis 20 "$SYSTEMD_NETWORKD_GATEWAY"))"; }
function SYSTEMD_NETWORKD_GATEWAY_show() { [[ $STAGE3_VARIANT == *systemd* ]] && is_on "$SYSTEMD_NETWORKD" && is_off "$SYSTEMD_NETWORKD_DHCP"; }
function SYSTEMD_NETWORKD_GATEWAY_help() { echo "The gateway address for the network."; }
function SYSTEMD_NETWORKD_GATEWAY_menu() {
dialog \
--title "Network Gateway" \
--inputbox "The gateway address for the network." \
"${INPUTBOX_SIZE[@]}" "$SYSTEMD_NETWORKD_GATEWAY" \
|| return 0
SYSTEMD_NETWORKD_GATEWAY="$dialog_out"
UNSAVED_CHANGES=true
}
function STAGE3_VARIANT_tag() { echo "Stage3 variant & Init system"; }
function STAGE3_VARIANT_label() { echo "($STAGE3_VARIANT)"; }
function STAGE3_VARIANT_show() { return 0; }
function STAGE3_VARIANT_help() { echo "Select which stage3 tarball to use. Implicitly determines whether systemd or OpenRC is used. Not all stage3 variants have been tested with this installer. The basic installation process is always the same, but due to complex profiles, unexpected blockers may arise when emerge is called. Stick to the basic choices and change after bootstraping, unless you know how to invervene while installing."; }
function STAGE3_VARIANT_help() { echo "Select which stage3 tarball to use. Implicitly determines whether systemd or OpenRC is used. Not all stage3 variants have been tested with this installer. The basic installation process is always the same, but due to complex profiles, unexpected blockers may arise when emerge is called. Stick to the basic choices and change after bootstrapping, unless you know how to intervene while installing."; }
function STAGE3_VARIANT_menu() {
if menu_radiolist_labeled \
"Select stage3 variant" \
"Select the base stage3 tarball variant to use for bootstrapping the system. Implicitly determines whether systemd or OpenRC is used. Not all stage3 variants have been tested with this installer. The basic installation process is always the same, but due to complex profiles, unexpected blockers may arise when emerge is called. Stick to the basic choices and change after bootstraping, unless you know how to invervene while installing." \
"Select the base stage3 tarball variant to use for bootstrapping the system. Implicitly determines whether systemd or OpenRC is used. Not all stage3 variants have been tested with this installer. The basic installation process is always the same, but due to complex profiles, unexpected blockers may arise when emerge is called. Stick to the basic choices and change after bootstrapping, unless you know how to intervene while installing." \
"$STAGE3_VARIANT" \
"${ALL_STAGE3_VARIANTS[@]}"
then
@ -1324,12 +1440,14 @@ function PORTAGE_GIT_FULL_HISTORY_menu() {
function PORTAGE_GIT_MIRROR_tag() { echo " └ Git mirror"; }
function PORTAGE_GIT_MIRROR_label() { echo " └ ($(ellipsis 20 "$PORTAGE_GIT_MIRROR"))"; }
function PORTAGE_GIT_MIRROR_show() { one_of "$PORTAGE_SYNC_TYPE" "git"; }
function PORTAGE_GIT_MIRROR_help() { echo "The portage git mirror is the git endpoint that is used to sync the portage tree."; }
function PORTAGE_GIT_MIRROR_help() { echo "The portage git mirror is the git endpoint that is used to sync the portage tree. You usually should not need to change this!"; }
function PORTAGE_GIT_MIRROR_menu() {
dialog \
--title "Select portage git mirror" \
--inputbox "Enter the portage git mirror that should be used to sync the portage tree." \
"${INPUTBOX_SIZE[@]}" "$PORTAGE_GIT_MIRROR"
"${INPUTBOX_SIZE[@]}" "$PORTAGE_GIT_MIRROR" \
|| return 0
PORTAGE_GIT_MIRROR="$dialog_out"
UNSAVED_CHANGES=true
}
@ -1340,8 +1458,10 @@ function GENTOO_MIRROR_help() { echo "Enter the initial gentoo mirror that shou
function GENTOO_MIRROR_menu() {
dialog \
--title "Select gentoo mirror" \
--inputbox "Enter the initial gentoo mirror that should be used for the installation process (until mirrorselect is run)." \
"${INPUTBOX_SIZE[@]}" "$GENTOO_MIRROR"
--inputbox "Enter the initial gentoo mirror that should be used for the system (or until mirrorselect is run). You need to enter the FULL PATH to the tree including relevant subdirectories. Leave this as it is if in doubt!" \
"${INPUTBOX_SIZE[@]}" "$GENTOO_MIRROR" \
|| return 0
GENTOO_MIRROR="$dialog_out"
UNSAVED_CHANGES=true
}
@ -1391,12 +1511,21 @@ function SELECT_MIRRORS_LARGE_FILE_menu() {
UNSAVED_CHANGES=true
}
function INSTALL_SSHD_tag() { echo "Install sshd"; }
function INSTALL_SSHD_label() { on_off_label "$INSTALL_SSHD"; }
function INSTALL_SSHD_show() { return 0; }
function INSTALL_SSHD_help() { echo "Install and enable sshd on the new system. A reasonably secure sshd configuration will be provided. It will by default only allow ed25519 keys, restrict key exchange algorithms to a reasonable subset, disable any password based authentication, and only allow root to login."; }
function INSTALL_SSHD_menu() {
on_off_toggle "INSTALL_SSHD"
function ENABLE_SSHD_tag() { echo "Enable sshd"; }
function ENABLE_SSHD_label() { on_off_label "$ENABLE_SSHD"; }
function ENABLE_SSHD_show() { return 0; }
function ENABLE_SSHD_help() { echo "Install and enable sshd on the new system. A reasonably secure sshd configuration will be provided. It will by default only allow ed25519 keys, restrict key exchange algorithms to a reasonable subset, disable any password based authentication, and only allow root to login."; }
function ENABLE_SSHD_menu() {
on_off_toggle "ENABLE_SSHD"
UNSAVED_CHANGES=true
}
function ENABLE_BINPKG_tag() { echo "Enable binary packages"; }
function ENABLE_BINPKG_label() { on_off_label "$ENABLE_BINPKG"; }
function ENABLE_BINPKG_show() { return 0; }
function ENABLE_BINPKG_help() { echo "Use binary packages if available."; }
function ENABLE_BINPKG_menu() {
on_off_toggle "ENABLE_BINPKG"
UNSAVED_CHANGES=true
}
@ -1474,6 +1603,13 @@ KEYMAP_INITRAMFS=${KEYMAP_INITRAMFS@Q}
LOCALES=${LOCALES@Q}
LOCALE=${LOCALE@Q}
SYSTEMD_NETWORKD=${SYSTEMD_NETWORKD@Q}
SYSTEMD_NETWORKD_INTERFACE_NAME=${SYSTEMD_NETWORKD_INTERFACE_NAME@Q}
SYSTEMD_NETWORKD_DHCP=${SYSTEMD_NETWORKD_DHCP@Q}
SYSTEMD_NETWORKD_ADDRESSES=${SYSTEMD_NETWORKD_ADDRESSES@Q}
SYSTEMD_NETWORKD_GATEWAY=${SYSTEMD_NETWORKD_GATEWAY@Q}
SYSTEMD_INITRAMFS_SSHD=${SYSTEMD_INITRAMFS_SSHD@Q}
################################################
# Gentoo configuration
@ -1489,13 +1625,15 @@ USE_PORTAGE_TESTING=${USE_PORTAGE_TESTING@Q}
SELECT_MIRRORS=${SELECT_MIRRORS@Q}
SELECT_MIRRORS_LARGE_FILE=${SELECT_MIRRORS_LARGE_FILE@Q}
SYSTEMD=\$([[ \$STAGE3_VARIANT == *systemd* ]] && echo "true" || echo "false")
MUSL=\$([[ \$STAGE3_VARIANT == *musl* ]] && echo "true" || echo "false")
################################################
# Additional (optional) configuration
ADDITIONAL_PACKAGES=(${ADDITIONAL_PACKAGES[@]@Q})
INSTALL_SSHD=${INSTALL_SSHD@Q}
ENABLE_SSHD=${ENABLE_SSHD@Q}
ENABLE_BINPKG=${ENABLE_BINPKG@Q}
ROOT_SSH_AUTHORIZED_KEYS=${ROOT_SSH_AUTHORIZED_KEYS@Q}

View File

@ -1,4 +1,3 @@
C.UTF-8 UTF-8
aa_DJ.UTF-8 UTF-8
aa_DJ ISO-8859-1
aa_ER UTF-8
@ -77,6 +76,7 @@ brx_IN UTF-8
bs_BA.UTF-8 UTF-8
bs_BA ISO-8859-2
byn_ER UTF-8
C.UTF-8 UTF-8
ca_AD.UTF-8 UTF-8
ca_AD ISO-8859-15
ca_ES.UTF-8 UTF-8

View File

@ -35,10 +35,10 @@ function disk_configuration() {
#
# Parameters:
# swap=<size> Create a swap partition with given size, or no swap
# at all if set to false
# at all if set to false.
# type=[efi|bios] Selects the boot type. Defaults to efi if not given.
# luks=[true|false] Encrypt root partition. Defaults to false if not given.
# root_fs=[ext4|btrfs] Root filesystem
# root_fs=[ext4|btrfs] Root filesystem. Defaults to ext4 if not given.
#create_classic_single_disk_layout swap=8GiB type=efi luks=true root_fs=ext4 /dev/sdX
# 2. create_btrfs_centric_layout
@ -52,7 +52,7 @@ function disk_configuration() {
#
# Parameters:
# swap=<size> Create a swap partition with given size, or no swap
# at all if set to false
# at all if set to false.
# type=[efi|bios] Selects the boot type. Defaults to efi if not given.
# encrypt=[true|false] Encrypt the zfs datasets. Defaults to false if not given.
# compress=[false|<compression>] Compress the zfs datasets. For valid values visit man zfsprops. Defaults to false if not given.
@ -68,13 +68,30 @@ function disk_configuration() {
#
# Parameters:
# swap=<size> Create a swap partition with given size for each disk,
# or no swap at all if set to false
# or no swap at all if set to false.
# type=[efi|bios] Selects the boot type. Defaults to efi if not given.
# root_fs=[ext4|btrfs] Root filesystem
# luks=[true|false] Encrypt root partition. Defaults to true if not given.
# root_fs=[ext4|btrfs] Root filesystem. Defaults to ext4 if not given.
# Careful: You will get N times the swap amount, so be sure to divide beforehand.
#create_raid0_luks_layout swap=4GiB type=efi root_fs=ext4 /dev/sd{X,Y}
# 4. create_btrfs_centric_layout
# 4. create_raid1_luks_layout
#
# This layout creates the single disk layout on multiple disks and combines
# the swap and root partitions in separate raid1 arrays. Useful if you e.g. have
# several nvme drives and want data redundancy. Only one boot partition will actually
# be used though.
#
# Parameters:
# swap=<size> Create a swap partition with given size for each disk,
# or no swap at all if set to false.
# type=[efi|bios] Selects the boot type. Defaults to efi if not given.
# luks=[true|false] Encrypt root partition. Defaults to true if not given.
# root_fs=[ext4|btrfs] Root filesystem. Defaults to ext4 if not given.
# Careful: You will get N times the swap amount, so be sure to divide beforehand.
#create_raid1_luks_layout swap=4GiB type=efi root_fs=ext4 /dev/sd{X,Y}
# 5. create_btrfs_centric_layout
#
# This layout is the same as the single_disk_layout, but uses btrfs as the root
# filesystem and allows you to put additional disks into the btrfs device pool.
@ -85,7 +102,7 @@ function disk_configuration() {
#
# Parameters:
# swap=<size> Create a swap partition with given size, or no swap
# at all if set to false
# at all if set to false.
# type=[efi|bios] Selects the boot type. Defaults to efi if not given.
# luks=[true|false] Encrypt root partition and btrfs devices. Defaults
# to false if not given.
@ -171,8 +188,7 @@ function disk_configuration() {
HOSTNAME="gentoo"
# The timezone for the new system
TIMEZONE="Europe/London"
#TIMEZONE="Europe/Berlin"
TIMEZONE="Atlantic/Azores"
# The default keymap for the system
KEYMAP="us"
@ -183,20 +199,43 @@ KEYMAP_INITRAMFS="$KEYMAP"
# A list of additional locales to generate. You should only
# add locales here if you really need them and want to localize
# your system. Otherwise, leave this list empty, and use "C.utf8" as the locale.
# your system. Otherwise, leave this list empty, and use "C.UTF-8" as the locale.
# Be careful that the syntax for locales is a bit different from the name of the resulting
# locale. For a list of supported locales, see the file /usr/share/i18n/SUPPORTED.
LOCALES=""
# The locale to set for the system. Be careful, the locale names deviate from the LOCALES
# list entries (e.g. .UTF-8 vs .utf8). See `locale -a` for all available locales.
LOCALE="C.utf8"
# For a german system you could use:
# Although `locale -a` lists the suffix in lower case without any hyphens, it is best to always use UTF-8 in preference to utf8.
LOCALE="C.UTF-8"
# For a PT system you could use:
# LOCALES="
# de_DE.UTF-8 UTF-8
# de_DE ISO-8859-1
# de_DE@euro ISO-8859-15
# pt_PT.UTF-8 UTF-8
# pt_PT ISO-8859-1
# pt_PT@euro ISO-8859-15
# " # End of LOCALES
# LOCALE="de_DE.utf8"
# LOCALE="pt_PT.UTF-8"
################################################
# Network configuration
# The following network configuration only applies to systemd
# configurations and will otherwise be ignored. All OpenRC based
# configurations always just starts dhcpcd.
# Enable systemd-networkd to configure internet
SYSTEMD_NETWORKD=true
# The interfaces to match and configure (systemd [Match] -> Name)
SYSTEMD_NETWORKD_INTERFACE_NAME="en*"
# Whether to use DHCP (systemd [Network] -> DHCP)
SYSTEMD_NETWORKD_DHCP=true
# If DHCP is disabled, assign the given list of addresses including CIDR mask. (systemd [Network] -> Address)
SYSTEMD_NETWORKD_ADDRESSES=("192.168.1.100/32" "fd00::1/64")
# If DHCP is disabled, use the given gateway
SYSTEMD_NETWORKD_GATEWAY="192.168.1.1"
# Enable sshd in initramfs to allow unlocking encrypted devices / enter emergency shell if needed.
# Requires systemd. Visit https://github.com/gsauthof/dracut-sshd for more information.
SYSTEMD_INITRAMFS_SSHD=false
################################################
@ -219,19 +258,21 @@ GENTOO_MIRROR="https://mirror.eu.oneandone.net/linux/distributions/gentoo/gentoo
GENTOO_ARCH="amd64"
# The stage3 tarball variant to use. Determines whether systemd
# or openrc is used based on whether "systemd" is contained in this string.
# or OpenRC is used based on whether "systemd" is contained in this string.
STAGE3_VARIANT="systemd"
# The stage3 tarball to download and bootstrap
STAGE3_BASENAME="stage3-$GENTOO_ARCH-$STAGE3_VARIANT"
# Automatically set to true, if the stage3 tarball is based on systemd. In this case
# we need to use slightly different utilities to setup the base system.
SYSTEMD=$([[ $STAGE3_VARIANT == *systemd* ]] && echo "true" || echo "false")
# Automatically set to true, if the stage3 tarball is based on musl.
MUSL=$([[ $STAGE3_VARIANT == *musl* ]] && echo "true" || echo "false")
# If set to true, the installer will add ACCEPT_KEYWORDS="~$GENTOO_ARCH"
# to /etc/portage/make.conf to enable packages in testing.
USE_PORTAGE_TESTING=true
# If set to true, the best best gentoo mirrors will be selected
# If set to true, the best gentoo mirrors will be selected
# automatically by app-portage/mirrorselect
SELECT_MIRRORS=true
@ -250,7 +291,10 @@ ADDITIONAL_PACKAGES=()
# Install and configure sshd (a reasonably secure config is provided, which
# only allows the use of ed25519 keys, and requires pubkey authentication)
INSTALL_SSHD=true
ENABLE_SSHD=true
# Enable binary portage packages where available
ENABLE_BINPKG=false
# An ssh key to add to the authorized_keys file for the root user.
# This variable will become the content of the authorized_keys file,
@ -264,3 +308,76 @@ ROOT_SSH_AUTHORIZED_KEYS=""
# To prove that you have read and edited the config
# properly, set the following value to true.
I_HAVE_READ_AND_EDITED_THE_CONFIG_PROPERLY=false
################################################
# Hooks
# before_prepare_environment() {
# einfo 'before prepare environment'
# }
# after_prepare_environment() {
# einfo 'after prepare environment'
# }
# before_disk_configuration() {
# einfo 'before disk configuration'
# }
# after_disk_configuration() {
# einfo 'after disk configuration'
# }
# before_download_stage3() {
# einfo "stage3 basename: $1"
# einfo 'before download stage3'
# }
# after_download_stage3() {
# einfo "stage3 downloaded file name: $1"
# einfo 'after download stage3'
# }
# before_extract_stage3() {
# einfo "stage3 downloaded file path: $1"
# einfo "root mountpoint: $1"
# einfo 'before extract stage3'
# }
# after_extract_stage3() {
# einfo "stage3 downloaded file path: $1"
# einfo "root mountpoint: $1"
# einfo 'after extract stage3'
# }
# before_install() {
# einfo 'before install'
# }
# after_install() {
# einfo 'after install'
# }
# before_configure_base_system() {
# einfo 'before configure base system'
# }
# after_configure_base_system() {
# einfo 'after configure base system'
# }
# before_configure_portage() {
# einfo 'before configure portage'
# }
# after_configure_portage() {
# einfo 'after configure portage'
# }
# before_install_kernel() {
# einfo 'before install kernel'
# }
# after_install_kernel() {
# einfo 'after install kernel'
# }

View File

@ -104,7 +104,8 @@ if [[ -z "$ACTION" ]]; then
# Default if configuration exists: Run installer
ACTION="install"
else
# Default if configuration does not exists: Run configurator, and exit afterwards.
# Default if configuration does not exist: Run configurator, and exit afterwards.
echo "You have not created a gentoo.conf. Starting configurator instead of installing."
exec "$GENTOO_INSTALL_REPO_DIR/configure" "$CONFIG"
fi
fi

View File

@ -293,10 +293,10 @@ function expand_ids() {
# Single disk, 3 partitions (efi, swap, root)
# Parameters:
# swap=<size> Create a swap partition with given size, or no swap at all if set to false
# swap=<size> Create a swap partition with given size, or no swap at all if set to false.
# type=[efi|bios] Selects the boot type. Defaults to efi if not given.
# luks=[true|false] Encrypt root partition. Defaults to false if not given.
# root_fs=[ext4|btrfs] Root filesystem
# root_fs=[ext4|btrfs] Root filesystem. Defaults to ext4 if not given.
function create_classic_single_disk_layout() {
local known_arguments=('+swap' '?type' '?luks' '?root_fs')
local extra_arguments=()
@ -311,7 +311,7 @@ function create_classic_single_disk_layout() {
local root_fs="${arguments[root_fs]:-ext4}"
create_gpt new_id=gpt device="$device"
create_partition new_id="part_$type" id=gpt size=512MiB type="$type"
create_partition new_id="part_$type" id=gpt size=1GiB type="$type"
[[ $size_swap != "false" ]] \
&& create_partition new_id=part_swap id=gpt size="$size_swap" type=swap
create_partition new_id=part_root id=gpt size=remaining type=linux
@ -353,7 +353,7 @@ function create_single_disk_layout() {
# Skip partitioning, and use existing pre-formatted partitions. These must be trivially mountable.
# Parameters:
# swap=<device|false> Use the given device as swap, or no swap at all if set to false
# swap=<device|false> Use the given device as swap, or no swap at all if set to false.
# boot=<device> Use the given device as the bios/efi partition.
# type=[efi|bios] Selects the boot type. Defaults to efi if not given.
function create_existing_partitions_layout() {
@ -389,7 +389,7 @@ function create_existing_partitions_layout() {
# Multiple disks, up to 3 partitions on first disk (efi, optional swap, root with zfs).
# Additional devices will be added to the zfs pool.
# Parameters:
# swap=<size> Create a swap partition with given size, or no swap at all if set to false
# swap=<size> Create a swap partition with given size, or no swap at all if set to false.
# type=[efi|bios] Selects the boot type. Defaults to efi if not given.
# encrypt=[true|false] Encrypt zfs pool. Defaults to false if not given.
# pool_type=[stripe|mirror] Select raid type. Defaults to stripe.
@ -408,7 +408,7 @@ function create_zfs_centric_layout() {
# Create layout on first disk
create_gpt new_id="gpt_dev0" device="${extra_arguments[0]}"
create_partition new_id="part_${type}_dev0" id="gpt_dev0" size=512MiB type="$type"
create_partition new_id="part_${type}_dev0" id="gpt_dev0" size=1GiB type="$type"
[[ $size_swap != "false" ]] \
&& create_partition new_id="part_swap_dev0" id="gpt_dev0" size="$size_swap" type=swap
create_partition new_id="part_root_dev0" id="gpt_dev0" size=remaining type=linux
@ -444,11 +444,12 @@ function create_zfs_centric_layout() {
# - swap: raid 0 → fs
# - root: raid 0 → luks → fs
# Parameters:
# swap=<size> Create a swap partition with given size for each disk, or no swap at all if set to false
# swap=<size> Create a swap partition with given size for each disk, or no swap at all if set to false.
# type=[efi|bios] Selects the boot type. Defaults to efi if not given.
# root_fs=[ext4|btrfs] Root filesystem
# luks=[true|false] Encrypt root partition. Defaults to true if not given.
# root_fs=[ext4|btrfs] Root filesystem. Defaults to ext4 if not given.
function create_raid0_luks_layout() {
local known_arguments=('+swap' '?type' '?root_fs')
local known_arguments=('+swap' '?type' '?luks' '?root_fs')
local extra_arguments=()
declare -A arguments; parse_arguments "$@"
@ -456,11 +457,12 @@ function create_raid0_luks_layout() {
|| die_trace 1 "Expected at least one positional argument (the devices)"
local size_swap="${arguments[swap]}"
local type="${arguments[type]:-efi}"
local use_luks="${arguments[luks]:-true}"
local root_fs="${arguments[root_fs]:-ext4}"
for i in "${!extra_arguments[@]}"; do
create_gpt new_id="gpt_dev${i}" device="${extra_arguments[$i]}"
create_partition new_id="part_${type}_dev${i}" id="gpt_dev${i}" size=512MiB type="$type"
create_partition new_id="part_${type}_dev${i}" id="gpt_dev${i}" size=1GiB type="$type"
[[ $size_swap != "false" ]] \
&& create_partition new_id="part_swap_dev${i}" id="gpt_dev${i}" size="$size_swap" type=raid
create_partition new_id="part_root_dev${i}" id="gpt_dev${i}" size=remaining type=raid
@ -469,12 +471,17 @@ function create_raid0_luks_layout() {
[[ $size_swap != "false" ]] \
&& create_raid new_id=part_raid_swap name="swap" level=0 ids="$(expand_ids '^part_swap_dev[[:digit:]]$')"
create_raid new_id=part_raid_root name="root" level=0 ids="$(expand_ids '^part_root_dev[[:digit:]]$')"
create_luks new_id=part_luks_root name="root" id=part_raid_root
local root_id="part_raid_root"
if [[ "$use_luks" == "true" ]]; then
create_luks new_id=part_luks_root name="root" id=part_raid_root
root_id="part_luks_root"
fi
format id="part_${type}_dev0" type="$type" label="$type"
[[ $size_swap != "false" ]] \
&& format id=part_raid_swap type=swap label=swap
format id=part_luks_root type="$root_fs" label=root
format id="$root_id" type="$root_fs" label=root
if [[ $type == "efi" ]]; then
DISK_ID_EFI="part_${type}_dev0"
@ -483,12 +490,76 @@ function create_raid0_luks_layout() {
fi
[[ $size_swap != "false" ]] \
&& DISK_ID_SWAP=part_raid_swap
DISK_ID_ROOT=part_luks_root
DISK_ID_ROOT="$root_id"
if [[ $root_fs == "btrfs" ]]; then
DISK_ID_ROOT_TYPE="btrfs"
DISK_ID_ROOT_MOUNT_OPTS="defaults,noatime,compress=zstd,subvol=/root"
elif [[ $root_fs == "btrfs" ]]; then
elif [[ $root_fs == "ext4" ]]; then
DISK_ID_ROOT_TYPE="ext4"
DISK_ID_ROOT_MOUNT_OPTS="defaults,noatime,errors=remount-ro,discard"
else
die "Unsupported root filesystem type"
fi
}
# Multiple disks, with raid 1 and luks
# - efi: partition on all disks, but only first disk used
# - swap: raid 1 → fs
# - root: raid 1 → luks → fs
# Parameters:
# swap=<size> Create a swap partition with given size for each disk, or no swap at all if set to false.
# type=[efi|bios] Selects the boot type. Defaults to efi if not given.
# luks=[true|false] Encrypt root partition. Defaults to true if not given.
# root_fs=[ext4|btrfs] Root filesystem. Defaults to ext4 if not given.
function create_raid1_luks_layout() {
local known_arguments=('+swap' '?type' '?luks' '?root_fs')
local extra_arguments=()
declare -A arguments; parse_arguments "$@"
[[ ${#extra_arguments[@]} -gt 0 ]] \
|| die_trace 1 "Expected at least one positional argument (the devices)"
local size_swap="${arguments[swap]}"
local type="${arguments[type]:-efi}"
local use_luks="${arguments[luks]:-true}"
local root_fs="${arguments[root_fs]:-ext4}"
for i in "${!extra_arguments[@]}"; do
create_gpt new_id="gpt_dev${i}" device="${extra_arguments[$i]}"
create_partition new_id="part_${type}_dev${i}" id="gpt_dev${i}" size=1GiB type="$type"
[[ $size_swap != "false" ]] \
&& create_partition new_id="part_swap_dev${i}" id="gpt_dev${i}" size="$size_swap" type=raid
create_partition new_id="part_root_dev${i}" id="gpt_dev${i}" size=remaining type=raid
done
[[ $size_swap != "false" ]] \
&& create_raid new_id=part_raid_swap name="swap" level=1 ids="$(expand_ids '^part_swap_dev[[:digit:]]$')"
create_raid new_id=part_raid_root name="root" level=1 ids="$(expand_ids '^part_root_dev[[:digit:]]$')"
local root_id="part_raid_root"
if [[ "$use_luks" == "true" ]]; then
create_luks new_id=part_luks_root name="root" id=part_raid_root
root_id="part_luks_root"
fi
format id="part_${type}_dev0" type="$type" label="$type"
[[ $size_swap != "false" ]] \
&& format id=part_raid_swap type=swap label=swap
format id="$root_id" type="$root_fs" label=root
if [[ $type == "efi" ]]; then
DISK_ID_EFI="part_${type}_dev0"
else
DISK_ID_BIOS="part_${type}_dev0"
fi
[[ $size_swap != "false" ]] \
&& DISK_ID_SWAP=part_raid_swap
DISK_ID_ROOT="$root_id"
if [[ $root_fs == "btrfs" ]]; then
DISK_ID_ROOT_TYPE="btrfs"
DISK_ID_ROOT_MOUNT_OPTS="defaults,noatime,compress=zstd,subvol=/root"
elif [[ $root_fs == "ext4" ]]; then
DISK_ID_ROOT_TYPE="ext4"
DISK_ID_ROOT_MOUNT_OPTS="defaults,noatime,errors=remount-ro,discard"
else
@ -499,7 +570,7 @@ function create_raid0_luks_layout() {
# Multiple disks, up to 3 partitions on first disk (efi, optional swap, root with btrfs).
# Additional devices will be first encrypted and then put directly into btrfs array.
# Parameters:
# swap=<size> Create a swap partition with given size, or no swap at all if set to false
# swap=<size> Create a swap partition with given size, or no swap at all if set to false.
# type=[efi|bios] Selects the boot type. Defaults to efi if not given.
# luks=[true|false] Encrypt root partition and btrfs devices. Defaults to false if not given.
# raid_type=[raid0|raid1] Select raid type. Defaults to raid0.
@ -518,7 +589,7 @@ function create_btrfs_centric_layout() {
# Create layout on first disk
create_gpt new_id="gpt_dev0" device="${extra_arguments[0]}"
create_partition new_id="part_${type}_dev0" id="gpt_dev0" size=512MiB type="$type"
create_partition new_id="part_${type}_dev0" id="gpt_dev0" size=1GiB type="$type"
[[ $size_swap != "false" ]] \
&& create_partition new_id="part_swap_dev0" id="gpt_dev0" size="$size_swap" type=swap
create_partition new_id="part_root_dev0" id="gpt_dev0" size=remaining type=linux

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() {
@ -239,6 +243,18 @@ function disk_create_partition() {
sgdisk -n "0:0:$arg_size" -t "0:$type" -u "0:$partuuid" $extra_args "$device" >/dev/null \
|| die "Could not create new gpt partition ($new_id) on '$device' ($id)"
partprobe "$device"
# On some system, we need to wait a bit for the partition to show up.
local new_device
new_device="$(resolve_device_by_id "$new_id")" \
|| die "Could not resolve new device with id=$new_id"
for i in {1..10}; do
[[ -e "$new_device" ]] && break
[[ "$i" -eq 1 ]] && printf "Waiting for partition (%s) to appear..." "$new_device"
printf " %s" "$((10 - i + 1))"
sleep 1
[[ "$i" -eq 10 ]] && echo
done
}
function disk_create_raid() {
@ -275,12 +291,19 @@ function disk_create_raid() {
local mddevice="/dev/md/$name"
local uuid="${DISK_ID_TO_UUID[$new_id]}"
extra_args=()
if [[ ${level} == 1 ]]; then
extra_args+=("--metadata=1.0")
else
extra_args+=("--metadata=1.2")
fi
einfo "Creating raid$level ($new_id) on $devices_desc"
mdadm \
--create "$mddevice" \
--verbose \
--homehost="$HOSTNAME" \
--metadata=1.2 \
"${extra_args[@]}" \
--raid-devices="${#devices[@]}" \
--uuid="$uuid" \
--level="$level" \
@ -399,6 +422,9 @@ function disk_format() {
mkswap "$device" \
|| die "Could not format device '$device' ($id)"
fi
# Try to swapoff in case the system enabled swap automatically
swapoff "$device" &>/dev/null
;;
'ext4')
if [[ -v "arguments[label]" ]]; then
@ -439,12 +465,6 @@ function format_zfs_standard() {
einfo "Creating zfs pool on $devices_desc"
if [[ "$compress" != false ]]; then
extra_args+=(
"-O" "compression=$compress"
)
fi
local zfs_stdin=""
if [[ "$encrypt" == true ]]; then
extra_args+=(
@ -473,6 +493,10 @@ function format_zfs_standard() {
<<< "$zfs_stdin" \
|| die "Could not create zfs pool on $devices_desc"
if [[ "$compress" != false ]]; then
zfs set "compression=$compress" rpool \
|| die "Could enable compression on dataset 'rpool'"
fi
zfs create rpool/ROOT \
|| die "Could not create zfs dataset 'rpool/ROOT'"
zfs create -o mountpoint=/ rpool/ROOT/default \
@ -722,6 +746,8 @@ function apply_disk_configuration() {
|| die "Aborted"
countdown "Applying in " 5
maybe_exec 'before_disk_configuration'
einfo "Applying disk configuration"
apply_disk_actions
@ -729,6 +755,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() {
@ -790,7 +818,7 @@ function download_stage3() {
cd "$TMP_DIR" \
|| die "Could not cd into '$TMP_DIR'"
local STAGE3_RELEASES="$GENTOO_MIRROR/releases/amd64/autobuilds/current-$STAGE3_BASENAME/"
local STAGE3_RELEASES="$GENTOO_MIRROR/releases/$GENTOO_ARCH/autobuilds/current-$STAGE3_BASENAME/"
# Download upstream list of files
CURRENT_STAGE3="$(download_stdout "$STAGE3_RELEASES")" \
@ -806,6 +834,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"
@ -842,6 +872,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() {
@ -852,6 +884,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'"
@ -866,6 +900,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() {
@ -928,7 +964,12 @@ function gentoo_chroot() {
einfo "Mounting virtual filesystems"
(
mountpoint -q -- "$chroot_dir/proc" || mount -t proc /proc "$chroot_dir/proc" || exit 1
mountpoint -q -- "$chroot_dir/tmp" || mount --rbind /tmp "$chroot_dir/tmp" || exit 1
mountpoint -q -- "$chroot_dir/run" || {
mount --rbind /run "$chroot_dir/run" &&
mount --make-rslave "$chroot_dir/run"; } || exit 1
mountpoint -q -- "$chroot_dir/tmp" || {
mount --rbind /tmp "$chroot_dir/tmp" &&
mount --make-rslave "$chroot_dir/tmp"; } || exit 1
mountpoint -q -- "$chroot_dir/sys" || {
mount --rbind /sys "$chroot_dir/sys" &&
mount --make-rslave "$chroot_dir/sys"; } || exit 1
@ -951,10 +992,8 @@ function gentoo_chroot() {
function enable_service() {
if [[ $SYSTEMD == "true" ]]; then
systemctl enable "$1" \
|| die "Could not enable $1 service"
try systemctl enable "$1"
else
rc-update add "$1" default \
|| die "Could not add $1 to default services"
try rc-update add "$1" default
fi
}

View File

@ -13,11 +13,19 @@ function install_stage3() {
}
function configure_base_system() {
einfo "Generating locales"
echo "$LOCALES" > /etc/locale.gen \
|| die "Could not write /etc/locale.gen"
locale-gen \
|| die "Could not generate locales"
if [[ $MUSL == "true" ]]; then
einfo "Installing musl-locales"
if [[ $USE_PORTAGE_TESTING == "false" ]]; then
echo "sys-apps/musl-locales" >> /etc/portage/package.accept_keywords/musl-locales
fi
try emerge --verbose sys-apps/musl-locales
else
einfo "Generating locales"
echo "$LOCALES" > /etc/locale.gen \
|| die "Could not write /etc/locale.gen"
locale-gen \
|| die "Could not generate locales"
fi
if [[ $SYSTEMD == "true" ]]; then
einfo "Setting machine-id"
@ -49,10 +57,19 @@ function configure_base_system() {
|| die "Could not sed replace in /etc/conf.d/hostname"
# Set timezone
einfo "Selecting timezone"
echo "$TIMEZONE" > /etc/timezone \
|| die "Could not write /etc/timezone"
try emerge -v --config sys-libs/timezone-data
if [[ $MUSL == "true" ]]; then
try emerge -v sys-libs/timezone-data
einfo "Selecting timezone"
echo -e "\nTZ=\"$TIMEZONE\"" >> /etc/env.d/00musl \
|| die "Could not write to /etc/env.d/00musl"
else
einfo "Selecting timezone"
echo "$TIMEZONE" > /etc/timezone \
|| die "Could not write /etc/timezone"
chmod 644 /etc/timezone \
|| die "Could not set correct permissions for /etc/timezone"
try emerge -v --config sys-libs/timezone-data
fi
# Set keymap
einfo "Selecting keymap"
@ -74,6 +91,7 @@ function configure_portage() {
touch_or_die 0644 "/etc/portage/package.use/zz-autounmask"
mkdir_or_die 0755 "/etc/portage/package.keywords"
touch_or_die 0644 "/etc/portage/package.keywords/zz-autounmask"
touch_or_die 0644 "/etc/portage/package.license"
if [[ $SELECT_MIRRORS == "true" ]]; then
einfo "Temporarily installing mirrorselect"
@ -86,22 +104,24 @@ function configure_portage() {
try mirrorselect "${mirrorselect_params[@]}"
fi
if [[ $USE_PORTAGE_TESTING == "true" ]]; then
einfo "Adding ~$GENTOO_ARCH to ACCEPT_KEYWORDS"
echo "ACCEPT_KEYWORDS=\"~$GENTOO_ARCH\"" >> /etc/portage/make.conf \
|| die "Could not modify /etc/portage/make.conf"
if [[ $ENABLE_BINPKG == "true" ]]; then
echo 'FEATURES="getbinpkg"' >> /etc/portage/make.conf
getuto
chmod 644 /etc/portage/gnupg/pubring.kbx
fi
chmod 644 /etc/portage/make.conf \
|| die "Could not chmod 644 /etc/portage/make.conf"
}
function install_sshd() {
einfo "Installing sshd"
function enable_sshd() {
einfo "Installing and enabling sshd"
install -m0600 -o root -g root "$GENTOO_INSTALL_REPO_DIR/contrib/sshd_config" /etc/ssh/sshd_config \
|| die "Could not install /etc/ssh/sshd_config"
enable_service sshd
}
function install_authorized_keys() {
mkdir_or_die 0700 "/root/"
mkdir_or_die 0700 "/root/.ssh"
@ -134,25 +154,37 @@ function generate_initramfs() {
|| die "Could not figure out kernel version from /usr/src/linux symlink."
kver="${kver#linux-}"
dracut_opts=()
if [[ $SYSTEMD == "true" && $SYSTEMD_INITRAMFS_SSHD == "true" ]]; then
cd /tmp || die "Could not change into /tmp"
try git clone https://github.com/gsauthof/dracut-sshd
try cp -r dracut-sshd/46sshd /usr/lib/dracut/modules.d
sed -e 's/^Type=notify/Type=simple/' \
-e 's@^\(ExecStart=/usr/sbin/sshd\) -D@\1 -e -D@' \
-i /usr/lib/dracut/modules.d/46sshd/sshd.service \
|| die "Could not replace sshd options in service file"
dracut_opts+=("--install" "/etc/systemd/network/20-wired.network")
modules+=("systemd-networkd")
fi
# Generate initramfs
# TODO --conf "/dev/null" \
# TODO --confdir "/dev/null" \
# TODO --conf "/dev/null" \
# TODO --confdir "/dev/null" \
try dracut \
--kver "$kver" \
--zstd \
--no-hostonly \
--ro-mnt \
--add "bash ${modules[*]}" \
"${dracut_opts[@]}" \
--force \
"$output"
# TODO --conf "/dev/null" \\
# TODO --confdir "/dev/null" \\
# Create script to repeat initramfs generation
cat > "$(dirname "$output")/generate_initramfs.sh" <<EOF
#!/bin/bash
kver="\$1"
output="\$2"
output="\$2" # At setup time, this was "$output"
[[ -n "\$kver" ]] || { echo "usage \$0 <kernel_version> <output>" >&2; exit 1; }
dracut \\
--kver "\$kver" \\
@ -160,8 +192,9 @@ dracut \\
--no-hostonly \\
--ro-mnt \\
--add "bash ${modules[*]}" \\
${dracut_opts[@]@Q} \\
--force \\
"$output"
"\$output"
EOF
}
@ -181,11 +214,10 @@ function install_kernel_efi() {
# Copy kernel to EFI
local kernel_file
kernel_file="$(find "/boot" -name "vmlinuz-*" -printf '%f\n' | sort -V | tail -n 1)" \
kernel_file="$(find "/boot" \( -name "vmlinuz-*" -or -name 'kernel-*' \) -printf '%f\n' | sort -V | tail -n 1)" \
|| die "Could not list newest kernel file"
cp "/boot/$kernel_file" "/boot/efi/vmlinuz.efi" \
|| die "Could not copy kernel to EFI partition"
try cp "/boot/$kernel_file" "/boot/efi/vmlinuz.efi"
# Generate initramfs
generate_initramfs "/boot/efi/initramfs.img"
@ -197,15 +229,26 @@ function install_kernel_efi() {
|| die "Could not resolve device with id=$DISK_ID_EFI"
efipartdev="$(realpath "$efipartdev")" \
|| die "Error in realpath '$efipartdev'"
local efipartnum="${efipartdev: -1}"
local sys_efipart
sys_efipart="/sys/class/block/$(basename "$efipartdev")" \
|| die "Could not construct /sys path to efi partition"
local efipartnum
efipartnum="$(cat "$sys_efipart/partition")" \
|| die "Failed to find partition number for EFI partition $efipartdev"
local gptdev
gptdev="$(resolve_device_by_id "${DISK_ID_PART_TO_GPT_ID[$DISK_ID_EFI]}")" \
|| die "Could not resolve device with id=${DISK_ID_PART_TO_GPT_ID[$DISK_ID_EFI]}"
gptdev="/dev/$(basename "$(readlink -f "$sys_efipart/..")")" \
|| die "Failed to find parent device for EFI partition $efipartdev"
if [[ ! -e "$gptdev" ]] || [[ -z "$gptdev" ]]; then
gptdev="$(resolve_device_by_id "${DISK_ID_PART_TO_GPT_ID[$DISK_ID_EFI]}")" \
|| die "Could not resolve device with id=${DISK_ID_PART_TO_GPT_ID[$DISK_ID_EFI]}"
fi
try efibootmgr --verbose --create --disk "$gptdev" --part "$efipartnum" --label "gentoo" --loader '\vmlinuz.efi' --unicode 'initrd=\initramfs.img'" $(get_cmdline)"
# Create script to repeat adding efibootmgr entry
cat > "/boot/efi/efibootmgr_add_entry.sh" <<EOF
#!/bin/bash
# This is the command that was used to create the efibootmgr entry when the
# system was installed using gentoo-install.
efibootmgr --verbose --create --disk "$gptdev" --part "$efipartnum" --label "gentoo" --loader '\\vmlinuz.efi' --unicode 'initrd=\\initramfs.img'" $(get_cmdline)"
EOF
}
@ -227,11 +270,10 @@ function install_kernel_bios() {
# Link kernel to known name
local kernel_file
kernel_file="$(find "/boot" -name "vmlinuz-*" -printf '%f\n' | sort -V | tail -n 1)" \
kernel_file="$(find "/boot" \( -name "vmlinuz-*" -or -name 'kernel-*' \) -printf '%f\n' | sort -V | tail -n 1)" \
|| die "Could not list newest kernel file"
cp "/boot/$kernel_file" "/boot/bios/vmlinuz-current" \
|| die "Could copy kernel to /boot/bios/vmlinuz-current"
try cp "/boot/$kernel_file" "/boot/bios/vmlinuz-current"
# Generate initramfs
generate_initramfs "/boot/bios/initramfs.img"
@ -259,13 +301,17 @@ function install_kernel_bios() {
function install_kernel() {
# Install vanilla kernel
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
install_kernel_efi
else
install_kernel_bios
fi
einfo "Installing linux-firmware"
echo "sys-kernel/linux-firmware linux-fw-redistributable no-source-code" >> /etc/portage/package.license \
|| die "Could not write to /etc/portage/package.license"
try emerge --verbose linux-firmware
}
function add_fstab_entry() {
@ -293,6 +339,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"
@ -315,9 +363,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)
@ -345,6 +396,21 @@ 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
# Install authorized_keys before dracut, which might need them for remote unlocking.
install_authorized_keys
einfo "Enabling dracut USE flag on sys-kernel/installkernel"
echo "sys-kernel/installkernel dracut" > /etc/portage/package.use/installkernel \
|| die "Could not write /etc/portage/package.use/installkernel"
# Install required programs and kernel now, in order 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)
if [[ $USED_RAID == "true" ]]; then
@ -358,12 +424,22 @@ EOF
try emerge --verbose sys-fs/cryptsetup
fi
if [[ $SYSTEMD == "true" && $USED_LUKS == "true" ]] ; then
einfo "Enabling cryptsetup USE flag on sys-apps/systemd"
echo "sys-apps/systemd cryptsetup" > /etc/portage/package.use/systemd \
|| die "Could not write /etc/portage/package.use/systemd"
einfo "Rebuilding systemd with changed USE flag"
try emerge --verbose --changed-use --oneshot sys-apps/systemd
fi
# Install btrfs-progs if we used btrfs
if [[ $USED_BTRFS == "true" ]]; then
einfo "Installing btrfs-progs"
try emerge --verbose sys-fs/btrfs-progs
fi
try emerge --verbose dev-vcs/git
# Install zfs kernel module and tools if we used zfs
if [[ $USED_ZFS == "true" ]]; then
einfo "Installing zfs"
@ -371,18 +447,20 @@ EOF
einfo "Enabling zfs services"
if [[ $SYSTEMD == "true" ]]; then
systemctl enable zfs.target || die "Could not enable zfs.target service"
systemctl enable zfs-import-cache || die "Could not enable zfs-import-cache service"
systemctl enable zfs-mount || die "Could not enable zfs-mount service"
systemctl enable zfs-import.target || die "Could not enable zfs-import.target service"
try systemctl enable zfs.target
try systemctl enable zfs-import-cache
try systemctl enable zfs-mount
try systemctl enable zfs-import.target
else
rc-update add zfs-import boot || die "Could not add zfs-import to boot services"
rc-update add zfs-mount boot || die "Could not add zfs-mount to boot services"
try rc-update add zfs-import boot
try rc-update add zfs-mount boot
fi
fi
# Install kernel and initramfs
maybe_exec 'before_install_kernel'
install_kernel
maybe_exec 'after_install_kernel'
# Generate a valid fstab file
generate_fstab
@ -391,21 +469,27 @@ EOF
einfo "Installing gentoolkit"
try emerge --verbose app-portage/gentoolkit
# Install and enable sshd
if [[ $INSTALL_SSHD == "true" ]]; then
install_sshd
fi
if [[ $SYSTEMD == "true" ]]; then
# Enable systemd networking and dhcp
enable_service systemd-networkd
enable_service systemd-resolved
echo -en "[Match]\nName=en*\n\n[Network]\nDHCP=yes" > /etc/systemd/network/20-wired-dhcp.network \
|| die "Could not write dhcp network config to '/etc/systemd/network/20-wired-dhcp.network'"
chown root:systemd-network /etc/systemd/network/20-wired-dhcp.network \
|| die "Could not change owner of '/etc/systemd/network/20-wired-dhcp.network'"
chmod 640 /etc/systemd/network/20-wired-dhcp.network \
|| die "Could not change permissions of '/etc/systemd/network/20-wired-dhcp.network'"
if [[ $SYSTEMD_NETWORKD == "true" ]]; then
# Enable systemd networking and dhcp
enable_service systemd-networkd
enable_service systemd-resolved
if [[ $SYSTEMD_NETWORKD_DHCP == "true" ]]; then
echo -en "[Match]\nName=${SYSTEMD_NETWORKD_INTERFACE_NAME}\n\n[Network]\nDHCP=yes" > /etc/systemd/network/20-wired.network \
|| die "Could not write dhcp network config to '/etc/systemd/network/20-wired.network'"
else
addresses=""
for addr in "${SYSTEMD_NETWORKD_ADDRESSES[@]}"; do
addresses="${addresses}Address=$addr\n"
done
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'"
fi
chown root:systemd-network /etc/systemd/network/20-wired.network \
|| die "Could not change owner of '/etc/systemd/network/20-wired.network'"
chmod 640 /etc/systemd/network/20-wired.network \
|| die "Could not change permissions of '/etc/systemd/network/20-wired.network'"
fi
else
# Install and enable dhcpcd
einfo "Installing dhcpcd"
@ -414,6 +498,10 @@ EOF
enable_service dhcpcd
fi
if [[ $ENABLE_SSHD == "true" ]]; then
enable_sshd
fi
# Install additional packages, if any.
if [[ ${#ADDITIONAL_PACKAGES[@]} -gt 0 ]]; then
einfo "Installing additional packages"
@ -429,10 +517,22 @@ EOF
ewarn "Root password cleared, set one as soon as possible!"
fi
# If configured, change to gentoo testing at the last moment.
# This is to ensure a smooth installation process. You can deal
# with the blockers after installation ;)
if [[ $USE_PORTAGE_TESTING == "true" ]]; then
einfo "Adding ~$GENTOO_ARCH to ACCEPT_KEYWORDS"
echo "ACCEPT_KEYWORDS=\"~$GENTOO_ARCH\"" >> /etc/portage/make.conf \
|| 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."
einfo "You may now reboot your system."
einfo "You may now reboot your system or execute ./install --chroot $ROOT_MOUNTPOINT to enter your system in a chroot."
einfo "Chrooting in this way is always possible in case you need to fix something after rebooting."
}
function main_install() {

View File

@ -377,7 +377,9 @@ function check_wanted_programs() {
local checkfile
for tuple in "$@"; do
program="${tuple%%=*}"
checkfile="${tuple##*=}"
checkfile=""
[[ "$tuple" == *=* ]] \
&& checkfile="${tuple##*=}"
if ! has_program "${program#"?"}" "$checkfile"; then
if [[ "$program" == "?"* ]]; then
missing_wanted+=("${program#"?"}")
@ -415,8 +417,8 @@ function check_wanted_programs() {
&& need_zfs=true
if [[ -v "pacman_packages[$program]" ]]; then
# Assignments to the empty string are explcitly ignored,
# as for example zfs needs to be handeled separately.
# Assignments to the empty string are explicitly ignored,
# as for example, zfs needs to be handled separately.
[[ -n "${pacman_packages[$program]}" ]] \
&& packages+=("${pacman_packages[$program]}")
else
@ -427,9 +429,9 @@ function check_wanted_programs() {
if [[ "$need_zfs" == true ]]; then
elog "On an Arch live-stick you need the archzfs repository and some tools and modifications to use zfs."
elog "There is an automated installer available at https://eoli3n.github.io/archzfs/init."
elog "There is an automated installer available at https://raw.githubusercontent.com/eoli3n/archiso-zfs/master/init."
if ask "Do you want to automatically download and execute this zfs installation script?"; then
curl -s "https://eoli3n.github.io/archzfs/init" | bash
curl -s "https://raw.githubusercontent.com/eoli3n/archiso-zfs/master/init" | bash
fi
fi
@ -443,3 +445,9 @@ function check_wanted_programs() {
ask "Continue without recommended programs?"
fi
}
# exec function if defined
# $@ function name and arguments
function maybe_exec() {
type "$1" &>/dev/null && "$@"
}