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:
parent
77bc0b98d1
commit
dd08e29560
7
Makefile
7
Makefile
@ -14,8 +14,9 @@ bindir := /usr/bin
|
|||||||
sbindir := /usr/sbin
|
sbindir := /usr/sbin
|
||||||
sysconfdir := /etc
|
sysconfdir := /etc
|
||||||
datadir := /usr/share
|
datadir := /usr/share
|
||||||
mambadir := /usr/share/openmamba
|
mambadir := ${datadir}/openmamba
|
||||||
polkitdir := /usr/share/polkit-1/actions
|
polkitdir := ${datadir}/polkit-1/actions
|
||||||
|
dbussystemdir := ${sysconfdir}/dbus-1/system.d
|
||||||
localesdir := ${datadir}/locale
|
localesdir := ${datadir}/locale
|
||||||
|
|
||||||
DESTDIR :=
|
DESTDIR :=
|
||||||
@ -50,6 +51,7 @@ install-dirs:
|
|||||||
@$(INSTALL_DIR) $(DESTDIR)$(datadir)/applications
|
@$(INSTALL_DIR) $(DESTDIR)$(datadir)/applications
|
||||||
@$(INSTALL_DIR) $(DESTDIR)$(mambadir)/usbinstall/img
|
@$(INSTALL_DIR) $(DESTDIR)$(mambadir)/usbinstall/img
|
||||||
@$(INSTALL_DIR) $(DESTDIR)$(polkitdir)
|
@$(INSTALL_DIR) $(DESTDIR)$(polkitdir)
|
||||||
|
@$(INSTALL_DIR) $(DESTDIR)$(dbussystemdir)
|
||||||
|
|
||||||
install: install-dirs install-locales
|
install: install-dirs install-locales
|
||||||
$(INSTALL_PROGRAM) src/usbinstall.py $(DESTDIR)$(mambadir)/usbinstall/usbinstall.py
|
$(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/fdisk_template $(DESTDIR)$(mambadir)/usbinstall/fdisk_template
|
||||||
$(INSTALL_DATA) src/img/*.png $(DESTDIR)$(mambadir)/usbinstall/img/
|
$(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.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
|
$(INSTALL_DATA) src/usbinstall.desktop $(DESTDIR)$(datadir)/applications/usbinstall.desktop
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
12
src/org.openmamba.usbinstall.conf
Normal file
12
src/org.openmamba.usbinstall.conf
Normal 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>
|
||||||
|
|
@ -294,10 +294,10 @@ class set_dbus(dbus.service.Object):
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
def dbus_start():
|
def dbus_start():
|
||||||
session_bus = dbus.SessionBus()
|
session_bus = dbus.SystemBus()
|
||||||
bus_name = dbus.service.BusName('org.openmamba.usbinstall', bus=session_bus)
|
bus_name = dbus.service.BusName('org.openmamba.usbinstall', bus=dbus.SystemBus())
|
||||||
dbus_loop = set_dbus(bus_name)
|
dbus_loop = set_dbus(bus_name)
|
||||||
bus = dbus.SessionBus(mainloop=dbus_loop)
|
bus = dbus.SystemBus(mainloop=dbus_loop)
|
||||||
#4)###############################(DBUS CODE)########################################
|
#4)###############################(DBUS CODE)########################################
|
||||||
|
|
||||||
|
|
||||||
@ -368,7 +368,7 @@ def step4():
|
|||||||
# Show the progressBar
|
# Show the progressBar
|
||||||
window.p_install.show()
|
window.p_install.show()
|
||||||
dbus_start()
|
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)
|
# Show a list of object (step 1 and 2)
|
||||||
|
@ -68,7 +68,7 @@ function dbus_properties_get_bool() {
|
|||||||
set_pbar()
|
set_pbar()
|
||||||
{
|
{
|
||||||
if [ "$DBUS_USBINSTALL" == "1" ]; then
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ set_pbar()
|
|||||||
set_status()
|
set_status()
|
||||||
{
|
{
|
||||||
if [ "$DBUS_USBINSTALL" == "1" ]; then
|
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
|
fi
|
||||||
}
|
}
|
||||||
####################################(DBUS)###########################################
|
####################################(DBUS)###########################################
|
||||||
@ -95,13 +95,12 @@ function errorAndExit()
|
|||||||
|
|
||||||
function usage()
|
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 "\tUsage: sudo usbinstall Arg1 Arg2 Arg3 [-y]"
|
||||||
echo -e "\tArg 1: Usb device path (es. /dev/sdc)"
|
echo -e "\tArg 1: Usb device path (e.g. /dev/sdc)"
|
||||||
echo -e "\tArg 2: Cpio.gz file (es. ~/openmamba-bootusb-it-milestone2-2.0pre8.i586.cpio.gz)"
|
echo -e "\tArg 2: Cpio.gz file (e.g. ~/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 "\tArg 3: Iso file (e.g. ~/openmamba-livecd-it-milestone2-2.0pre8.i586.iso)"
|
||||||
echo -e "\t-y: Installa senza chiedere alcuna conferma [Attenzione!]"
|
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
|
if [ "$ISKEY" = "true" ]; then # If is a usb
|
||||||
export SELECT_USB=$1
|
export SELECT_USB=$1
|
||||||
else # If not, user can choose
|
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
|
read KEY
|
||||||
case "$KEY" in
|
case "$KEY" in
|
||||||
yes)
|
yes)
|
||||||
@ -159,7 +158,7 @@ fi
|
|||||||
# Check if Arg 3 is valid
|
# Check if Arg 3 is valid
|
||||||
if [ -f "$3" ]; then # Check if is a file
|
if [ -f "$3" ]; then # Check if is a file
|
||||||
if [ -r "$3" ]; then # Chek is is readable
|
if [ -r "$3" ]; then # Chek is is readable
|
||||||
export SELECT_ISO=$3
|
SELECT_ISO=$3
|
||||||
else
|
else
|
||||||
errorAndExit "Error(Arg 3): \"$3\" is not readable" 1
|
errorAndExit "Error(Arg 3): \"$3\" is not readable" 1
|
||||||
fi
|
fi
|
||||||
@ -173,9 +172,12 @@ fi
|
|||||||
|
|
||||||
# Confirm
|
# Confirm
|
||||||
if [ "$4" = "-y" ]; then
|
if [ "$4" = "-y" ]; then
|
||||||
export CONFIRM=0
|
CONFIRM=0
|
||||||
|
elif [ "$4" = "-d" ]; then
|
||||||
|
CONFIRM=0
|
||||||
|
DBUS_USBINSTALL=1
|
||||||
else
|
else
|
||||||
export CONFIRM=1
|
CONFIRM=1
|
||||||
fi
|
fi
|
||||||
#################################(INITIAL-CHECK)#####################################
|
#################################(INITIAL-CHECK)#####################################
|
||||||
|
|
||||||
@ -242,6 +244,7 @@ if [ ! -d "$MOUNTDIR" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
set_status "Estrazione del file di boot in corso..."
|
set_status "Estrazione del file di boot in corso..."
|
||||||
|
echo "Extracting bootusb archive..."
|
||||||
pushd $MOUNTDIR >/dev/null
|
pushd $MOUNTDIR >/dev/null
|
||||||
sudo chmod 777 ./
|
sudo chmod 777 ./
|
||||||
gunzip -c $SELECT_BOOT | cpio -i
|
gunzip -c $SELECT_BOOT | cpio -i
|
||||||
@ -255,6 +258,7 @@ set_pbar 45
|
|||||||
|
|
||||||
|
|
||||||
set_status "Copia del file iso di openmamba in corso..."
|
set_status "Copia del file iso di openmamba in corso..."
|
||||||
|
echo "Copying ISO..."
|
||||||
# Copy code
|
# Copy code
|
||||||
ORIG_SIZE=`stat -c %s $SELECT_ISO`
|
ORIG_SIZE=`stat -c %s $SELECT_ISO`
|
||||||
cp $SELECT_ISO ./ &
|
cp $SELECT_ISO ./ &
|
||||||
@ -279,4 +283,5 @@ LANG=C udisks --unmount ${SELECT_USB}1 | grep failed && {
|
|||||||
exit 2
|
exit 2
|
||||||
}
|
}
|
||||||
set_pbar 100
|
set_pbar 100
|
||||||
|
echo "Done."
|
||||||
#################################(INSTALLATION)######################################
|
#################################(INSTALLATION)######################################
|
||||||
|
Loading…
Reference in New Issue
Block a user