2008-05-10 09:34:39 -06:00
|
|
|
#!/bin/sh
|
2008-04-21 09:22:00 -06:00
|
|
|
#
|
2008-05-10 09:34:39 -06:00
|
|
|
# Purpose: Perform appropriate startup of GParted executable gpartedbin.
|
|
|
|
#
|
2009-10-15 10:32:29 -06:00
|
|
|
# The purpose of these startup methods is to prevent
|
|
|
|
# devices from being automounted.
|
2008-04-21 09:22:00 -06:00
|
|
|
# File system problems can occur if devices are mounted
|
|
|
|
# prior to the completion of GParted's operations.
|
|
|
|
#
|
2009-10-15 10:32:29 -06:00
|
|
|
|
2010-06-01 17:04:39 -06:00
|
|
|
#
|
|
|
|
# Search PATH to determine if udisks program can be found
|
|
|
|
# and if appropriate daemon is running.
|
|
|
|
#
|
|
|
|
HAVE_UDISKS=no
|
|
|
|
for k in '' `echo "$PATH" | sed 's,:, ,g'`; do
|
|
|
|
if test -x "$k/udisks"; then
|
|
|
|
if test "z`ps -e | grep udisks-daemon`" != "z"; then
|
|
|
|
HAVE_UDISKS=yes
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2009-10-15 10:32:29 -06:00
|
|
|
#
|
|
|
|
# Search PATH to determine if devkit-disks program can be found
|
|
|
|
# and if appropriate daemon is running.
|
2010-06-01 17:04:39 -06:00
|
|
|
# On December 1, 2009, devkit-disks was named udisks.
|
2008-04-21 09:22:00 -06:00
|
|
|
#
|
2009-10-15 10:32:29 -06:00
|
|
|
HAVE_DEVKIT_DISKS=no
|
|
|
|
for k in '' `echo "$PATH" | sed 's,:, ,g'`; do
|
|
|
|
if test -x "$k/devkit-disks"; then
|
|
|
|
if test "z`ps -e | grep devkit-disks-da`" != "z"; then
|
|
|
|
HAVE_DEVKIT_DISKS=yes
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
2008-05-10 09:34:39 -06:00
|
|
|
|
2008-04-21 09:22:00 -06:00
|
|
|
#
|
2008-05-10 09:34:39 -06:00
|
|
|
# Search PATH to determine if hal-lock program can be found
|
2009-10-15 10:32:29 -06:00
|
|
|
# and if appropriate daemon is running.
|
2008-04-21 09:22:00 -06:00
|
|
|
#
|
2008-05-10 09:34:39 -06:00
|
|
|
HAVE_HAL_LOCK=no
|
|
|
|
for k in '' `echo "$PATH" | sed 's,:, ,g'`; do
|
|
|
|
if test -x "$k/hal-lock"; then
|
2008-07-27 09:31:34 -06:00
|
|
|
if test "z`ps -e | grep hald`" != "z"; then
|
|
|
|
HAVE_HAL_LOCK=yes
|
|
|
|
break
|
|
|
|
fi
|
2008-05-10 09:34:39 -06:00
|
|
|
fi
|
|
|
|
done
|
2008-04-21 09:22:00 -06:00
|
|
|
|
2011-02-27 11:41:40 -07:00
|
|
|
#
|
|
|
|
# Define base command for executing GParted
|
|
|
|
#
|
|
|
|
BASE_CMD="@installdir@/gpartedbin $*"
|
|
|
|
|
|
|
|
#
|
|
|
|
# If no root privileges, then invoke gpartedbin directly
|
|
|
|
# so that a graphical warning is displayed.
|
|
|
|
# Otherwise udisks, devkit-disks, or hal-lock in the later
|
|
|
|
# invocation may prevent gpartedbin from starting and hence
|
|
|
|
# the user will not see a graphical warning.
|
|
|
|
#
|
|
|
|
if test "x`id -u`" != "x0"; then
|
|
|
|
echo "Root privileges are required for running gparted."
|
|
|
|
$BASE_CMD
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2008-05-10 09:34:39 -06:00
|
|
|
#
|
2010-07-21 10:37:58 -06:00
|
|
|
# Use both udisks and hal-lock for invocation if both binaries exist and both
|
|
|
|
# daemons are running.
|
2010-07-21 10:32:06 -06:00
|
|
|
# Else use udisks if binary exists and daemon is running.
|
2010-06-01 17:04:39 -06:00
|
|
|
# Else use both devkit-disks and hal-lock for invocation if both binaries exist
|
2009-10-16 10:49:31 -06:00
|
|
|
# and both of the daemons are running.
|
2010-06-01 17:04:39 -06:00
|
|
|
# Else use devkit-disks if binary exists and daemon is running.
|
2009-10-15 10:32:29 -06:00
|
|
|
# Otherwise use hal-lock for invocation if binary exists and daemon is running.
|
|
|
|
# If the above checks fail then simply run gpartedbin.
|
2008-05-10 09:34:39 -06:00
|
|
|
#
|
2010-07-21 10:32:06 -06:00
|
|
|
if test "x$HAVE_UDISKS" = "xyes" && test "x$HAVE_HAL_LOCK" = "xyes"; then
|
|
|
|
udisks --inhibit -- \
|
|
|
|
hal-lock --interface org.freedesktop.Hal.Device.Storage --exclusive \
|
|
|
|
--run "$BASE_CMD"
|
|
|
|
elif test "x$HAVE_UDISKS" = "xyes"; then
|
2010-06-01 17:04:39 -06:00
|
|
|
udisks --inhibit -- $BASE_CMD
|
|
|
|
elif test "x$HAVE_DEVKIT_DISKS" = "xyes" && test "x$HAVE_HAL_LOCK" = "xyes"; then
|
2009-10-16 10:49:31 -06:00
|
|
|
devkit-disks --inhibit -- \
|
|
|
|
hal-lock --interface org.freedesktop.Hal.Device.Storage --exclusive \
|
|
|
|
--run "$BASE_CMD"
|
|
|
|
elif test "x$HAVE_DEVKIT_DISKS" = "xyes"; then
|
|
|
|
devkit-disks --inhibit -- $BASE_CMD
|
2009-10-15 10:32:29 -06:00
|
|
|
elif test "x$HAVE_HAL_LOCK" = "xyes"; then
|
2009-02-11 15:08:30 -07:00
|
|
|
hal-lock --interface org.freedesktop.Hal.Device.Storage --exclusive \
|
2009-10-16 10:49:31 -06:00
|
|
|
--run "$BASE_CMD"
|
2008-05-10 09:34:39 -06:00
|
|
|
else
|
2009-10-16 10:49:31 -06:00
|
|
|
$BASE_CMD
|
2008-05-10 09:34:39 -06:00
|
|
|
fi
|