osi-tools/Documentation/module-examples/systemd-dhcpcd.sh

32 lines
1.0 KiB
Bash
Raw Normal View History

#!/hint/bash -euE
2018-08-18 18:42:42 +00:00
# Copyright (C) 2018 Luke Shumaker
# SPDX-License-Identifier: AGPL-3.0-or-later
2018-08-06 00:09:42 +00:00
2018-08-15 19:05:16 +00:00
# Also enable haveged. Without it, TLS will be unavailable for a
# while even after network-online.target because getrandom(2) will
# block for so long that the connection will time out.
packages+=('haveged')
2018-08-06 01:49:45 +00:00
post_install+=(10:dhcpcd:post_install)
2018-08-06 00:09:42 +00:00
dhcpcd:post_install() {
local arg_mountpoint=$1
cat <<-'EOT' > "${arg_mountpoint}/etc/udev/rules.d/81-dhcpcd.rules"
ACTION=="add", SUBSYSTEM=="net", ENV{SYSTEMD_WANTS}="dhcpcd@$name.service"
EOT
mkdir "${arg_mountpoint}/etc/systemd/system/dhcpcd@.service.d"
cat <<-'EOT' > "${arg_mountpoint}/etc/systemd/system/dhcpcd@.service.d/wait-online.conf"
[Unit]
Before=network-online.target
EOT
mkdir "${arg_mountpoint}/etc/systemd/system/network-online.target.d"
cat <<-'EOT' > "${arg_mountpoint}/etc/systemd/system/network-online.target.d/udev-settle.conf"
[Unit]
Wants=systemd-udev-settle.service
After=systemd-udev-settle.service
EOT
2018-08-15 19:05:16 +00:00
systemctl --root="$arg_mountpoint" enable haveged.service
2018-08-06 00:09:42 +00:00
}