install.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233
  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. )
  11. }
  12. copy_scripts () {
  13. sed "s/AGENCY_ID/${1}/g" exec.sh.in > exec.sh
  14. adb push exec.sh /sdcard/wechat/exec.sh
  15. adb push crontab /sdcard/
  16. adb push start.sh /sdcard/start.sh
  17. adb shell "su - [ -d /data/data/com.termux/files/home ]"
  18. if [ "$?" = "1" ]; then
  19. read -p "Launch Termux for its bootstraping, press any key when completed"
  20. fi
  21. adb shell 'su - mv -f /sdcard/start.sh /data/data/com.termux/files/home/start.sh'
  22. adb shell 'su - chmod 555 /data/data/com.termux/files/home/start.sh'
  23. echo "Final step: install Busybox MANUALLY and execute ./start.sh in Termux at every time startup"
  24. }
  25. HAS_DEVICE=`adb devices|wc -l|xargs`
  26. if [ "$HAS_DEVICE" = "3" ]; then
  27. echo "Good, a device has been detected"
  28. install_tools
  29. read -p 'AGENCY_ID: ' AGENCY_ID
  30. copy_scripts $AGENCY_ID
  31. else
  32. echo "`adb devices` did not show exactly one device, check and try again"
  33. fi