I managed to initiate Linux on my Android phone through the terminal and even start the SSH service and tested it using ConnectBot. However, this is a manual operation. I was thinking more of an automated way of doing this.
I used this Linux mechanism: http://mitchtech.net/android-backtrack-chroot/
My main issue I believe is that I'm trying to do some steps before and after chroot is done, which didn't seem to work on an Android app:
Runtime.getRuntime().exec("su");
//Mount the image
Runtime.getRuntime().exec("startbt");
//chroot into Linux
Runtime.getRuntime().exec("bt");
//From inside chroot, start the ssh service
Runtime.getRuntime().exec("/etc/init.d/ssh start");
This also did not seem to work:
Runtime.getRuntime().exec("su & startbt & bt & /etc/init.d/ssh start");
I'm guessing again this is an issue what is interpreted as inside or outside the chroot. My main quest eventually is to start the SSH service automatically, not necessarily through an Android app.
If you execute
this will just launch
suand then exit. The next exec won't be executed with elevated privileges. Likewise after executingbtthe next command isn't executed within the chroot environment.I presume
btis a script? You could change it to pass arguments tochroot, so you can pass it the command to execute, something like:To run this, you need to pass the command to
sudirectly using the-coption. And you need to pass the commands as String array (or use aProcessBuilder):Another option would be to make
btpass arguments from the command line to chroot:and then pass them on the command line: