|
| 1 | +#!/bin/bash |
| 2 | +# This file is part of dracut. |
| 3 | +# SPDX-License-Identifier: GPL-2.0-or-later |
| 4 | + |
| 5 | +# Prerequisite check(s) for module. |
| 6 | +check() { |
| 7 | + |
| 8 | + # If the binary(s) requirements are not fulfilled the module can't be installed |
| 9 | + require_binaries "$systemdutildir"/systemd-timesyncd || return 1 |
| 10 | + require_binaries "$systemdutildir"/systemd-time-wait-sync || return 1 |
| 11 | + |
| 12 | + # Return 255 to only include the module, if another module requires it. |
| 13 | + return 255 |
| 14 | + |
| 15 | +} |
| 16 | + |
| 17 | +# Module dependency requirements. |
| 18 | +depends() { |
| 19 | + |
| 20 | + # This module has external dependency on other module(s). |
| 21 | + echo dbus systemd-timedated |
| 22 | + # Return 0 to include the dependent module(s) in the initramfs. |
| 23 | + return 0 |
| 24 | + |
| 25 | +} |
| 26 | + |
| 27 | +# Install the required file(s) and directories for the module in the initramfs. |
| 28 | +install() { |
| 29 | + |
| 30 | + # Enable this if networkd ( not the module ) is disabled at build time and you want to use timesyncd |
| 31 | + # inst_simple "$moddir/timesyncd-tmpfile-dracut.conf" "$tmpfilesdir/timesyncd-tmpfile-dracut.conf" |
| 32 | + |
| 33 | + inst_multiple -o \ |
| 34 | + "$dbussystem"/org.freedesktop.timesync1.conf \ |
| 35 | + "$dbussystemservices"/org.freedesktop.timesync1.service \ |
| 36 | + "$systemdutildir/ntp-units.d/*.list" \ |
| 37 | + "$systemdutildir"/systemd-timesyncd \ |
| 38 | + "$systemdutildir"/systemd-time-wait-sync \ |
| 39 | + "$systemdutildir/timesyncd.conf.d/*.conf" \ |
| 40 | + "$systemdsystemunitdir"/systemd-timesyncd.service \ |
| 41 | + "$systemdsystemunitdir/systemd-timesyncd.service.d/*.conf" \ |
| 42 | + "$systemdsystemunitdir"/systemd-time-wait-sync.service \ |
| 43 | + "$systemdsystemunitdir/systemd-time-wait-sync.service.d/*.conf" |
| 44 | + |
| 45 | + # Enable systemd type unit(s) |
| 46 | + for i in \ |
| 47 | + systemd-timesyncd.service \ |
| 48 | + systemd-time-wait-sync.service; do |
| 49 | + $SYSTEMCTL -q --root "$initdir" enable "$i" |
| 50 | + done |
| 51 | + |
| 52 | + # Install the hosts local user configurations if enabled. |
| 53 | + if [[ $hostonly ]]; then |
| 54 | + inst_multiple -H -o \ |
| 55 | + "$systemdutilconfdir/ntp-units.d/*.list" \ |
| 56 | + "$systemdutilconfdir"/timesyncd.conf \ |
| 57 | + "$systemdutilconfdir/timesyncd.conf.d/*.conf" \ |
| 58 | + "$systemdsystemconfdir"/systemd-timesyncd.service \ |
| 59 | + "$systemdsystemconfdir/systemd-timesyncd.service.d/*.conf" \ |
| 60 | + "$systemdsystemunitdir"/systemd-time-wait-sync.service \ |
| 61 | + "$systemdsystemunitdir/systemd-time-wait-sync.service.d/*.conf" |
| 62 | + fi |
| 63 | +} |
0 commit comments