From 6bb30dc5a47157c2c5793e31e9f89fc2ede38f6b Mon Sep 17 00:00:00 2001 From: Dave Hodgins Date: Mon, 7 Oct 2013 19:27:54 -0400 Subject: mv script from /sbin to bin, and run pkexec from it, instead of using seperate script --- bin/copyiso2usb | 4 ---- copyiso2usb | 31 +++++++++++++++---------------- 2 files changed, 15 insertions(+), 20 deletions(-) delete mode 100755 bin/copyiso2usb diff --git a/bin/copyiso2usb b/bin/copyiso2usb deleted file mode 100755 index 6e89dee..0000000 --- a/bin/copyiso2usb +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -pkexec '/usr/sbin/copyiso2usb' "$@" - diff --git a/copyiso2usb b/copyiso2usb index a0fa253..7ccb82c 100755 --- a/copyiso2usb +++ b/copyiso2usb @@ -1,6 +1,6 @@ #!/bin/bash ######################################################################################## -# /usr/sbin/copyiso2usb +# /usr/bin/copyiso2usb ######################################################################################## # Usage: copyiso2usb [isofile] # Installs needed packages if missing - dcfldd cdialog udisks mlocate @@ -13,11 +13,8 @@ # Confirms that the command should be run # Copies the iso image to the usb drive. # -# Note for maintainers 'xgettext -d copyiso2usb -L Shell /usr/sbin/copyiso2usb' used +# Note for maintainers 'xgettext -d copyiso2usb -L Shell /usr/bin/copyiso2usb' used # to create copyiso2usb.po (which was manually renamed to copyiso2usb.pot) -# -# If installing manually, also suggest installing Xdialog and runnning -# 'ln -s /usr/bin/consolehelper /usr/sbin/copyiso2usb' ######################################################################################## # Author: David W. Hodgins - Mageia Qa team # 2013-06-02 Initial writing @@ -42,6 +39,19 @@ Waitmlocate=$(gettext "Running /etc/cron.daily/mlocate.cron. Please wait for 'rc WaitCopy=$(gettext "Copying iso to usb drive. Please wait for 'rc=0' before continuing.") FileNameTemp=$(mktemp -p /tmp "${0##*/}".XXXXXX) +ThisScript="$0" +if [[ ! ${ThisScript:0:1} = '/' ]] ; then + ThisScript="$(pwd)/$0" +fi + +# Exit if not root. +if [[ "$(id -u)" != "0" ]] ; then + exec pkexec "$ThisScript" "$@" + MustBeRoot=$(eval_gettext "Must be root to run \$ThisScript") + ShowMsgExit "$MustBeRoot" + exit 0 +fi + #Check to see if running under pkexec, aka policykit and X pktest=${PKEXEC_UID-"unset"} if [ ! "unset" = "$pktest" ] ; then @@ -60,11 +70,6 @@ if [ ! -e /usr/bin/Xdialog ] || [ ! -x /usr/bin/Xdialog ] || [ "unset" = "$disp dialogcmd="/usr/bin/dialog" fi -ThisScript="$0" -if [[ ! ${ThisScript:0:1} = '/' ]] ; then - ThisScript="$(pwd)/$0" -fi - # Function to get window size GetDisplaySize() { IFS=$':, ' @@ -165,12 +170,6 @@ setspaceunits () { printf '%s' "$SpaceString" } -# Exit if not root. -if [[ "$(id -u)" != "0" ]] ; then - MustBeRoot=$(eval_gettext "Must be root to run \$ThisScript") - ShowMsgExit "$MustBeRoot" - exit 0 -fi InstallPackageIfFileMissing /usr/bin/dcfldd dcfldd InstallPackageIfFileMissing /usr/bin/dialog cdialog -- cgit v1.2.1