Added systemd's version of enabling services

This commit is contained in:
oddlama 2020-10-10 17:08:54 +02:00
parent fdbc6fb3aa
commit 19b4f1d80c
No known key found for this signature in database
GPG Key ID: 88EA325D51D53908
3 changed files with 19 additions and 10 deletions

View File

@ -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

View File

@ -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
}

View File

@ -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