summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatías Fonzo <[email protected]>2020-02-07 15:53:56 -0300
committerSlávek Banko <[email protected]>2020-02-10 20:14:51 +0100
commit410b580b17d06909281c55d6e6f6441a108e0dd9 (patch)
tree3cf6d40606e6b169acbaa3e4a19eca5f296d49f3
parent670087710a7af6f1c504db0ff84763cfcf15aed9 (diff)
downloadtdebase-410b580b17d06909281c55d6e6f6441a108e0dd9.tar.gz
tdebase-410b580b17d06909281c55d6e6f6441a108e0dd9.zip
starttde: Enhance startup script location
It was originally resolved by following the symbolic links to determine the location of the startup script. Mostly adjusted for Debian distributions and derivatives that have support for "alternatives". This doesn't work for distributions that install TDE under a self-contained directory (distros like Dragora, Guix or simply users that use Graft or GNU Stow tools). Also projects like GSRC... This code has been improved to cover these cases, also minimizing the compatibility impact for the readlink command (non-standard) by eliminating the use of options for greater compatibility, as some systems do not have the -e or -f options, as they may also have different behavior (between systems). Signed-off-by: Matías Fonzo <[email protected]> (cherry picked from commit b5f293f9437b4af567248d6cfc269fe8a0216391)
-rwxr-xr-xstarttde28
1 files changed, 23 insertions, 5 deletions
diff --git a/starttde b/starttde
index 846b8563c..899bdfa9c 100755
--- a/starttde
+++ b/starttde
@@ -87,11 +87,28 @@ echo "[starttde] This script is $0" 1>&2
# To determine that location use the following method rather than presuming
# the existence of $TDEDIR. That environment variable might not be
# defined or defined to point to KDE4 binaries.
-BIN_DIR="`dirname \`readlink -f $0\``"
-if [ -x $BIN_DIR/tde-config ]; then
- TDE_VERSION=$($BIN_DIR/tde-config --version | while IFS=: read a b; do [ "${a#TDE}" != "$a" ] && echo $b; done)
+BIN_DIR=""
+
+# Let's check if this script is called from the Debian alternatives
+# See: https://wiki.debian.org/DebianAlternatives
+if [ "$(readlink -- "$0")" = "/etc/alternatives/x-session-manager" ]
+then
+ # Check if it is not a dangling symlink
+ if [ -L "/etc/alternatives/x-session-manager" ] && \
+ [ -e "/etc/alternatives/x-session-manager" ]
+ then
+ # Determine location by reading the alternative symlink
+ BIN_DIR="$(readlink -- "/etc/alternatives/x-session-manager")"
+ BIN_DIR="$(dirname -- "$BIN_DIR")"
+ fi
+fi
+# Assign a default value if 'BIN_DIR' is unset or null
+BIN_DIR="${BIN_DIR:=$(dirname -- "$0")}"
+
+if [ -x ${BIN_DIR}/tde-config ]; then
+ TDE_VERSION="$( ${BIN_DIR}/tde-config --version | sed -n 's|^TDE: ||p' )"
+ TDEDIR="${BIN_DIR%/bin}"
echo "[starttde] TDE version is $TDE_VERSION" 1>&2
- export TDEDIR=${BIN_DIR%/bin}
echo "[starttde] TDE base directory is $TDEDIR" 1>&2
else
echo "[starttde] Unable to determine the TDE bin directory, where this script should be installed."
@@ -99,7 +116,8 @@ else
echo "[starttde] Exiting."
exit 1
fi
-unset BIN_DIR
+unset BIN_DIR TDE_VERSION
+export TDEDIR
# When the X server dies we get a HUP signal from xinit. We must ignore it
# because we still need to do some cleanup.