# install tools install_tools () { echo "Installing tools, you MAY grant the operation by click the button..." sleep 2 set -e ( set -x adb install -r apk/Termux_v0.118.0_apkpure.com.apk adb install -r apk/ru.meefik.busybox_46.apk adb install -r apk/com.termux.boot_7.apk ) } setup_auto_boot () { echo "Setup experimental Termux:boot for auto-start" set -e ( set -x TX_UID=`adb shell su - stat -c "%U" /data/data/com.termux/files/home|xargs` adb shell 'su - mkdir -p /data/data/com.termux/files/home/.termux/boot/' adb shell 'su - mv -f /sdcard/crond.sh /data/data/com.termux/files/home/.termux/boot/' adb shell 'su - chmod 555 /data/data/com.termux/files/home/.termux/boot/crond.sh' adb shell "su - chown -R ${TX_UID}:${TX_UID} /data/data/com.termux/files/home/.termux/boot" ) echo "Success, launch Termux:boot once to activiate it." } copy_scripts () { set -e adb push exec.sh.in /sdcard/wechat/exec.sh adb push crontab /sdcard/ adb push start.sh /sdcard/start.sh adb push start_fg.sh /sdcard/crond.sh set +e adb shell "su - [ -d /data/data/com.termux/files/home ]" if [ "$?" != "0" ]; then read -p "Launch Termux for its bootstraping, press any key when completed" fi set -e adb shell 'su - mv -f /sdcard/start.sh /data/data/com.termux/files/home/start.sh' adb shell 'su - chmod 555 /data/data/com.termux/files/home/start.sh' echo "Final step: install Busybox MANUALLY and execute ./start.sh in Termux at every time startup" setup_auto_boot } HAS_DEVICE=`adb devices|wc -l|xargs` if [ "$HAS_DEVICE" = "3" ]; then echo "Good, a device has been detected" install_tools copy_scripts else echo "`adb devices` did not show exactly one device, check and try again" fi