diff --git a/pkg/cidata/cidata.TEMPLATE.d/boot/00-reboot-if-required.sh b/pkg/cidata/cidata.TEMPLATE.d/boot/00-reboot-if-required.sh index fe75c1ae72e..49cf166ca7b 100644 --- a/pkg/cidata/cidata.TEMPLATE.d/boot/00-reboot-if-required.sh +++ b/pkg/cidata/cidata.TEMPLATE.d/boot/00-reboot-if-required.sh @@ -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 + systemctl reboot + fi fi fi fi diff --git a/pkg/cidata/cidata.TEMPLATE.d/lima.env b/pkg/cidata/cidata.TEMPLATE.d/lima.env index 8cd9453ccdc..4c78fe814a6 100644 --- a/pkg/cidata/cidata.TEMPLATE.d/lima.env +++ b/pkg/cidata/cidata.TEMPLATE.d/lima.env @@ -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}}