From 4d0cc6d735ba253afc606fd7d36ced331c10d612 Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Wed, 2 Apr 2014 00:49:41 +0200 Subject: [PATCH] installer.sh: some fixes for maybe long time bugs - suse a pid file to avoid duplicated instances (note:requires /run, change to /var/run if backporting to milestone2) - use trap to unmount install partition - use PIPESTATUS[0] to manage errors in cp | cp_parser --- installer/installer.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/installer/installer.sh b/installer/installer.sh index 3a469ad..b1984db 100755 --- a/installer/installer.sh +++ b/installer/installer.sh @@ -15,6 +15,16 @@ MAMBAWELCOME_SCRIPT=/usr/share/openmamba/mambawelcome/mambawelcome.sh LOG_FILE=/var/log/install-$INSTALL_DATE.log MOUNTPOINT=/mnt/install KERNEL_RELEASE=`uname -r` +PIDFILE=/run/openmamba-installer.pid + +[ -e $PIDFILE ] && PIDCHECK=`cat $PIDFILE` + +[ "$PIDCHECK" -a -e /proc/$PIDCHECK ] && { + echo "Error: an installer process is already running; exiting." + exit 0 +} + +trap "umount -R $MOUNTPOINT 2>/dev/null; rm -f $PIDFILE" 0 HUP INT QUIT ABRT KILL TERM function abort() { [ "$DCOPID" ] && { @@ -22,6 +32,7 @@ function abort() { dcop $DCOPID KommanderIf setText finallabel $"Installation aborted :-(" dcop $DCOPID KommanderIf setEnabled next true } + rm -f $PIDFILE exit 1 } @@ -34,6 +45,7 @@ function finished() { dcop $DCOPID KommanderIf setEnabled next true dcop $DCOPID KommanderIf setEnabled ProgressGroupBox true } + rm -f $PIDFILE exit 1 } @@ -96,6 +108,8 @@ function get_udisks_key() { exit 0 } +echo $$ > $PIDFILE + DCOPID=$2 echo $"\ @@ -333,7 +347,8 @@ done for d in etc bin boot lib lib64 opt sbin srv usr var root; do [ "$INSTALL_CLONE_MODE" != "1" ] && canonical_dir=/squashfs/$d || canonical_dir=`readlink -f /$d` [ -e $canonical_dir ] || continue - cp -av $canonical_dir $MOUNTPOINT/ | cp_parser || { + cp -av $canonical_dir $MOUNTPOINT/ | cp_parser + [ ${PIPESTATUS[0]} -eq 0 ] || { echo $"Error: cannot copy $canonical_dir to $MOUNTPOINT; aborting." >&2 abort } @@ -640,4 +655,5 @@ finished echo $"Installation done. You can now reboot to start the freshly installed system." +rm -f $PIDFILE exit 0