motorola droid autostart fixing test thread

Gothic rose

New member
The Motorola Droid solution requires the use of u2nl and some iptables rules which are run by an app called autostart. The problem is that after it runs the script, it sits around consuming the battery.

This thread is for people who want to test out some alternate autostart.sh scripts that attempt to kill the autostart app for you and save battery life.

If you want to experiment, just download the autostart.zip file off my web site http://www.whiterabbit.org/android/ and give some of the test scripts a try. If any of them work for you please let me know in this thread. I will keep adding more scripts for people to try so go ahead and download it again later if you want to try more.

These scripts are only for the Motorola Droid on Cricket. If we find one that works, the solution will be copied to the scripts for other phones and carriers.

If you try a script and about a minute after booting you still see the autostart app running in a task killer, you can either try another script out or just replace the bad autostart.sh script with the one you were using before, which is in the u2nl.zip on my site.

Thanks to anyone who helps. I don't use cricket/u2nl/autostart or root apps, otherwise I would test it out myself.
 
I tested number 6 and it works great! I rebooted the phone twice got off and on of wifi and checked ps in between all of those and autostart was not there any of those times. Thanks! This rules! If you need any more info or testing help let me know.

Btw I was playing around with this, this morning and thought about just having the last line be "kill 0" to kill the child and parent process. Let me tell you that sent my phone into a boot loop that would cycle all the way to the end of autostart and then just shut the whole phone down. Bad idea on my part.
 
Thanks! Did you test 5? It is the same thing, but just uses kill. 6 uses kill -9. I would prefer to not use -9 unless we need it.

I've never heard of using "kill 0" as a way of killing the parent. I have always used "kill $$" for that. It looks like killing the parent isn't an option though, which is why I made my kill line in 5 and 6 actually be a mini shell script of its own that runs in the background, letting autostart.sh exit on its own, then kills the autostart android app.

Can anyone else confirm that 6 works for you? Anyone else want to try 5?

I'm glad it is working already. I was expecting it to take longer than this and didn't want to get the other thread overrun with this stuff.
 
I just tested 5 the same way and it works as well. It does however take a few extra seconds for it to kill autostart. I had to run PS twice for it not to show up. In case anyone else tests this I was waiting for the 3G icon to show up and then waiting another second before I went into term emu. Then I would run PS and it would be in there I would run PS again and it was gone. Do you need me to test anything else? Let me know if I can help with anything and thanks again especially when none of this applies to you.
 
Thanks. I think I will go with script 5 then. I'll update my u2nl.zip right now. I don't see what it could hurt even if it doesn't work for people. If for some reason it does end up having a problem, I can change it later.
 
It should. I made this change to all of the autostart.sh files in my u2nl.zip. If you test it out, please let me know if it worked for you.
 
yep it sure does, its what your using from the zip i created, im creating a new zip now with these changes.

@whiterabbit, i have flashed this to my phone and been running all day, as well as fixed up my permissions and whatnot from my update.zip file to flash from recovery and its working great.
 
i dont c the autostart.zip file w the scripts and also.. I downloaded the new u2nl.zip file w the new autostart file, the new one for metro pcs doesn't work.. i had to go back to my old script.. here it is since not even ur old one worked for me. my current working Metro PCS autostart.sh file:

#!/system/bin/sh
/system/bin/iptables -P INPUT ACCEPT
/system/bin/iptables -P OUTPUT ACCEPT
/system/bin/iptables -P FORWARD ACCEPT
/system/bin/iptables -F
/system/bin/iptables -t nat -F
/system/bin/iptables -X
/system/bin/iptables -t nat -A OUTPUT -o ppp0 -p 6 ! -d 10.223.2.4 -j REDIRECT --to-port 1025
/system/bin/u2nl 10.223.2.4 3128 127.0.0.1 1025 >/dev/null 2>&1 &
exit 0
 
oh!!! I tried to manually input the new commands but i got this error:

FIX ME! implement getprotobyname() bionic/libc/bionic/stubs.c:378tables v1.3.7: Port `' not valid

try `iptables -h' or 'iptables --help' for more information.

i forgot witch 2 command was it that got this error...
 
ok i just retested ur commands in adb and i did get internet and i got the following errors in the following parts

until ping -c 1 $PROXYHOST >/dev/null 2>&1 ; do sleep 1 ; done --->it hangs, freezes, it doesn't let me get a input a new command next

error in errors:

/system/bin/iptables -t nat -A OUTPUT -o $INTERFACE -p 6 -d $MMSIP --dport $MMSPORT -j DNAT --to-destination $MMSIP:$MMSPORT
/system/bin/iptables -t nat -A OUTPUT -o $INTERFACE -p 6 --dport 80 -j DNAT --to-destination $PROXYIP:$PROXYPORT
/system/bin/iptables -t nat -A OUTPUT -o $INTERFACE -p 6 ! -d $PROXYIP ! --dport $PROXYPORT -j REDIRECT --to-port 1025

it prompts: FIX ME! implement getprotobynumber() bionic/libc/bionic/stubs.c:384
i will post the rest of the errors later, for now i got it working w:

#!/system/bin/sh
export INTERFACE=ppp0
export PROXYHOST=wap.metropcs.net
export PROXYIP=10.223.2.4
export PROXYPORT=3128
export MMSHOST=mms.metropcs.net
export MMSIP=10.221.2.140
export MMSPORT=3128
export PATH="$PATH:/system/bin"
/system/bin/iptables -P INPUT ACCEPT
/system/bin/iptables -P OUTPUT ACCEPT
/system/bin/iptables -P FORWARD ACCEPT
/system/bin/iptables -F
/system/bin/iptables -t nat -F
/system/bin/iptables -X
/system/bin/iptables -t nat -A OUTPUT -o $INTERFACE -p 6 ! -d $PROXYIP -j REDIRECT --to-port 1025
/system/bin/u2nl $PROXYIP $PROXYPORT 127.0.0.1 1025 >/dev/null 2>&1 &
sh -c "sleep 5;kill `ps|grep nk.bla.android.autostart|grep -v grep|awk '{print $2}'`" >/dev/null 2>&1 &
exit 0
 
It should freeze up there, 15-30 seconds shouldn't be bad. More than that and there is probably a problem. Can you ping your proxy normally?

That's not an error, although it looks like one.
 
I think the current autostart script still needs work, but I'm not interested in spending a lot of time on it right now. I think it would be great if people who are interested in improving it could post here with ideas to experiment with or complaints about what isn't working.

I'll keep an eye on the thread and help out still, but don't really want to be in charge of it myself right now.

I'll start with a tip: the "until" line should be changed. Originally it would keep trying nslookup on the wap server's host name until it got a response. This meant that the network was clearly working and ready. When I learned that nslookup was broken in a lot of roms (please let your rom developers know about bugs!), I changed all nslookups into pings. Ping can be used to find a hostname reliably since there doesn't need to be a ping reply to learn the IP you were looking for, but it isn't a great way to make sure the network is up and running when you can't be sure the host will respond to a ping. There is no need for the wap server to do that, it just has to be a wap server.

So to make the script more reliable, I think the until line should be changed to this:
Code:
until netcfg|grep -v DOWN|awk '{print $1}'|grep -v wlan|grep -v lo >/dev/null 2>&1 ; do sleep 1 ; done
It would probably be a good idea to add "sleep 5" on the line below it, just to be sure the network is ready.

The best part about this change is that it is better than even the nslookup way of doing it, since if you boot up with wifi on, it will wait for you to switch back to cellular data before setting up u2nl.
 
I was testing something out on my droid that needs to run at boot, and I didn't want to use the autostart app. On a stock droid, there is a script that makes sure your bootloader is up to date which I had disabled anyway, and any modded rom will too. The path is /system/etc/install-recovery.sh.

All I had to do was create a new file with that name, and put in it:
Code:
#!/system/bin/sh
/data/opt/autostart.sh &
And I had everything I needed. Cyanogenmod roms will also execute /sd-ext/userinit.sh at boot, so on many roms, the autostart app really isn't needed.
 
Back
Top