Path: blob/master/pkg/cidata/cidata.TEMPLATE.d/boot/00-reboot-if-required.sh
2678 views
#!/bin/bash12# SPDX-FileCopyrightText: Copyright The Lima Authors3# SPDX-License-Identifier: Apache-2.045set -eux67[ "$LIMA_CIDATA_UPGRADE_PACKAGES" = "1" ] || exit 089# Check if cloud-init forgot to reboot_if_required10# (only implemented for apt at the moment, not dnf)1112if command -v dnf >/dev/null 2>&1; then13# dnf-utils needs to be installed, for needs-restarting14if dnf -h needs-restarting >/dev/null 2>&1; then15# check-update returns "false" (100) if updates (!)16set +e17dnf check-update >/dev/null18if [ "$?" != "1" ]; then19# needs-restarting messages are translated _()20export LC_ALL=C.UTF-821logfile=$(mktemp)22# needs-restarting returns "false" if needed (!)23set -o pipefail24dnf needs-restarting -r | tee "$logfile"25if [ "$?" = "1" ]; then26if grep -q "Reboot is required" "$logfile"; then27systemctl reboot28fi29fi30rm "$logfile"31fi32fi33fi343536