This repository has been archived by the owner on Jul 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
gparted.in
99 lines (93 loc) · 2.89 KB
/
gparted.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/sh
#
# Purpose: Perform appropriate startup of GParted executable gpartedbin.
#
# The purpose of these startup methods is to prevent
# devices from being automounted.
# File system problems can occur if devices are mounted
# prior to the completion of GParted's operations.
#
#
# 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
#
# Search PATH to determine if devkit-disks program can be found
# and if appropriate daemon is running.
# On December 1, 2009, devkit-disks was named udisks.
#
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
#
# Search PATH to determine if hal-lock program can be found
# and if appropriate daemon is running.
#
HAVE_HAL_LOCK=no
for k in '' `echo "$PATH" | sed 's,:, ,g'`; do
if test -x "$k/hal-lock"; then
if test "z`ps -e | grep hald`" != "z"; then
HAVE_HAL_LOCK=yes
break
fi
fi
done
#
# 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
#
# Use both udisks and hal-lock for invocation if both binaries exist and both
# daemons are running.
# Else use udisks if binary exists and daemon is running.
# Else use both devkit-disks and hal-lock for invocation if both binaries exist
# and both of the daemons are running.
# Else use devkit-disks if binary exists and daemon is running.
# Otherwise use hal-lock for invocation if binary exists and daemon is running.
# If the above checks fail then simply run gpartedbin.
#
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
udisks --inhibit -- $BASE_CMD
elif test "x$HAVE_DEVKIT_DISKS" = "xyes" && test "x$HAVE_HAL_LOCK" = "xyes"; then
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
elif test "x$HAVE_HAL_LOCK" = "xyes"; then
hal-lock --interface org.freedesktop.Hal.Device.Storage --exclusive \
--run "$BASE_CMD"
else
$BASE_CMD
fi