diff --git a/scripts/config.sh b/scripts/config.sh index df6be2c..404774f 100644 --- a/scripts/config.sh +++ b/scripts/config.sh @@ -111,8 +111,6 @@ SYSTEMD=true # Array of additional packages to install ADDITIONAL_PACKAGES=("app-editors/neovim") -# Install and enable dhcpcd -INSTALL_DHCPCD=true # 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 diff --git a/scripts/functions.sh b/scripts/functions.sh index 348bf4c..d16361d 100644 --- a/scripts/functions.sh +++ b/scripts/functions.sh @@ -746,3 +746,13 @@ gentoo_chroot() { exec chroot -- "$ROOT_MOUNTPOINT" "$GENTOO_INSTALL_REPO_DIR/scripts/main_chroot.sh" "$@" \ || die "Failed to chroot into '$ROOT_MOUNTPOINT'" } + +enable_service() { + if [[ $SYSTEMD == "true" ]]; then + systemctl enable "$1" \ + || die "Could not enable $1 service" + else + rc-update add "$1" default \ + || die "Could not add $1 to default services" + fi +} diff --git a/scripts/main.sh b/scripts/main.sh index 646ac20..7849879 100755 --- a/scripts/main.sh +++ b/scripts/main.sh @@ -134,8 +134,7 @@ install_sshd() { einfo "Installing sshd" install -m0600 -o root -g root "$GENTOO_INSTALL_REPO_DIR/configs/sshd_config" /etc/ssh/sshd_config \ || die "Could not install /etc/ssh/sshd_config" - rc-update add sshd default \ - || die "Could not add sshd to default services" + enable_service sshd groupadd -r sshusers \ || die "Could not create group 'sshusers'" } @@ -346,7 +345,7 @@ main_install_gentoo_in_chroot() { # Generate a valid fstab file generate_fstab - # Install and enable dhcpcd + # Install gentoolkit einfo "Installing gentoolkit" try emerge --verbose app-portage/gentoolkit @@ -355,11 +354,13 @@ main_install_gentoo_in_chroot() { install_sshd fi - # Install and enable dhcpcd - einfo "Installing dhcpcd" - try emerge --verbose net-misc/dhcpcd - rc-update add dhcpcd default \ - || die "Could not add dhcpcd to default services" + if [[ $SYSTEMD != "true" ]]; then + # Install and enable dhcpcd + einfo "Installing dhcpcd" + try emerge --verbose net-misc/dhcpcd + + enable_service dhcpcd + fi # Install ansible if [[ $INSTALL_ANSIBLE == "true" ]]; then