From 672c52e0a213df4eda88cefc8e19e68a61e5a9ea Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Sat, 7 Jan 2012 18:11:05 +0100 Subject: [PATCH 1/2] usbinstall.sh: use DeviceIsMounted property to check if device is already mounted at startup --- src/usbinstall.sh | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/usbinstall.sh b/src/usbinstall.sh index efe7a92..aea1bcd 100755 --- a/src/usbinstall.sh +++ b/src/usbinstall.sh @@ -53,6 +53,13 @@ org.freedesktop.DBus.Properties.Get string:$3 string:$4` return 0 } +function dbus_properties_get_bool() { + REPLY=`dbus-send --system --print-reply --dest=$1 $2 org.freedesktop.DBus.Properties.Get string:$3 string:$4` + [ $? -eq 0 ] || return 1 + echo $REPLY | sed "s|.*boolean \(.*\)|\1|" + return 0 +} + # Set progressbar # Arg 1: value% set_pbar() @@ -80,10 +87,16 @@ export SELECT_ISO=$3 set_status "Smonto la chiavetta" -LANG=C udisks --unmount ${SELECT_USB}1 | grep failed && { + +DEVICEISMOUNTED=`dbus_properties_get_bool org.freedesktop.UDisks /org/freedesktop/UDisks/devices/${SELECT_USB/*\/}1 \ +org.freedesktop.UDisks.Device DeviceIsMounted` + +if [ "$DEVICEISMOUNTED" = "true" ]; then + LANG=C udisks --unmount ${SELECT_USB}1 | grep failed && { echo "Error: fail to umount the usb key (${SELECT_USB}1)" exit 1 -} + } +fi set_pbar 2 @@ -92,7 +105,7 @@ sudo fdisk $SELECT_USB < ./fdisk_template set_pbar 5 sudo mkfs.ext3 ${SELECT_USB}1 -L openmamba_live sleep 1 -udisks --mount ${SELECT_USB}1 +LANG=C udisks --mount ${SELECT_USB}1 set_pbar 30 @@ -130,7 +143,7 @@ set_pbar 98 set_status "Smonto la chiavetta" -udisks --unmount ${SELECT_USB}1 | grep failed && { +LANG=C udisks --unmount ${SELECT_USB}1 | grep failed && { echo "Error: fail to umount the usb key (${SELECT_USB}1)" exit 2 } From f3b36c8a84739b026f98f4ea8f5f0a3666003cad Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Sat, 7 Jan 2012 18:14:13 +0100 Subject: [PATCH 2/2] usbinstall.sh: make pushd/popd silent --- src/usbinstall.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/usbinstall.sh b/src/usbinstall.sh index aea1bcd..eb63d9c 100755 --- a/src/usbinstall.sh +++ b/src/usbinstall.sh @@ -114,7 +114,7 @@ MOUNTDIR=`dbus_properties_get_stringlist org.freedesktop.UDisks /org/freedesktop org.freedesktop.UDisks.Device DeviceMountPaths` set_status "Estrazione del file di boot in corso..." -pushd $MOUNTDIR +pushd $MOUNTDIR >/dev/null sudo chmod 777 ./ gunzip -c $SELECT_BOOT | cpio -i set_pbar 38 @@ -138,7 +138,7 @@ while [ $ORIG_SIZE -gt $DEST_SIZE ]; do set_pbar $percentuale done ln -fs `basename $SELECT_ISO` ./openmamba-live.iso -popd +popd >/dev/null set_pbar 98