Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

Commit

Permalink
dracut/30ignition: Reboot the system after ignition if kargs.d is pre…
Browse files Browse the repository at this point in the history
…sent

As mentioned in https://github.com/coreos/ignition-dracut/issues/81#issuecomment-494888494,
this change adds a service that checks for the presence of `/etc/ostree/kargs.d` and redeploys
then reboots the system if it exists.

Closes: #81
  • Loading branch information
Allen Bai committed Jun 24, 2019
1 parent df88988 commit 5d6eb52
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
16 changes: 16 additions & 0 deletions dracut/30ignition/ignition-reboot.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[Unit]
Description=Ignition (reboot)
DefaultDependencies=false
Before=ignition-complete.target

# Make sure ExecStart= runs before we switch root
Before=initrd-switch-root.target

# Make sure root filesystem is mounted
After=ignition-mount.service

[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=/run/ignition.env
ExecStart=/usr/sbin/ignition-reboot
14 changes: 14 additions & 0 deletions dracut/30ignition/ignition-reboot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -euo pipefail

# Checks if kernel argument directory exists,
# then redeploy and reboot the system if it exists
reboot_if_kargs_dir_exists() {
if [ -d /etc/ostree/kargs.d ]
then
ostree admin deploy fedora/x86_64/coreos/testing-devel
exec systemctl reboot
fi
}

reboot_if_kargs_dir_exists
4 changes: 4 additions & 0 deletions dracut/30ignition/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ install() {
inst_script "$moddir/ignition-setup.sh" \
"/usr/sbin/ignition-setup"

inst_script "$moddir/ignition-reboot.sh" \
"/usr/sbin/ignition-reboot"

# Distro packaging is expected to install the ignition binary into the
# module directory.
inst_simple "$moddir/ignition" \
Expand All @@ -53,6 +56,7 @@ install() {
install_ignition_unit ignition-mount.service
install_ignition_unit ignition-files.service
install_ignition_unit ignition-remount-sysroot.service
install_ignition_unit ignition-reboot.service

# needed for openstack config drive support
inst_rules 60-cdrom_id.rules
Expand Down

0 comments on commit 5d6eb52

Please sign in to comment.