forked from pool/ignition
406cbf31e8
* news: add notes for 2.12.0 * stages/files: add previousReport to result report * tests: fix linter warning * workflows: limit permissions to reading repo contents * workflows: bump linter version * go.mod: revendor * Drop EOL Go versions * internal/distro: drop DiskByIDDir * providers/azure: add support for azure gen2 VMs * stages/mount: correctly relabel the root of a fresh ext4 filesystem * exec: fix permissions for mountpoints in home dirs * tests: drop os.ModeDir requirement in mode of output directories * examples: reboot with --force * exec/util: add blkid API to query block devices based on FSTYPE * stages/files: use IntToPtr() in createCrypttabEntries() * stages/files: write result report to /var/lib/ignition * engine: persist fetched config summaries in State * stages/disks: use State to persist keyfiles for files stage * *: add general mechanism for persisting state between stages * main: drop -clear-cache flag * engine: don't hardcode neednet path * fetch-offline: return ErrNeedNet if we need net * engine: switch Engine.logReport() to pointer receiver * engine: fix incorrect error in log message * dracut: drop ignition-setup-user.service * dracut: drop reference to ignition-setup-base.service * providers/gcp: access GCP metadata service by IP address * Remove ignition-firstboot-complete.service * OWNERS: remove * internal/exec/util: drop device argument from cResultToErr() * docs/config*: document storage.luks.clevis.threshold default * ci: disable spec bump external test workaround * docs: Add Ignition release / Spec version table * templates: update example releng signing ticket * templates: don't update %gotest lines * Provide ignition-firstboot-complete.service (removed by upstream due to correctly being considered distro spcific), based on the old upstream version; removed all non-SUSE specific stuff and integrated our own changes * Removed change-ignition-firstboot-path.conf (changes are integrated into ignition-firstboot-complete.service now). * Provide ignition-setup-user.service (removed by upstream due to correctly being considered distro spcific), based on the old upstream version. * Renamed ignition-setup-user-suse.sh to ignition-setup-user.sh * Adapted ignition-generator-suse and module-setup.sh to use the custom ignition-setup-user.service (no overriding of parts of the service file necessary any more). * Synced ignition-kargs-helper script with upstream example * Raising minimum Go version to 1.15 as required by upstream OBS-URL: https://build.opensuse.org/package/show/devel:kubic:ignition/ignition?expand=0&rev=79
80 lines
2.6 KiB
Bash
80 lines
2.6 KiB
Bash
#!/bin/bash
|
|
# Based on Ignition's examples/ignition-kargs-helper
|
|
|
|
set -euxo pipefail
|
|
|
|
grubcfg="/sysroot/etc/default/grub"
|
|
|
|
# Mount root file system. Note that we mount /boot but we don't unmount it
|
|
# because we are run in a systemd unit with MountFlags=slave so it is unmounted
|
|
# for us.
|
|
. /dracut-state.sh
|
|
mount "${root#block:}" "${NEWROOT}"
|
|
# Also mount x-initrd.mount flagged mounts to get the current /etc state
|
|
awk '$4 ~ /x-initrd.mount/ { system("findmnt /sysroot" $2 " >/dev/null || mount -t " $3 " -o " $4 " " $1 " /sysroot" $2) }' /sysroot/etc/fstab
|
|
|
|
orig_kernelopts="$(grep GRUB_CMDLINE_LINUX_DEFAULT "${grubcfg}")"
|
|
orig_kernelopts="${orig_kernelopts#*=}"
|
|
# trim the leading and trailing quote
|
|
orig_kernelopts="${orig_kernelopts:1:-1}"
|
|
|
|
# add leading and trailing whitespace to allow for easy sed replacements
|
|
kernelopts=" $orig_kernelopts "
|
|
|
|
while [[ $# -gt 0 ]]
|
|
do
|
|
key="$1"
|
|
|
|
case $key in
|
|
--should-exist)
|
|
arg="$2"
|
|
# don't repeat the arg
|
|
if [[ ! "${kernelopts[*]}" =~ " ${arg} " ]]; then
|
|
kernelopts="$kernelopts$arg "
|
|
fi
|
|
shift 2
|
|
;;
|
|
--should-not-exist)
|
|
kernelopts="$(echo "$kernelopts" | sed "s| $2 | |g")"
|
|
shift 2
|
|
;;
|
|
*)
|
|
echo "Unknown option"
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
# trim the leading and trailing whitespace
|
|
kernelopts="$(echo "$kernelopts" | sed -e 's,^[[:space:]]*,,' -e 's,[[:space:]]*$,,')"
|
|
|
|
# only apply the changes & reboot if changes have been made
|
|
if [[ "$kernelopts" != "$orig_kernelopts" ]]; then
|
|
combustiondir="/run/combustion/mount/combustion"
|
|
# The Combustion script may be located on an external device; if so the
|
|
# device is guaranteed to mounted here already:
|
|
# combustion-prepare: Before=dracutinitqueue.service
|
|
# ignition-fetch: After=basic.target
|
|
# Unmount the device, as the new Combustion script will be put at the
|
|
# same location below.
|
|
if findmnt "${combustiondir}"/.. >/dev/null; then
|
|
umount "${combustiondir}"/..
|
|
fi
|
|
mkdir -p "${combustiondir}"
|
|
# escape escapes to survive the multiple shell invocations
|
|
kernelopts="${kernelopts//\\/\\\\\\\\}"
|
|
kernelopts="${kernelopts//$/\\\$}"
|
|
cat << EOF > "${combustiondir}/script"
|
|
sed -i "s|^\(GRUB_CMDLINE_LINUX_DEFAULT=\).*|\1\"$kernelopts\"|" /etc/default/grub
|
|
/usr/sbin/grub2-mkconfig > /boot/grub2/grub.cfg
|
|
EOF
|
|
SYSTEMD_OFFLINE=1 combustion
|
|
|
|
# Reset health-checker to prevent an unintended rollback
|
|
echo "Clearing GRUB flag"
|
|
chroot /sysroot grub2-editenv - set health_checker_flag=0 || true
|
|
|
|
systemctl reboot --force
|
|
fi
|
|
|