|
| 1 | +#!/bin/bash |
| 2 | +# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- |
| 3 | +# ex: ts=8 sw=4 sts=4 et filetype=sh |
| 4 | + |
| 5 | +check() { |
| 6 | + if [[ $IN_KDUMP == 1 ]]; then |
| 7 | + return 1 |
| 8 | + fi |
| 9 | +} |
| 10 | + |
| 11 | +depends() { |
| 12 | + echo systemd network ignition coreos-live |
| 13 | +} |
| 14 | + |
| 15 | +install_ignition_unit() { |
| 16 | + local unit="$1"; shift |
| 17 | + local target="${1:-ignition-complete.target}"; shift |
| 18 | + local instantiated="${1:-$unit}"; shift |
| 19 | + inst_simple "$moddir/$unit" "$systemdsystemunitdir/$unit" |
| 20 | + # note we `|| exit 1` here so we error out if e.g. the units are missing |
| 21 | + # see https://github.com/coreos/fedora-coreos-config/issues/799 |
| 22 | + systemctl -q --root="$initdir" add-requires "$target" "$instantiated" || exit 1 |
| 23 | +} |
| 24 | + |
| 25 | +install() { |
| 26 | + inst_multiple \ |
| 27 | + basename \ |
| 28 | + diff \ |
| 29 | + lsblk \ |
| 30 | + sed \ |
| 31 | + grep \ |
| 32 | + uname |
| 33 | + |
| 34 | + |
| 35 | + # In some cases we had to vendor gdisk in Ignition. |
| 36 | + # If this is the case here use that one. |
| 37 | + # See https://issues.redhat.com/browse/RHEL-56080 |
| 38 | + if [ -f /usr/libexec/ignition-sgdisk ]; then |
| 39 | + inst /usr/libexec/ignition-sgdisk /usr/sbin/sgdisk |
| 40 | + else |
| 41 | + inst sgdisk |
| 42 | + fi |
| 43 | + |
| 44 | + # For IBM SecureExecution |
| 45 | + if [[ $(uname -m) = s390x ]]; then |
| 46 | + inst_multiple \ |
| 47 | + gpg \ |
| 48 | + gpg-agent |
| 49 | + fi |
| 50 | + |
| 51 | + inst_simple "$moddir/coreos-diskful-generator" \ |
| 52 | + "$systemdutildir/system-generators/coreos-diskful-generator" |
| 53 | + |
| 54 | + inst_script "$moddir/coreos-gpt-setup.sh" \ |
| 55 | + "/usr/sbin/coreos-gpt-setup" |
| 56 | + |
| 57 | + # This has to work only on diskful systems during firstboot. |
| 58 | + # coreos-diskful-generator will create a symlink |
| 59 | + inst_simple "$moddir/80-coreos-boot-disk.rules" \ |
| 60 | + "/usr/lib/coreos/80-coreos-boot-disk.rules" |
| 61 | + |
| 62 | + inst_script "$moddir/coreos-disk-contains-fs.sh" \ |
| 63 | + "/usr/lib/udev/coreos-disk-contains-fs" |
| 64 | + |
| 65 | + inst_script "$moddir/coreos-ignition-setup-user.sh" \ |
| 66 | + "/usr/sbin/coreos-ignition-setup-user" |
| 67 | + |
| 68 | + inst_script "$moddir/coreos-post-ignition-checks.sh" \ |
| 69 | + "/usr/sbin/coreos-post-ignition-checks" |
| 70 | + |
| 71 | + install_ignition_unit coreos-post-ignition-checks.service |
| 72 | + |
| 73 | + # For consistency tear down the network and persist multipath between the initramfs and |
| 74 | + # real root. See https://github.com/coreos/fedora-coreos-tracker/issues/394#issuecomment-599721763 |
| 75 | + inst_script "$moddir/coreos-teardown-initramfs.sh" \ |
| 76 | + "/usr/sbin/coreos-teardown-initramfs" |
| 77 | + install_ignition_unit coreos-teardown-initramfs.service |
| 78 | + |
| 79 | + # units only started when we have a boot disk |
| 80 | + # path generated by systemd-escape --path /dev/disk/by-label/root |
| 81 | + install_ignition_unit coreos-gpt-setup.service ignition-diskful.target |
| 82 | + |
| 83 | + # dracut inst_script doesn't allow overwrites and we are replacing |
| 84 | + # the default script placed by Ignition |
| 85 | + binpath="/usr/sbin/ignition-kargs-helper" |
| 86 | + cp "$moddir/coreos-kargs.sh" "$initdir$binpath" |
| 87 | + install_ignition_unit coreos-kargs-reboot.service |
| 88 | + |
| 89 | + install_ignition_unit coreos-ignition-unique-boot.service ignition-diskful.target |
| 90 | + install_ignition_unit coreos-unique-boot.service ignition-diskful.target |
| 91 | + install_ignition_unit coreos-ignition-setup-user.service |
| 92 | + |
| 93 | + # IBM Secure Execution. Ignition config for reencryption of / and /boot |
| 94 | + inst_simple "$moddir/01-secex.ign" /usr/lib/coreos/01-secex.ign |
| 95 | + inst_simple "$moddir/coreos-secex-ignition-prepare.service" \ |
| 96 | + "$systemdsystemunitdir/coreos-secex-ignition-prepare.service" |
| 97 | + inst_script "$moddir/coreos-secex-ignition-prepare.sh" \ |
| 98 | + "/usr/sbin/coreos-secex-ignition-prepare" |
| 99 | + |
| 100 | + inst_multiple jq blkid |
| 101 | + inst_script "$moddir/coreos-rootflags.sh" \ |
| 102 | + "/usr/sbin/coreos-rootflags" |
| 103 | + # Install unit, but don't enable it. Will be pulled in by diskful generator. |
| 104 | + inst_simple "$moddir/coreos-rootflags.service" "$systemdsystemunitdir/coreos-rootflags.service" |
| 105 | +} |
0 commit comments