Skip to content

Commit

Permalink
Add GRUB firstboot variable support
Browse files Browse the repository at this point in the history
For firstboot detection Ignition currently supports the flag file
/boot/ignition.firstboot. On a pure read only root file system however this
file could not be deleted, so there has to be another option for storing
the flag.

This commit implements support for storing the flag as a GRUB environment
variable.
  • Loading branch information
laenion committed Mar 18, 2019
1 parent b11553f commit cb70bb2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 0 additions & 1 deletion grub/02_ignition_firstboot
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ exec tail -n +3 $0
search --set=bootpart --label boot
# Determine if this is a first boot and set the variable
# to be used later on the kernel command line.
set ignition_firstboot=""
if [ -f "(${bootpart})/ignition.firstboot" ]; then
set ignition_firstboot="ignition.firstboot rd.neednet=1 ip=dhcp"
fi
6 changes: 5 additions & 1 deletion systemd/ignition-firstboot-complete.service
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ RemainAfterExit=yes
# detected this file. Fail if we are unable to remove it, rather than risking
# rerunning Ignition at next boot.
MountFlags=slave
ExecStart=/bin/sh -c 'mount -o remount,rw /boot && rm /boot/ignition.firstboot'
ExecStart=/bin/sh -c 'if [ -e /boot/ignition.firstboot ]; then \
mount -o remount,rw /boot && rm /boot/ignition.firstboot; fi'
ExecStart=-/bin/sh -c 'if command -v grub2-editenv >/dev/null && \
grub2-editenv list | grep -q "^ignition_firstboot="; then \
grub2-editenv - set ignition_firstboot=0; fi'

[Install]
WantedBy=multi-user.target

0 comments on commit cb70bb2

Please sign in to comment.