usbinstall: support for loop device installation and udisks2
This commit is contained in:
parent
7bd135a19c
commit
9c5c860761
@ -112,9 +112,11 @@ function errorAndExit()
|
||||
if [ -n "$2" ]; then
|
||||
usage
|
||||
fi
|
||||
if [ "${SELECT_USB}" ]; then
|
||||
udisks --unmount ${SELECT_USB}1 >/dev/null
|
||||
udisks --unmount ${SELECT_USB}2 >/dev/null
|
||||
if [ "${SELECT_USB1}" ]; then
|
||||
udisksctl unmount -b ${SELECT_USB1} >/dev/null
|
||||
fi
|
||||
if [ "${SELECT_USB2}" ]; then
|
||||
udisksctl unmount -b ${SELECT_USB2} >/dev/null
|
||||
fi
|
||||
exit_frontend "$1" # Termina il frontend con codice di errore 1
|
||||
exit 1
|
||||
@ -157,9 +159,8 @@ fi
|
||||
|
||||
# Check if Arg 1 is valid
|
||||
if [ -b "$1" ]; then # If is a block device
|
||||
ISKEY=`dbus_properties_get_bool org.freedesktop.UDisks /org/freedesktop/UDisks/devices/${1/*\/} \
|
||||
org.freedesktop.UDisks.Device DeviceIsRemovable`
|
||||
if [ "$ISKEY" = "true" ]; then # If is a usb
|
||||
ISKEY=`udisksctl info -b $1 | grep HintSystem | sed "s|.*[[:space:]]||"`
|
||||
if [ "$ISKEY" = "true" -o "$CONFIRM" = "0" ]; then # If is a usb
|
||||
export SELECT_USB=$1
|
||||
else # If not, user can choose
|
||||
echo $"Warning: you haven't choosen a removable device ($1). Are you sure to continue? [yes/no]"
|
||||
@ -177,6 +178,14 @@ else
|
||||
errorAndExit $"Error(Arg 1): \"$1\" isn't a block device" 1
|
||||
fi
|
||||
|
||||
if [ "${SELECT_USB:0:9}" = "/dev/loop" ]; then
|
||||
SELECT_USB1=${SELECT_USB}p1
|
||||
SELECT_USB2=${SELECT_USB}p2
|
||||
else
|
||||
SELECT_USB1=${SELECT_USB}1
|
||||
SELECT_USB2=${SELECT_USB}2
|
||||
fi
|
||||
|
||||
# Check if Arg 2 is valid
|
||||
if [ -r "$2" ]; then # Check it is readable
|
||||
# Check if Arg 2 is an iso file
|
||||
@ -190,8 +199,8 @@ fi
|
||||
|
||||
# Check if Arg 3 is valid
|
||||
if [ "$3" ]; then
|
||||
if [ "$3" != "-d" -a "$3" != "-t" ]; then # Check it is readable
|
||||
errorAndExit $"Error(Arg 3): \"$3\" is not -d nor -t" 1
|
||||
if [ "$3" != "-d" -a "$3" != "-y" ]; then # Check it is readable
|
||||
errorAndExit $"Error(Arg 3): \"$3\" is not -d nor -y" 1
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -208,12 +217,11 @@ trap "[ \"$CPPID\" ] && kill -9 $CPPID" HUP INT QUIT ABRT KILL TERM
|
||||
set_status $"Unmount usb device"
|
||||
echo $"Unmount usb device"
|
||||
|
||||
DEVICEISMOUNTED=`dbus_properties_get_bool org.freedesktop.UDisks /org/freedesktop/UDisks/devices/${SELECT_USB/*\/}1 \
|
||||
org.freedesktop.UDisks.Device DeviceIsMounted`
|
||||
DEVICEMOUNTPOINTS=`udisksctl info -b ${SELECT_USB1} | grep MountPoints: | sed "s|.*[[:space:]]||"`
|
||||
|
||||
if [ "$DEVICEISMOUNTED" = "true" ]; then
|
||||
LANG=C udisks --unmount ${SELECT_USB}1 | grep failed && {
|
||||
errorAndExit $"Error: fail to umount the usb key (${SELECT_USB}1)"
|
||||
if [ "$DEVICEMOUNTPOINTS" ]; then
|
||||
LANG=C udiskctl unmount -b ${SELECT_USB1} || {
|
||||
errorAndExit $"Error: fail to umount the usb key (${SELECT_USB1})"
|
||||
}
|
||||
fi
|
||||
set_pbar 2
|
||||
@ -258,29 +266,28 @@ set_pbar 5
|
||||
|
||||
set_status $"Formatting $SELECT_USB..."
|
||||
echo $"Formatting $SELECT_USB..."
|
||||
sudo mkfs.vfat ${SELECT_USB}1 -n EFI &>>$LOGFILE
|
||||
sudo mkfs.vfat ${SELECT_USB1} -n EFI &>>$LOGFILE
|
||||
if [ "$?" != "0" ]; then
|
||||
errorAndExit $"Error:"" \"mkfs.vfat\" "$"exit with error (see $LOGFILE)"
|
||||
fi
|
||||
sudo mkfs.ext4 ${SELECT_USB}2 -L openmamba_live &>>$LOGFILE
|
||||
sudo mkfs.ext4 ${SELECT_USB2} -L openmamba_live &>>$LOGFILE
|
||||
if [ "$?" != "0" ]; then
|
||||
errorAndExit $"Error:"" \"mkfs.ext4\" "$"exit with error (see $LOGFILE)"
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
LANG=C udisks --mount ${SELECT_USB}1 &>>$LOGFILE
|
||||
LANG=C udisksctl mount -b ${SELECT_USB1} &>>$LOGFILE
|
||||
if [ "$?" != "0" ]; then
|
||||
errorAndExit $"Error:"" \"udisks --mount\" "$"exit with error (see $LOGFILE)"
|
||||
fi
|
||||
LANG=C udisks --mount ${SELECT_USB}2 &>>$LOGFILE
|
||||
LANG=C udisksctl mount -b ${SELECT_USB2} &>>$LOGFILE
|
||||
if [ "$?" != "0" ]; then
|
||||
errorAndExit $"Error:"" \"udisks --mount\" "$"exit with error (see $LOGFILE)"
|
||||
fi
|
||||
set_pbar 30
|
||||
|
||||
# Riceve la mountdir della chiavetta da dbus
|
||||
MOUNTDIR_EFI=`dbus_properties_get_stringlist org.freedesktop.UDisks /org/freedesktop/UDisks/devices/${SELECT_USB/*\/}1 \
|
||||
org.freedesktop.UDisks.Device DeviceMountPaths`
|
||||
MOUNTDIR_EFI=`udisksctl info -b ${SELECT_USB1} | grep -m1 MountPoints: | sed "s|.*[[:space:]]||"`
|
||||
|
||||
if [ ! -d "$MOUNTDIR_EFI" ]; then
|
||||
errorAndExit $"Error: unable to found usb mount path"
|
||||
@ -304,8 +311,7 @@ if [ -d /usr/lib/grub/i386-efi ]; then
|
||||
fi
|
||||
|
||||
# Riceve la mountdir della chiavetta da dbus
|
||||
MOUNTDIR=`dbus_properties_get_stringlist org.freedesktop.UDisks /org/freedesktop/UDisks/devices/${SELECT_USB/*\/}2 \
|
||||
org.freedesktop.UDisks.Device DeviceMountPaths`
|
||||
MOUNTDIR=`udisksctl info -b ${SELECT_USB2} | grep -m1 MountPoints: | sed "s|.*[[:space:]]||"`
|
||||
|
||||
if [ ! -d "$MOUNTDIR" ]; then
|
||||
errorAndExit $"Error: unable to found usb mount path"
|
||||
@ -399,11 +405,11 @@ set_pbar 95
|
||||
|
||||
set_status $"Unmount usb device"
|
||||
echo $"Unmount usb device"
|
||||
LANG=C udisks --unmount ${SELECT_USB}1 | grep failed && {
|
||||
errorAndExit $"Error: fail to umount the usb key (${SELECT_USB}1)"
|
||||
LANG=C udisksctl unmount -b ${SELECT_USB1} || {
|
||||
errorAndExit $"Error: fail to umount the usb key (${SELECT_USB1})"
|
||||
}
|
||||
LANG=C udisks --unmount ${SELECT_USB}2 | grep failed && {
|
||||
errorAndExit $"Error: fail to umount the usb key (${SELECT_USB}2)"
|
||||
LANG=C udisksctl unmount -b ${SELECT_USB2} || {
|
||||
errorAndExit $"Error: fail to umount the usb key (${SELECT_USB2})"
|
||||
}
|
||||
|
||||
# WARNING: calling install-mbr after unmounting to prevent problems of FAT since EFI partition introduction
|
||||
|
Loading…
Reference in New Issue
Block a user