Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions pkg/cidata/cidata.TEMPLATE.d/boot/00-reboot-if-required.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,21 @@

set -eux

[ "$LIMA_CIDATA_UPGRADE_PACKAGES" = "1" ] || exit 0

# Check if cloud-init forgot to reboot_if_required
# (only implemented for apt at the moment, not dnf)

if command -v dnf >/dev/null 2>&1; then
# dnf-utils needs to be installed, for needs-restarting
if dnf -h needs-restarting >/dev/null 2>&1; then
# needs-restarting returns "false" if needed (!)
if ! dnf needs-restarting -r >/dev/null 2>&1; then
systemctl reboot
# check-update returns "false" (100) if updates (!)
dnf check-update >/dev/null
if [ "$?" != "1" ]; then
# needs-restarting returns "false" if needed (!)
if ! dnf needs-restarting -r; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the command fails due to other reasons, this results in reboot loop too?
Should this match the stdout/stderr to avoid that?

Copy link
Member Author

@afbjorklund afbjorklund Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exit codes are hopelessly confused, scraping the plugin output could make it worse

But I think it is possible, as long as you select the C locale (the messages are translated)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the output is unclear it should default to avoid the potential reboot loop

systemctl reboot
fi
fi
fi
fi
5 changes: 5 additions & 0 deletions pkg/cidata/cidata.TEMPLATE.d/lima.env
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ LIMA_CIDATA_YQ_PROVISION_{{$yqProvision.FileName}}_PATH={{$yqProvision.Path}}
LIMA_CIDATA_YQ_PROVISION_{{$yqProvision.FileName}}_PERMISSIONS={{$yqProvision.Permissions}}
{{- end}}
LIMA_CIDATA_GUEST_INSTALL_PREFIX={{ .GuestInstallPrefix }}
{{- if .UpgradePackages}}
LIMA_CIDATA_UPGRADE_PACKAGES=1
{{- else}}
LIMA_CIDATA_UPGRADE_PACKAGES=
{{- end}}
{{- if .Containerd.User}}
LIMA_CIDATA_CONTAINERD_USER=1
{{- else}}
Expand Down
Loading