Use system dbus for communication between frontend and script

Install configuration file in /etc/dbus-1/system.d for proper permissions
Modified some text strings
This commit is contained in:
Silvan Calarco 2012-02-20 02:31:57 +01:00
parent 77bc0b98d1
commit dd08e29560
4 changed files with 38 additions and 18 deletions

View File

@ -14,8 +14,9 @@ bindir := /usr/bin
sbindir := /usr/sbin
sysconfdir := /etc
datadir := /usr/share
mambadir := /usr/share/openmamba
polkitdir := /usr/share/polkit-1/actions
mambadir := ${datadir}/openmamba
polkitdir := ${datadir}/polkit-1/actions
dbussystemdir := ${sysconfdir}/dbus-1/system.d
localesdir := ${datadir}/locale
DESTDIR :=
@ -50,6 +51,7 @@ install-dirs:
@$(INSTALL_DIR) $(DESTDIR)$(datadir)/applications
@$(INSTALL_DIR) $(DESTDIR)$(mambadir)/usbinstall/img
@$(INSTALL_DIR) $(DESTDIR)$(polkitdir)
@$(INSTALL_DIR) $(DESTDIR)$(dbussystemdir)
install: install-dirs install-locales
$(INSTALL_PROGRAM) src/usbinstall.py $(DESTDIR)$(mambadir)/usbinstall/usbinstall.py
@ -57,6 +59,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_DATA) src/org.openmamba.usbinstall.policy $(DESTDIR)$(polkitdir)/org.openmamba.usbinstall.policy
$(INSTALL_DATA) src/org.openmamba.usbinstall.conf $(DESTDIR)$(dbussystemdir)/org.openmamba.usbinstall.conf
$(INSTALL_DATA) src/usbinstall.desktop $(DESTDIR)$(datadir)/applications/usbinstall.desktop
clean:

View File

@ -0,0 +1,12 @@
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<policy user="root">
<allow send_destination="org.openmamba.usbinstall"/>
</policy>
<policy at_console="true">
<allow own="org.openmamba.usbinstall"/>
</policy>
</busconfig>

View File

@ -294,10 +294,10 @@ class set_dbus(dbus.service.Object):
return 0
def dbus_start():
session_bus = dbus.SessionBus()
bus_name = dbus.service.BusName('org.openmamba.usbinstall', bus=session_bus)
session_bus = dbus.SystemBus()
bus_name = dbus.service.BusName('org.openmamba.usbinstall', bus=dbus.SystemBus())
dbus_loop = set_dbus(bus_name)
bus = dbus.SessionBus(mainloop=dbus_loop)
bus = dbus.SystemBus(mainloop=dbus_loop)
#4)###############################(DBUS CODE)########################################
@ -368,7 +368,7 @@ def step4():
# Show the progressBar
window.p_install.show()
dbus_start()
process_sh = Popen(["pkexec", "/usr/sbin/usbinstall", path_dev, path_cpio, path_iso, "-y"], env={"DBUS_USBINSTALL": "1"})
process_sh = Popen(["pkexec", "/usr/sbin/usbinstall", path_dev, path_cpio, path_iso, "-d"])
# Show a list of object (step 1 and 2)

View File

@ -68,7 +68,7 @@ function dbus_properties_get_bool() {
set_pbar()
{
if [ "$DBUS_USBINSTALL" == "1" ]; then
dbus-send --print-reply --session --dest=org.openmamba.usbinstall /org/openmamba/usbinstall org.openmamba.usbinstall.Set_progressBar int32:$1
dbus-send --system --print-reply --dest=org.openmamba.usbinstall /org/openmamba/usbinstall org.openmamba.usbinstall.Set_progressBar int32:$1 >/dev/null
fi
}
@ -77,7 +77,7 @@ set_pbar()
set_status()
{
if [ "$DBUS_USBINSTALL" == "1" ]; then
dbus-send --print-reply --session --dest=org.openmamba.usbinstall /org/openmamba/usbinstall org.openmamba.usbinstall.Set_description "string:$1"
dbus-send --system --print-reply --dest=org.openmamba.usbinstall /org/openmamba/usbinstall org.openmamba.usbinstall.Set_description "string:$1" >/dev/null
fi
}
####################################(DBUS)###########################################
@ -95,13 +95,12 @@ function errorAndExit()
function usage()
{
echo "Usbistall: write Openmamba into your usb key!"
echo "usbinstall: install openmamba into your usb key!"
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!]"
echo -e "\tArg 1: Usb device path (e.g. /dev/sdc)"
echo -e "\tArg 2: Cpio.gz file (e.g. ~/openmamba-bootusb-it-milestone2-2.0pre8.i586.cpio.gz)"
echo -e "\tArg 3: Iso file (e.g. ~/openmamba-livecd-it-milestone2-2.0pre8.i586.iso)"
echo -e "\t-y: install without asking confirmation [Be careful!]"
}
@ -126,7 +125,7 @@ if [ -b "$1" ]; then # If is a block device
if [ "$ISKEY" = "true" ]; then # If is a usb
export SELECT_USB=$1
else # If not, user can choose
echo "Warning: you haven't choose a usb key ($1). Are you sure to continue? [yes/no]"
echo "Warning: you haven't choosen a usb key ($1). Are you sure to continue? [yes/no]"
read KEY
case "$KEY" in
yes)
@ -159,7 +158,7 @@ fi
# Check if Arg 3 is valid
if [ -f "$3" ]; then # Check if is a file
if [ -r "$3" ]; then # Chek is is readable
export SELECT_ISO=$3
SELECT_ISO=$3
else
errorAndExit "Error(Arg 3): \"$3\" is not readable" 1
fi
@ -173,9 +172,12 @@ fi
# Confirm
if [ "$4" = "-y" ]; then
export CONFIRM=0
CONFIRM=0
elif [ "$4" = "-d" ]; then
CONFIRM=0
DBUS_USBINSTALL=1
else
export CONFIRM=1
CONFIRM=1
fi
#################################(INITIAL-CHECK)#####################################
@ -242,6 +244,7 @@ if [ ! -d "$MOUNTDIR" ]; then
fi
set_status "Estrazione del file di boot in corso..."
echo "Extracting bootusb archive..."
pushd $MOUNTDIR >/dev/null
sudo chmod 777 ./
gunzip -c $SELECT_BOOT | cpio -i
@ -255,6 +258,7 @@ set_pbar 45
set_status "Copia del file iso di openmamba in corso..."
echo "Copying ISO..."
# Copy code
ORIG_SIZE=`stat -c %s $SELECT_ISO`
cp $SELECT_ISO ./ &
@ -279,4 +283,5 @@ LANG=C udisks --unmount ${SELECT_USB}1 | grep failed && {
exit 2
}
set_pbar 100
echo "Done."
#################################(INSTALLATION)######################################