Last active
May 25, 2024 22:00
-
-
Save cswl/cd13971e644dc5ced7b2 to your computer and use it in GitHub Desktop.
DEPRECATED: Use https://github.com/cswl/tsu instead.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/data/data/com.termux/files/usr/bin/sh | |
# sudo for Termux | |
# For security reasons some environent variables are reset by su | |
# So we need to set LD_LIBRARY_PATH | |
# Root's HOME is set to 'termux's home/.suroot'. | |
# Startup files and other stuffs can be added there. | |
ROOT_HOME=$HOME/.suroot | |
case "$1" in | |
'-') | |
# check if user has set shell | |
if test -x "$HOME/.termux/shell" ; then | |
ROOT_SHELL=$HOME/.termux/shell | |
# has installed bash? | |
elif test -x "$PREFIX/bin/bash" ; then | |
ROOT_SHELL="$PREFIX/bin/bash" | |
# no..fallback to default ash. | |
else | |
ROOT_SHELL="$PREFIX/bin/ash" | |
fi | |
exec su -c "LD_LIBRARY_PATH=$PREFIX/lib HOME=$ROOT_HOME $ROOT_SHELL" | |
;; | |
''|'--help') | |
echo 'Sets up environment to allow termux programs to run with root access' | |
echo 'Not the sudo as found in other *nixes' | |
echo | |
echo 'Usage: sudo [-|cmd args]' | |
echo '- : Try to start a shell of termux as root shell. su by default runs /system/bin/sh.' | |
echo 'cmd : Run termux program with args as root.' | |
;; | |
*) | |
exec su -c "LD_LIBRARY_PATH=$PREFIX/lib HOME=$ROOT_HOME ${@}"; | |
;; | |
esac | |
hello, i tried installing it but it says sudo requires su
No such file or directory
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
fix usaage