-
-
Save killerbees19/7aa8f4af2eed34d8addc1f399459f1b1 to your computer and use it in GitHub Desktop.
run termux programs as root..
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 need to set LD_LIBRARY_PATH again | |
# root's HOME is set to termux's home/.suroot. You can add bashrc 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=/data/data/com.termux/files/usr/lib HOME=$ROOT_HOME $ROOT_SHELL" | |
;; | |
''|'-h'|'--help') | |
echo 'Sets up environment to allow termux programs to run with root access. Not the sudo as found in other *nixes' | |
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=/data/data/com.termux/files/usr/lib HOME=$ROOT_HOME ${@}"; | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment