Running by hand,
adb shell
su
chmod 666 /dev/graphics/fb0
export CLASSPATH=/data/local/device.jar
export LD_LIBRARY_PATH=/data/local
exec app_process /system/bin com.device.client.Main /data/local/device.conf &
Performs as expected.
However, trying to run this from a bash script using the following command does not work as expected.
adb shell "su -c '
chmod 666 /dev/graphics/fb0
&& export CLASSPATH=/data/local/device.jar
&& export LD_LIBRARY_PATH=/data/local
&& exec app_process /system/bin com.device.client.Main /data/local/device.conf &'"
It works without &, but with & it just won't start the binary. exec app_process has to be a background process.
It's possible that the shell executes the binary but then just dies, because it does not wait on anything else, but I don't know how to fix it. Making su a background process should do it, '&" but it didn't work.
When running without &, we get:
D/su ( 1728): 0 /system/bin/sh executing 0
D/su ( 1728): chmod 666 /dev/graphics/fb0
D/su ( 1728): && export CLASSPATH=/data/local/device.jar
D/su ( 1728): && export LD_LIBRARY_PATH=/data/local
D/su ( 1728): && exec app_process /system/bin com.device.client.Main /data/local/device.conf using shell /system/bin/sh : sh
When adding &, we get:
D/su ( 1746): 0 /system/bin/sh executing 0
D/su ( 1746): chmod 666 /dev/graphics/fb0
D/su ( 1746): && export CLASSPATH=/data/local/device.jar
D/su ( 1746): && export LD_LIBRARY_PATH=/data/local
D/su ( 1746): && exec app_process /system/bin com.device.client.Main /data/local/device.conf & using shell /system/bin/sh : sh
but nothing gets loaded!
How can I run my set of commands, ensuring that app_process will run in the background?
I don't have adb
(its an old debugger right) but a good syntax for passing a set of commands to the su
command is:
su -c bash <<END_BASH
chmod 666 /dev/graphics/fb0
export CLASSPATH=/data/local/device.jar
export LD_LIBRARY_PATH=/data/local
exec app_process /system/bin com.device.client.Main /data/local/device.conf &
END_BASH