*Add confirm check by -y arg

This commit is contained in:
Filippo Bedendo Bordon 2012-02-18 19:07:03 +01:00
parent cf7c3c76c5
commit b5cf37d9f6
3 changed files with 34 additions and 7 deletions

View File

@ -46,6 +46,7 @@ install-locales: locales
install-dirs:
@$(INSTALL_DIR) $(DESTDIR)$(sbindir)
@$(INSTALL_DIR) $(DESTDIR)$(mambadir)/usbinstall
@$(INSTALL_DIR) $(DESTDIR)$(datadir)/applications
@$(INSTALL_DIR) $(DESTDIR)$(mambadir)/usbinstall/img
@$(INSTALL_DIR) $(DESTDIR)$(sysconfdir)/sudoers.d/
@ -55,7 +56,7 @@ install: install-dirs install-locales
$(INSTALL_DATA) src/fdisk_template $(DESTDIR)$(mambadir)/usbinstall/fdisk_template
$(INSTALL_DATA) src/img/*.png $(DESTDIR)$(mambadir)/usbinstall/img/
${INSTALL} -m 440 src/usbinstall-sudoers $(DESTDIR)$(sysconfdir)/sudoers.d/usbinstall
# Crea un link in /usr/bin agli eseguibili in $(mambadir)/usbinstall
$(INSTALL_DATA) src/usbinstall.desktop $(DESTDIR)$(datadir)/applications/usbinstall.desktop
clean:
rm -f $(pck_catalogs:.po=.mo)

View File

@ -369,7 +369,7 @@ def step4():
window.p_install.show()
dbus_start()
# NON FUNZIONA...
process_sh = Popen(["sudo", "/usr/bin/usbinstall.sh", path_dev, path_cpio, path_iso], env={"DBUS_USBINSTALL": "1"})
process_sh = Popen(["sudo", "/usr/bin/usbinstall.sh", path_dev, path_cpio, path_iso, "-y"], env={"DBUS_USBINSTALL": "1"})
# Show a list of object (step 1 and 2)

View File

@ -96,10 +96,12 @@ function errorAndExit()
function usage()
{
echo "Usbistall: write Openmamba into your usb key!"
echo -e "\tUsage: sudo usbinstall Arg1 Arg2 Arg3"
echo -e "\tUsage: sudo usbinstall Arg1 Arg2 Arg3 [-y]"
echo -e "\tArg 1: Usb device path (es. /dev/sdc)"
echo -e "\tArg 2: Cpio.gz file (es. ~/openmamba-bootusb-it-milestone2-2.0pre8.i586.cpio.gz)"
echo -e "\tArg 3: Iso file (es. ~/openmamba-livecd-it-milestone2-2.0pre8.i586.iso)"
echo -e "\t-y: Installa senza chiedere alcuna conferma [Attenzione!]"
}
@ -168,6 +170,13 @@ fi
if [ "${3##*.}" != "iso" ]; then
errorAndExit "Error(Arg 3): you must chose a iso file" 1
fi
# Confirm
if [ "$4" = "-y" ]; then
export CONFIRM=0
else
export CONFIRM=1
fi
#################################(INITIAL-CHECK)#####################################
@ -189,22 +198,35 @@ if [ "$DEVICEISMOUNTED" = "true" ]; then
fi
set_pbar 2
# Prima di formattare :P
if [ "$CONFIRM" = "1" ]; then
echo "Warning: You are going to format this device ($1). Are you sure to continue? [yes/no]"
read KEY
case "$KEY" in
yes)
;;
*)
errorAndExit "Installation aborted"
;;
esac
fi
set_status "Formattazione della chiavetta in corso..."
echo "Format..."
set_status "Partizionamento della chiavetta in corso..."
echo "Partitioning $SELECT_USB..."
sudo fdisk $SELECT_USB < /usr/share/openmamba/usbinstall/fdisk_template &>$LOGFILE
if [ "$?" != "0" ]; then
errorAndExit "Error: \"fdisk\" exit with error (see $LOGFILE)"
fi
set_pbar 5
echo "Make Fs (ext3)..."
set_status "Formattazione della chiavetta in corso..."
echo "Formatting..."
sudo mkfs.ext3 ${SELECT_USB}1 -L openmamba_live &>>$LOGFILE
if [ "$?" != "0" ]; then
errorAndExit "Error: \"mkfs.ext3\" exit with error (see $LOGFILE)"
fi
LANG=C udisks --mount ${SELECT_USB}1
LANG=C udisks --mount ${SELECT_USB}1 &>>$LOGFILE
if [ "$?" != "0" ]; then
errorAndExit "Error: \"udisks --mount\" exit with error (see $LOGFILE)"
fi
@ -215,6 +237,10 @@ set_pbar 30
MOUNTDIR=`dbus_properties_get_stringlist org.freedesktop.UDisks /org/freedesktop/UDisks/devices/${SELECT_USB/*\/}1 \
org.freedesktop.UDisks.Device DeviceMountPaths`
if [ ! -d "$MOUNTDIR" ]; then
errorAndExit "Error: unable to find usb mount path"
fi
set_status "Estrazione del file di boot in corso..."
pushd $MOUNTDIR >/dev/null
sudo chmod 777 ./