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
This commit is contained in:
Silvan Calarco 2014-04-02 00:49:41 +02:00
parent a60b433c44
commit 4d0cc6d735

View File

@ -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