unset LD_PRELOAD
command="/data/data/com.termux/files/usr/bin/proot"

command+=" --kill-on-exit"
command+=" --link2symlink"
command+=" --rootfs=/data/data/com.termux/files/home/.alpine"
command+=" --root-id"
command+=" --cwd=/root"
command+=" --bind=/dev"
command+=" --bind=/dev/urandom:/dev/random"
command+=" --bind=/proc"
command+=" --bind=/sys"
command+=" --bind=/data/data/com.termux/files/home/.alpine/root:/dev/shm"

[ ! -d "/data/data/com.termux/files/home/.alpine/tmp" ] && mkdir "/data/data/com.termux/files/home/.alpine/tmp"
command+=" --bind=/data/data/com.termux/files/home/.alpine/tmp:/dev/shm"
# Bind /data/data/com.termux to /
command+=" --bind=/data/data/com.termux"
# Bind /storage to /
command+=" --bind=/storage"
# Bind /sdcard to /
command+=" --bind=/storage/self/primary:/sdcard"
command+=" /usr/bin/env -i"
command+=" HOME=/root"
command+=" LANG=C.UTF-8"
command+=" TZ=Asia/Shanghai"
command+=" PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
command+=" TERM=${TERM-xterm-256color}"
command+=" TMPDIR=/tmp"
command+=" SHELL=/bin/bash"
command+=" /bin/bash --login"

com="$@"; [ -z "$1" ] && exec $command || $command -c "$com"
