From 287d50889a6d9dbe062f14a8a3d6a821b54c9fee Mon Sep 17 00:00:00 2001 From: Leonid Pliushch Date: Wed, 13 Oct 2021 14:09:24 +0300 Subject: [PATCH] termux-tools: add login hook for running commands before shell is launched --- packages/termux-tools/build.sh | 13 +++++++++++-- packages/termux-tools/login | 4 ++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/termux-tools/build.sh b/packages/termux-tools/build.sh index 58b15fad3..f6d190922 100644 --- a/packages/termux-tools/build.sh +++ b/packages/termux-tools/build.sh @@ -9,8 +9,11 @@ TERMUX_PKG_ESSENTIAL=true TERMUX_PKG_BREAKS="termux-keyring (<< 1.9)" TERMUX_PKG_CONFLICTS="procps (<< 3.3.15-2)" TERMUX_PKG_SUGGESTS="termux-api" -TERMUX_PKG_CONFFILES="etc/motd -etc/motd-playstore" +TERMUX_PKG_CONFFILES=" +etc/motd +etc/motd-playstore +etc/termux-login.sh +" # Some of these packages are not dependencies and used only to ensure # that core packages are installed after upgrading (we removed busybox @@ -68,4 +71,10 @@ termux_step_make_install() { cp $TERMUX_PREFIX/share/examples/termux/termux.properties $TERMUX_ANDROID_HOME/.termux/ fi EOF + + cat <<- EOF > $TERMUX_PREFIX/etc/termux-login.sh + ## + ## This script is sourced by $PREFIX/bin/login before executing shell. + ## + EOF } diff --git a/packages/termux-tools/login b/packages/termux-tools/login index 757a67694..57c5b21ce 100755 --- a/packages/termux-tools/login +++ b/packages/termux-tools/login @@ -28,6 +28,10 @@ if [ -f @TERMUX_PREFIX@/lib/libtermux-exec.so ]; then $SHELL -c "coreutils --coreutils-prog=true" > /dev/null 2>&1 || unset LD_PRELOAD fi +if [ -f @TERMUX_PREFIX@/etc/termux-login.sh ]; then + . @TERMUX_PREFIX@/etc/termux-login.sh +fi + if [ -n "$TERM" ]; then exec "$SHELL" -l "$@" else