install.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # install tools
  2. install_tools () {
  3. echo "Installing tools, you MAY grant the operation by click the button..."
  4. sleep 2
  5. set -e
  6. (
  7. set -x
  8. adb install -r apk/Termux_v0.118.0_apkpure.com.apk
  9. adb install -r apk/ru.meefik.busybox_46.apk
  10. adb install -r apk/com.termux.boot_7.apk
  11. )
  12. }
  13. setup_auto_boot () {
  14. echo "Setup experimental Termux:boot for auto-start"
  15. set -e
  16. (
  17. set -x
  18. TX_UID=`adb shell su - stat -c "%U" /data/data/com.termux/files/home|xargs`
  19. adb shell 'su - mkdir -p /data/data/com.termux/files/home/.termux/boot/'
  20. adb shell 'su - mv -f /sdcard/crond.sh /data/data/com.termux/files/home/.termux/boot/'
  21. adb shell 'su - chmod 555 /data/data/com.termux/files/home/.termux/boot/crond.sh'
  22. adb shell "su - chown -R ${TX_UID}:${TX_UID} /data/data/com.termux/files/home/.termux/boot"
  23. )
  24. echo "Success, launch Termux:boot once to activiate it."
  25. }
  26. copy_scripts () {
  27. set -e
  28. adb push exec.sh.in /sdcard/wechat/exec.sh
  29. adb push crontab /sdcard/
  30. adb push start.sh /sdcard/start.sh
  31. adb push start_fg.sh /sdcard/crond.sh
  32. set +e
  33. adb shell "su - [ -d /data/data/com.termux/files/home ]"
  34. if [ "$?" != "0" ]; then
  35. read -p "Launch Termux for its bootstraping, press any key when completed"
  36. fi
  37. set -e
  38. adb shell 'su - mv -f /sdcard/start.sh /data/data/com.termux/files/home/start.sh'
  39. adb shell 'su - chmod 555 /data/data/com.termux/files/home/start.sh'
  40. echo "Final step: install Busybox MANUALLY and execute ./start.sh in Termux at every time startup"
  41. setup_auto_boot
  42. }
  43. HAS_DEVICE=`adb devices|wc -l|xargs`
  44. if [ "$HAS_DEVICE" = "3" ]; then
  45. echo "Good, a device has been detected"
  46. install_tools
  47. copy_scripts
  48. else
  49. echo "`adb devices` did not show exactly one device, check and try again"
  50. fi