termux-tools: add login hook for running commands before shell is launched

This commit is contained in:
Leonid Pliushch 2021-10-13 14:09:24 +03:00
parent 5a05be5d99
commit 287d50889a
No known key found for this signature in database
GPG Key ID: 45F2964132545795
2 changed files with 15 additions and 2 deletions

View File

@ -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
}

View File

@ -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