#!/bin/bash check() { if ! hash haveged 2>/dev/null; then warn "Could not find haveged in $PATH. Check if its installed." return 1 fi return 0 } # called by dracut install() { # see where haveged is installed local haveged_bin="$(command -v haveged)" if [ -z "$haveged_bin" ]; then warn "Could not find havaged in $PATH. Check if its installed." return 1 fi # TODO SysVInit support, if that even a thing anymore :) local haveged_service="$systemdsystemunitdir/haveged.service" if [ ! -f "$haveged_service" ]; then # query systemd directly haveged_service="$(systemctl show -p FragmentPath haveged | cut -c 14-)" if [ -z "$haveged_service" ]; then warn "Could not find haveged service in '$systemdsystemunitdir' or by querying systemd." warn "Check if it is installed properly." return 1 fi fi inst_multiple -o \ "$haveged_bin" \ "$haveged_service" # In Ubuntu, the service sources an EnvironmentFile for default options local haveged_env_file="$(grep -oP '^EnvironmentFile=-?\K.*' $haveged_service)" if [ -n "$haveged_env_file" ]; then mkdir -p "$initdir/${haveged_env_file%/*}" 2>/dev/null cp "$haveged_env_file" "$initdir/$haveged_env_file" fi mkdir -p "$initdir/$systemdsystemunitdir/basic.target.wants" 2>/dev/null ln_r "$systemdsystemunitdir/haveged.service" "$systemdsystemunitdir/basic.target.wants/haveged.service" }