Add usbinstall.sh in sudoers
This commit is contained in:
parent
6a9f8d584d
commit
3dca414f8c
6
Makefile
6
Makefile
@ -11,6 +11,7 @@ dist_archive := $(distdir).tar.bz2
|
|||||||
|
|
||||||
# Directory
|
# Directory
|
||||||
bindir := /usr/bin
|
bindir := /usr/bin
|
||||||
|
sysconfdir := /etc
|
||||||
datadir := /usr/share
|
datadir := /usr/share
|
||||||
mambadir := /usr/share/openmamba
|
mambadir := /usr/share/openmamba
|
||||||
localesdir := ${datadir}/locale
|
localesdir := ${datadir}/locale
|
||||||
@ -46,16 +47,17 @@ install-dirs:
|
|||||||
@$(INSTALL_DIR) $(DESTDIR)$(bindir)
|
@$(INSTALL_DIR) $(DESTDIR)$(bindir)
|
||||||
@$(INSTALL_DIR) $(DESTDIR)$(mambadir)/usbinstall
|
@$(INSTALL_DIR) $(DESTDIR)$(mambadir)/usbinstall
|
||||||
@$(INSTALL_DIR) $(DESTDIR)$(mambadir)/usbinstall/img
|
@$(INSTALL_DIR) $(DESTDIR)$(mambadir)/usbinstall/img
|
||||||
|
@$(INSTALL_DIR) $(DESTDIR)$(sysconfdir)/sudoers.d/
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
$(INSTALL_SCRIPT) src/usbinstall.sh $(DESTDIR)$(mambadir)/usbinstall/usbinstall.sh
|
$(INSTALL_SCRIPT) src/usbinstall.sh $(DESTDIR)$(bindir)/usbinstall.sh
|
||||||
$(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} -m 440 src/usbinstall-sudoers $(DESTDIR)$(sysconfdir)/sudoers.d/usbinstall
|
||||||
# Crea un link in /usr/bin agli eseguibili in $(mambadir)/usbinstall
|
# Crea un link in /usr/bin agli eseguibili in $(mambadir)/usbinstall
|
||||||
ln -s $(mambadir)/usbinstall/usbinstall.py $(DESTDIR)$(bindir)/usbinstall.py
|
ln -s $(mambadir)/usbinstall/usbinstall.py $(DESTDIR)$(bindir)/usbinstall.py
|
||||||
ln -s $(mambadir)/usbinstall/usbinstall.sh $(DESTDIR)$(bindir)/usbinstall.sh
|
|
||||||
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
11
src/usbinstall-sudoers
Normal file
11
src/usbinstall-sudoers
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# usbinstall sudoers.d file.
|
||||||
|
#
|
||||||
|
# This file MUST be edited with the 'visudo' command as root.
|
||||||
|
#
|
||||||
|
# See the sudoers man page for the details on how to write a sudoers file.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Cmnd alias specification
|
||||||
|
Cmnd_Alias USBINSTALL = /usr/bin/usbinstall.sh
|
||||||
|
|
||||||
|
%sysadmin ALL = NOPASSWD: USBINSTALL
|
5
src/usbinstall.py
Normal file → Executable file
5
src/usbinstall.py
Normal file → Executable file
@ -1,5 +1,5 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
# Copyright 2011 michiamophil (openmamba user :-)
|
# Copyright 2011 michiamophil (openmamba user :-)
|
||||||
# ChangeLog:
|
# ChangeLog:
|
||||||
@ -368,7 +368,8 @@ def step4():
|
|||||||
# Show the progressBar
|
# Show the progressBar
|
||||||
window.p_install.show()
|
window.p_install.show()
|
||||||
dbus_start()
|
dbus_start()
|
||||||
process_sh = Popen(["/usr/bin/usbinstall.sh", "start", path_dev, path_cpio, path_iso])
|
# NON FUNZIONA...
|
||||||
|
process_sh = Popen(["sudo", "/usr/bin/usbinstall.sh", path_dev, path_cpio, path_iso], env={"DBUS_USBINSTALL": "1"})
|
||||||
|
|
||||||
|
|
||||||
# Show a list of object (step 1 and 2)
|
# Show a list of object (step 1 and 2)
|
||||||
|
@ -53,18 +53,22 @@ org.freedesktop.DBus.Properties.Get string:$3 string:$4`
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Set progressbar
|
# Set progressbar (only if $DBUS_USBINSTALL = 1)
|
||||||
# Arg 1: value%
|
# Arg 1: value%
|
||||||
set_pbar()
|
set_pbar()
|
||||||
{
|
{
|
||||||
dbus-send --print-reply --session --dest=org.openmamba.usbinstall /org/openmamba/usbinstall org.openmamba.usbinstall.Set_progressBar int32:$1
|
if [ $DBUS_USBINSTALL == 1 ]; then
|
||||||
|
dbus-send --print-reply --session --dest=org.openmamba.usbinstall /org/openmamba/usbinstall org.openmamba.usbinstall.Set_progressBar int32:$1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Set status label
|
# Set status label
|
||||||
# Arg 1: string
|
# Arg 1: string
|
||||||
set_status()
|
set_status()
|
||||||
{
|
{
|
||||||
dbus-send --print-reply --session --dest=org.openmamba.usbinstall /org/openmamba/usbinstall org.openmamba.usbinstall.Set_description "string:$1"
|
if [ $DBUS_USBINSTALL == 1 ]; then
|
||||||
|
dbus-send --print-reply --session --dest=org.openmamba.usbinstall /org/openmamba/usbinstall org.openmamba.usbinstall.Set_description "string:$1"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
####################################(DBUS)###########################################
|
####################################(DBUS)###########################################
|
||||||
|
|
||||||
@ -78,7 +82,6 @@ export SELECT_USB=$1
|
|||||||
export SELECT_BOOT=$2
|
export SELECT_BOOT=$2
|
||||||
export SELECT_ISO=$3
|
export SELECT_ISO=$3
|
||||||
|
|
||||||
|
|
||||||
set_status "Smonto la chiavetta"
|
set_status "Smonto la chiavetta"
|
||||||
LANG=C 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)"
|
echo "Error: fail to umount the usb key (${SELECT_USB}1)"
|
||||||
@ -118,11 +121,11 @@ set_status "Copia del file iso di openmamba in corso..."
|
|||||||
ORIG_SIZE=`stat -c %s $SELECT_ISO`
|
ORIG_SIZE=`stat -c %s $SELECT_ISO`
|
||||||
cp $SELECT_ISO ./ &
|
cp $SELECT_ISO ./ &
|
||||||
DEST_SIZE=0
|
DEST_SIZE=0
|
||||||
sleep 2
|
|
||||||
while [ $ORIG_SIZE -gt $DEST_SIZE ]; do
|
while [ $ORIG_SIZE -gt $DEST_SIZE ]; do
|
||||||
DEST_SIZE=$(stat -c %s ./"`basename $SELECT_ISO`")
|
DEST_SIZE=$(stat -c %s ./"`basename $SELECT_ISO`")
|
||||||
percentuale=$((45 + ( 50 * $DEST_SIZE ) / $ORIG_SIZE ))
|
percentuale=$((45 + ( 50 * $DEST_SIZE ) / $ORIG_SIZE ))
|
||||||
set_pbar $percentuale
|
set_pbar $percentuale
|
||||||
|
sleep 2
|
||||||
done
|
done
|
||||||
ln -fs `basename $SELECT_ISO` ./openmamba-live.iso
|
ln -fs `basename $SELECT_ISO` ./openmamba-live.iso
|
||||||
popd
|
popd
|
||||||
|
Loading…
Reference in New Issue
Block a user