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 # Array of additional packages to install
ADDITIONAL_PACKAGES=("app-editors/neovim") ADDITIONAL_PACKAGES=("app-editors/neovim")
# Install and enable dhcpcd
INSTALL_DHCPCD=true
# Install and configure sshd (a reasonably secure config is provided, which # Install and configure sshd (a reasonably secure config is provided, which
# only allows the use of ed25519 keys, and requires pubkey authentication) # only allows the use of ed25519 keys, and requires pubkey authentication)
INSTALL_SSHD=true INSTALL_SSHD=true

View File

@ -746,3 +746,13 @@ gentoo_chroot() {
exec chroot -- "$ROOT_MOUNTPOINT" "$GENTOO_INSTALL_REPO_DIR/scripts/main_chroot.sh" "$@" \ exec chroot -- "$ROOT_MOUNTPOINT" "$GENTOO_INSTALL_REPO_DIR/scripts/main_chroot.sh" "$@" \
|| die "Failed to chroot into '$ROOT_MOUNTPOINT'" || 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" einfo "Installing sshd"
install -m0600 -o root -g root "$GENTOO_INSTALL_REPO_DIR/configs/sshd_config" /etc/ssh/sshd_config \ 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" || die "Could not install /etc/ssh/sshd_config"
rc-update add sshd default \ enable_service sshd
|| die "Could not add sshd to default services"
groupadd -r sshusers \ groupadd -r sshusers \
|| die "Could not create group 'sshusers'" || die "Could not create group 'sshusers'"
} }
@ -346,7 +345,7 @@ main_install_gentoo_in_chroot() {
# Generate a valid fstab file # Generate a valid fstab file
generate_fstab generate_fstab
# Install and enable dhcpcd # Install gentoolkit
einfo "Installing gentoolkit" einfo "Installing gentoolkit"
try emerge --verbose app-portage/gentoolkit try emerge --verbose app-portage/gentoolkit
@ -355,11 +354,13 @@ main_install_gentoo_in_chroot() {
install_sshd install_sshd
fi fi
# Install and enable dhcpcd if [[ $SYSTEMD != "true" ]]; then
einfo "Installing dhcpcd" # Install and enable dhcpcd
try emerge --verbose net-misc/dhcpcd einfo "Installing dhcpcd"
rc-update add dhcpcd default \ try emerge --verbose net-misc/dhcpcd
|| die "Could not add dhcpcd to default services"
enable_service dhcpcd
fi
# Install ansible # Install ansible
if [[ $INSTALL_ANSIBLE == "true" ]]; then if [[ $INSTALL_ANSIBLE == "true" ]]; then