public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: roberto.foglietta@gmail.com
To: isar-users@googlegroups.com
Cc: roberto.foglietta@gmail.com
Subject: [PATCH] If expand last partition fails, unsupervised systems reboot
Date: Tue, 13 Dec 2022 06:21:26 +0000	[thread overview]
Message-ID: <4uin751ogvjz.BGcJ14VHPisZGHKiFLvkmQ2@16F0H.trk.elasticemail.com> (raw)

From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>

Improvement for unsupervised embedded devices which need to reboot if expand last
partition fails because a under-provided system should not even complete the boot
in the field in order to avoid functioning failures at unexpected future time.
This patch do not affect the previous behaviour because requirs /etc/unsupervised

This patch applies after the following other patches:

 - In expand last partition script btrfs support added
 - In expand last partition wait for udev have finished

Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
---
 .../expand-on-first-boot/files/expand-last-partition.sh     | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/meta/recipes-support/expand-on-first-boot/files/expand-last-partition.sh b/meta/recipes-support/expand-on-first-boot/files/expand-last-partition.sh
index e314f70..46f3019 100755
--- a/meta/recipes-support/expand-on-first-boot/files/expand-last-partition.sh
+++ b/meta/recipes-support/expand-on-first-boot/files/expand-last-partition.sh
@@ -9,6 +9,8 @@
 
 set -e
 
+test -e /etc/unsupervised && trap reboot EXIT
+
 udevadm settle
 
 ROOT_DEV="$(findmnt / -o source -n)"
@@ -21,6 +23,7 @@ fi
 BOOT_DEV="$(echo "${ROOT_DEV}" | sed 's/p\?[0-9]*$//')"
 if [ "${ROOT_DEV}" = "${BOOT_DEV}" ]; then
 	echo "Boot device equals root device - no partitioning found" >&2
+	trap - EXIT
 	exit 1
 fi
 
@@ -37,6 +40,7 @@ done
 MINIMAL_SIZE=$((ALL_PARTS_SIZE + BUFFER_SIZE))
 if [ "$DISK_SIZE" -lt "$MINIMAL_SIZE" ]; then
 	echo "Disk is practically already full, doing nothing." >&2
+	trap - EXIT
 	exit 0
 fi
 
@@ -73,3 +77,5 @@ case $(lsblk -fno FSTYPE "${LAST_PART}") in
 		umount $tmp/btrfs && rmdir $tmp/btrfs
 		;;
 esac
+
+trap - EXIT
-- 
2.34.1


https://16F0H.trk.elasticemail.com/tracking/unsubscribe?d=k8b5tU6T3wzslpuxK4LJeIK0teDer-E0YhqiiD6-xRlYeYHHXmReVBuTI40TvZtKXtFA3zy8svB8aEFPpT3VZDtcG4yRxgul7f12efFHZyV10

                 reply	other threads:[~2022-12-13  6:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4uin751ogvjz.BGcJ14VHPisZGHKiFLvkmQ2@16F0H.trk.elasticemail.com \
    --to=roberto.foglietta@gmail.com \
    --cc=isar-users@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox