Patchwork [2/2] mkefidisk.sh: Add signal handling

login
register
mail settings
Submitter Darren Hart
Date July 21, 2014, 10:45 p.m.
Message ID <4d5011c9e8ab86c32edd9ac606fa1330576bb97f.1405982758.git.dvhart@linux.intel.com>
Download mbox | patch
Permalink /patch/76233/
State Accepted
Commit cfa23a21d4f97136af56066d5d438c4a612eac11
Headers show

Comments

Darren Hart - July 21, 2014, 10:45 p.m.
Add basic signal handling to unmount and remove any temporary files.

Signed-off-by: Darren Hart <dvhart@linux.intel.com>
---
 scripts/contrib/mkefidisk.sh | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
Darren Hart - July 21, 2014, 11:01 p.m.
Please ignore this one (2/2), it rearranges output in a way that might
lead to someone pulling the USB key before the sync completes. I will
resend 2/2 of separately.

Apologies :/

On 7/21/14, 15:45, "Darren Hart" <dvhart@linux.intel.com> wrote:

>Add basic signal handling to unmount and remove any temporary files.
>
>Signed-off-by: Darren Hart <dvhart@linux.intel.com>
>---
> scripts/contrib/mkefidisk.sh | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
>diff --git a/scripts/contrib/mkefidisk.sh b/scripts/contrib/mkefidisk.sh
>index 44ab8d5..7d48b53 100755
>--- a/scripts/contrib/mkefidisk.sh
>+++ b/scripts/contrib/mkefidisk.sh
>@@ -46,7 +46,9 @@ cleanup() {
> 	if [ -d "$TMPDIR" ]; then
> 		rm -rf $TMPDIR || error "Failed to remove $TMPDIR"
> 	fi
>+	exit $1
> }
>+trap cleanup HUP INT TERM
> 
> # Logging routines
> WARNINGS=0
>@@ -72,8 +74,7 @@ success() {
> }
> die() {
> 	error $1
>-	cleanup
>-	exit 1
>+	cleanup 1
> }
> debug() {
> 	if [ $DEBUG -eq 1 ]; then
>@@ -375,10 +376,6 @@ if [ -d $ROOTFS_MNT/etc/udev/ ] ; then
> 	echo "$TARGET_DEVICE" >> $ROOTFS_MNT/etc/udev/mount.blacklist
> fi
> 
>-
>-# Call cleanup to unmount devices and images and remove the TMPDIR
>-cleanup
>-
> echo ""
> if [ $WARNINGS -ne 0 ] && [ $ERRORS -eq 0 ]; then
> 	echo "${YELLOW}Installation completed with warnings${CLEAR}"
>@@ -391,3 +388,6 @@ else
> 	success "Installation completed successfully"
> fi
> echo ""
>+
>+# Call cleanup to unmount devices and images and remove the TMPDIR
>+cleanup 0
>-- 
>2.0.0
>
>

Patch

diff --git a/scripts/contrib/mkefidisk.sh b/scripts/contrib/mkefidisk.sh
index 44ab8d5..7d48b53 100755
--- a/scripts/contrib/mkefidisk.sh
+++ b/scripts/contrib/mkefidisk.sh
@@ -46,7 +46,9 @@  cleanup() {
 	if [ -d "$TMPDIR" ]; then
 		rm -rf $TMPDIR || error "Failed to remove $TMPDIR"
 	fi
+	exit $1
 }
+trap cleanup HUP INT TERM
 
 # Logging routines
 WARNINGS=0
@@ -72,8 +74,7 @@  success() {
 }
 die() {
 	error $1
-	cleanup
-	exit 1
+	cleanup 1
 }
 debug() {
 	if [ $DEBUG -eq 1 ]; then
@@ -375,10 +376,6 @@  if [ -d $ROOTFS_MNT/etc/udev/ ] ; then
 	echo "$TARGET_DEVICE" >> $ROOTFS_MNT/etc/udev/mount.blacklist
 fi
 
-
-# Call cleanup to unmount devices and images and remove the TMPDIR
-cleanup
-
 echo ""
 if [ $WARNINGS -ne 0 ] && [ $ERRORS -eq 0 ]; then
 	echo "${YELLOW}Installation completed with warnings${CLEAR}"
@@ -391,3 +388,6 @@  else
 	success "Installation completed successfully"
 fi
 echo ""
+
+# Call cleanup to unmount devices and images and remove the TMPDIR
+cleanup 0