[webtop] Using cellular network without jumping through hoops - Atrix 4G Android Development

Upfronts: I'm using NottachTrix 1.3.1 with the 2.3.6 Webtop. I'm also a programmer and a network administrator, so I might be a little more comfortable poking around in things that might break my phone than other users. Don't do anything you aren't comfortable with! I'm just reporting my findings. Your phone, your comfort level, your business!
I wanted to get my new lapdock to use the cellular network without jumping through any "enable/disable mobile hotspot" hoops. I finally got all the webtop2sd stuff running, including a working lxterminal and synaptic. I was running synaptic as root from a bash shell ("sudo bash" to give me a root shell, other commands as needed). I noticed that synaptic worked without wifi but firefox didn't. I could also ping various websites with no trouble under the root shell, but the adas user could not. adas COULD ping IP addresses, though, so it seemed like there was a firewall in place that was blocking adas from resolving domain names.
As it turns out, there is a firewall in place that is blocking the adas user from resolving domain names.
Webtop seems to be using iptables to restrict access to the default login user. I typed "iptables -L" to view all the iptables-based firewalling that was going on. Sure enough, three entries existed to block network traffic for the user "adas". After an "iptables -S" to get the commands that were used to turn on the filtering, I was able to reverse the process. (Hint: -A adds a rule, -D deletes one)
From here, I could do a lot of things -- create a script to disable iptables on demand, block the commands from running in the first place, dance a happy little jig... I won't embarrass myself by revealing which I actually did, but hopefully there's enough in this post that will help others resolve their problems in a similar manner!
(By the way, every time the phone is docked, it re-blocks network access, apparently using a file called "syslog-restart".)

If you could fix this would be great, I have the same rom and everything and I use my LapDock in my business and it is always a pain to make it connect and most of the times it fails to connect for me.
Cheers

The following presumes a working lxterminal and synaptic (or apt-get). If you haven't run the webtopscripts to fix the broken dependencies, now's a good time to poke that bear*.
(Type the stuff that's in bold -- comments are in italics)
In lxterminal:
sudo apt-get install nano (Command-line text editor)
iptables -S (generates a list of rules that iptables is currently using)
copy any lines in the "-P OUTPUT ACCEPT" section that start with "-A"
create a new file in nano by typing nano fwdisable.sh
at the top of the new document, type #!/bin/bash and press Enter
paste the copied lines into the resulting screen
insert iptables at the start of each line and change "-A" to "-D" (A for add, D for delete)
once the file looks the way you think it should, exit the program with CTRL-X, saving the file when it asks
at the command prompt, type chmod 755 fwdisable.sh
run your new shell script with sudo ./fwdisable.sh
open up a web browser and enjoy!
* Please don't poke any bears. While they may look fluffy, they react poorly to being poked. There's probably a good metaphor about messing around in the internals of your phone in there somewhere, but for the life of me I just can't find it!

Did you guys can edit a ROM that has it all in a matter of WebTop, I can not make it work on my Atrix in any way.
I do not have the device only the HDMI cable.

Trying to save fwdisable.sh nano give me following error
"Error writing fwdisable.sh Read-only file system"
Please advise

pederb said:
Trying to save fwdisable.sh nano give me following error
"Error writing fwdisable.sh Read-only file system"
Please advise
Click to expand...
Click to collapse
Sounds like you're not root or su
Sent from my MB860 using Tapatalk 2

Ok the drive was write protected, but now I get
" ./fwdisable.sh: line 2: -D: command not found"
" ./fwdisable.sh: line 3: -D: command not found"
I was not able to get it to work with Nano so I used gedit instead but should not make a difference, right?
Any idea?

maybe someone can create a flashable fix so that its easy for some of us noobs lol

studean said:
The following presumes a working lxterminal and synaptic (or apt-get). If you haven't run the webtopscripts to fix the broken dependencies, now's a good time to poke that bear*.
(Type the stuff that's in bold -- comments are in italics)
In lxterminal:
sudo apt-get install nano (Command-line text editor)
iptables -S (generates a list of rules that iptables is currently using)
copy any lines in the "-P OUTPUT ACCEPT" section that start with "-A"
create a new file in nano by typing nano fwdisable.sh
at the top of the new document, type #!/bin/bash and press Enter
paste the copied lines into the resulting screen
insert iptables at the start of each line and change "-A" to "-D" (A for add, D for delete)
once the file looks the way you think it should, exit the program with CTRL-X, saving the file when it asks
at the command prompt, type chmod 755 fwdisable.sh
run your new shell script with sudo ./fwdisable.sh
open up a web browser and enjoy!
* Please don't poke any bears. While they may look fluffy, they react poorly to being poked. There's probably a good metaphor about messing around in the internals of your phone in there somewhere, but for the life of me I just can't find it!
Click to expand...
Click to collapse
Follow this guide guys, it is ridiculously easy, no flashing needed.
I also added a button to the AWN dock with the command:
sudo ./fwdisable.sh
Which will give you one click disabling of the firewall. It will restart the firewall each time you dock/undock it appears, so just dock it, click the firewall disable button and you are good to go.

Norcalz71 said:
Follow this guide guys, it is ridiculously easy, no flashing needed.
I also added a button to the AWN dock with the command:
sudo ./fwdisable.sh
Which will give you one click disabling of the firewall. It will restart the firewall each time you dock/undock it appears, so just dock it, click the firewall disable button and you are good to go.
Click to expand...
Click to collapse
Well I'm still getting my error no matter how many time I try it again

man i cant even get webtop2sd to work. as soon as i run it on my phone it force closes. i havent even got it to open longer then super user request yet.
fingers crossed on a cwm flashable lol.

Thanks for this. I was wondering why apt-get update would work but adas couldn't ping out properly over 3g.
Also, thank you for the walk through in editing iptables there. Interesting that they chose to use that over something more proprietary, or well hidden.

I had this problem at first, too -- I think it was busybox-related. There's a busybox updater or two in the Market (I mean, "Play Store") that will bring you up to speed and let you install webtop2sd.

Sorry it's been so long since my last post! It appears that you didn't insert an "iptables " before the "-D". Check to make sure that each line after the "#!/bin/bash" starts with "iptables -D" instead of just "-D" and see if that takes care of the problem. (Also make sure you execute the script with a "sudo" -- iptables won't work properly as a regular user...)

studean said:
Sorry it's been so long since my last post! It appears that you didn't insert an "iptables " before the "-D". Check to make sure that each line after the "#!/bin/bash" starts with "iptables -D" instead of just "-D" and see if that takes care of the problem. (Also make sure you execute the script with a "sudo" -- iptables won't work properly as a regular user...)
Click to expand...
Click to collapse
should it be,
iptables -D
or
-D iptables
[email protected]:/$ sudo iptables -S
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
FATAL: Could not load /lib/modules/2.6.32.56-MB860-faux123-GB-024/modules.dep: No such file or directory
FATAL: Could not load /lib/modules/2.6.32.56-MB860-faux123-GB-024/modules.dep: No such file or directory
-A OUTPUT -d 127.0.0.1/32 -p tcp -m tcp --dport 8086 -m owner ! --uid-owner adas -j REJECT --reject-with icmp-port-unreachable
-A OUTPUT -d 127.0.0.1/32 -p tcp -m tcp --dport 8085 -m owner ! --uid-owner adas -j REJECT --reject-with icmp-port-unreachable
This is how it looks before editing

It should be "iptables -D". Based on the output from your "iptables -S" command, the file should look like this:
Code:
#/bin/bash
iptables -D OUTPUT -d 127.0.0.1/32 -p tcp -m tcp --dport 8086 -m owner ! --uid-owner adas -j REJECT --reject-with icmp-port-unreachable
iptables -D OUTPUT -d 127.0.0.1/32 -p tcp -m tcp --dport 8085 -m owner ! --uid-owner adas -j REJECT --reject-with icmp-port-unreachable
I also had a third line (that escapes me at the moment -- I'm on a different machine) that further blocked access, but apparently there is a bit of variation in the configuration... At any rate, create the file using whatever text editor you feel most comfortable using, then "chmod 755" the file to make it executable. If you call it "fwdisable.sh", then you should type "chmod 755 fwdisable.sh" in lxterminal and run the file with "sudo ./fwdisable.sh" to disable the firewall.
Good luck! If you want to know more about the workings of this stuff, google "bash scripting guide" and (for a general overview) read the wikipedia page for "iptables". It will help you understand what's up with all these seemingly weird commands...

That worked, but now I get these error messages?
[email protected]:/$ sudo ./fwdisable.sh
FATAL: Could not load /lib/modules/2.6.32.56-MB860-faux123-GB-024/modules.dep: No such file or directory
FATAL: Could not load /lib/modules/2.6.32.56-MB860-faux123-GB-024/modules.dep: No such file or directory
FATAL: Could not load /lib/modules/2.6.32.56-MB860-faux123-GB-024/modules.dep: No such file or directory
FATAL: Could not load /lib/modules/2.6.32.56-MB860-faux123-GB-024/modules.dep: No such file or directory
[email protected]:/$
Click to expand...
Click to collapse
Please advice
Cheers

You should be okay with those error messages. I'm not entirely sure WHY it's looking for that file, but it's "normal" output. If you'll remember, it's the same output you got in the "iptables -S" command... Something about accessing iptables causes the system to look for that file. (I just haven't been bothered enough over it to check yet...)
To verify, run "sudo iptables -S" again to see if there is anything left. You should just see three lines:
Code:
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
Anything more than that and you might need to edit your script as you did before. If the output from "iptables -S" looks like the above, though, fire up firefox and give it a whirl!

studean said:
You should be okay with those error messages. I'm not entirely sure WHY it's looking for that file, but it's "normal" output. If you'll remember, it's the same output you got in the "iptables -S" command... Something about accessing iptables causes the system to look for that file. (I just haven't been bothered enough over it to check yet...)
To verify, run "sudo iptables -S" again to see if there is anything left. You should just see three lines:
Code:
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
Anything more than that and you might need to edit your script as you did before. If the output from "iptables -S" looks like the above, though, fire up firefox and give it a whirl!
Click to expand...
Click to collapse
[email protected]:/$ sudo iptables -S
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
FATAL: Could not load /lib/modules/2.6.32.56-MB860-faux123-GB-024/modules.dep: No such file or directory
FATAL: Could not load /lib/modules/2.6.32.56-MB860-faux123-GB-024/modules.dep: No such file or directory
-A OUTPUT -o ppp0 -m owner --uid-owner adas -j REJECT --reject-with icmp-port-unreachable
[email protected]:/$

Excellent! This means you're almost there! As before, copy/paste that line into your shell script, change the "-A" to "iptables -D" and that SHOULD be the end of it.
No, really. This time for sure. Just re-run the script when you're done (ignoring the "fatal" stuff) and you'll be browsing in no time!

Related

adb shell and arrow keys

is it just me, or when you "adb shell" into the device and then use a program that uses the arrow keys everything goes berserk?
it seems like it's overlaying the command history into the on-screen buffer and all future interactions are corrupted beyond repair.
for example, run vi and use arrow keys to navigate around (yes, i know there are other methods for this, just using this to illustrate) and it pulls info from some sort of history buffer on to the screen.
another example is the ash shell. up and down arrows behave nicely at first allowing you to scroll through your command history. but, it degrades fairly rapidly into being unusable
this does not seem to be an issue using scroll ball in terminal on the device.
I can't find anything in the Android Issues Page.
I've reproduced this in multiple builds on multiple OS's on multiple machines (but I've only got one G1, hence this thread)
Does anyone have any insight?
What OS? Mine behaves this way too, and I think the root problem is the Windows command prompt. Read a comment somewhere on here that makes sense - something along the lines of cmd.exe not properly interpretting ANSI control codes? Need to hit up Google, maybe there's an alternative command shell that would solve this for Windows users.
EDIT: Ok, really need to work on reading comprehension - you tried multiple OSes? I was all set to blame MS. Anyway, I tested in Cygwin, Command2, Command2 wrapped around bash.exe .. No luck. Problem has to be in ADB itself somewhere, either the daemon on the phone or in all the clients.
Saiboogu said:
What OS? Mine behaves this way too, and I think the root problem is the Windows command prompt. Read a comment somewhere on here that makes sense - something along the lines of cmd.exe not properly interpretting ANSI control codes? Need to hit up Google, maybe there's an alternative command shell that would solve this for Windows users.
Click to expand...
Click to collapse
Thx for the reply.
I use a Mac mostly, but have similar response in Linux and Windows.
I've tried Terminal.app as well as iTerm on the Mac.
I tried cmd.exe, powershell, & cygwin / bash in Windows.
I agree it almost has to do have something to do with the way the adb daemon handles ANSI codes.
Maybe this will help...
Hi All,
I don't reckon there isn't an actual problem.
The "DOS" console is not a terminal program and thus doesn't behave proper, and the DOS telnet program is just as bad!
In linux, the console is a terminal program, but is also very generic.
The adb shell is not a very good telnet server either in terms of terminal handling; which all really boils down to the sh being to limited as a login shell.
The following may help a little.
Have PuTTY or the like handy.
For windows, copy paste the following or something like it into a bat file (dlink.bat I called it):
The important bit is the forwarding...
Code:
@echo off
:init
::REM //-----------------------------------------------------------------------
set prog=%~f0&&REM This
set progDir=%~dp0&&REM This location
set workdir=%cd%&&REM Current locataion
set ADB=%progDir%adb
echo --Droid Link--
echo current settings:
echo -----------------
echo prog=%prog%
echo progDir=%progDir%
echo workdir=%workdir%
echo -----------------
::REM //-----------------------------------------------------------------------
::REM //ensure a clean house
%ADB% kill-server&&echo adb server clean: Ok.||echo adb server clean: Problem...
::REM //start fresh server instance, use its own shell as it will not detach from the shell until it ends elsewise due to it running in daemon mode
%SystemRoot%\system32\cmd.exe /e:on/v:on/f:on /c "%ADB% root>nul:"
::REM //get id of the Android (will need to be adjusted for more than one)
for /f %%a in ('"%ADB% devices|find "HT""') do set adev=%%a
::REM //see if we found our device
if .%adev%.==.. (
echo Android not detected...
goto :done
) else (
echo Android detected as:%adev%
)
::REM /if
set DROID=%ADB% -s %adev%
::REM //-----------------------------------------------------------------------
:begin
::REM //-----------------------------------------------------------------------
::REM //forward telnet port
%DROID% forward tcp:18023 tcp:23
::REM //forward ssh port
%DROID% forward tcp:18022 tcp:22
echo This terminal is now held by --Droid Link--
echo You can now connect to Android:%adev% via telnet host:127.0.0.1 port:18023
echo And if you start a ssh server...
echo You can connect to Android:%adev% via ssh host:127.0.0.1 port:18022
echo For best results, use a program like PuTTY or something (dos telnet is lacking).
%DROID% shell telnetd
echo --Droid Link: Closed---
::REM //-----------------------------------------------------------------------
:done
::REM //-----------------------------------------------------------------------
%ADB% kill-server&&echo adb server off-line.||echo adb server dropped: off-line.
::REM //cleanup
set DROID=
set ADB=
set adev=
::REM //-----------------------------------------------------------------------
:xit
echo End of line.
::REM //-----------------------------------------------------------------------
For Mac, I'm afraid I rely on my linux syntax and pray it works the same in OSX:
adb -s {device ID} forward tcp:18023 tcp:23
note the adb -d forward tcp:18023 tcp:23 may do the trick also.
I use PuTTY and have a profile called Android-Telnet, which can be called from the console as putty.exe -load Android-Telnet
PuTTY may or may not be the end-all, be-all of terminal programs, but I like it, it works, and is multiplatform.
Hope that helps.
tyvm, Darkstrumn. that worked great! Can't believe i didn't think to try this as a workaround.
all i did (on OSX Leopard):
adb shell telnetd &
adb forward tcp:9999 tcp:23
telnet localhost 9999
now, to get working on compiling dropbear 0.52 and / or patching adb *eek*
i guess a related question becomes, is there any way to change ash to the default login shell?
alapapa said:
tyvm, Darkstrumn. that worked great! Can't believe i didn't think to try this as a workaround.
all i did (on OSX Leopard):
adb shell telnetd &
adb forward tcp:9999 tcp:23
telnet localhost 9999
now, to get working on compiling dropbear 0.52 and / or patching adb *eek*
i guess a related question becomes, is there any way to change ash to the default login shell?
Click to expand...
Click to collapse
Just a note: The windows version of this is just as simple as those 3 commands, the complexity of the script is simply allowing the script to lock-on to the device by id; my actual scripts enumerate the devices including the emulator into the %adevN% variables where N is 0-X. %adev0% will always be the first instance of the emulator found and %adev1% will always be the first instance of a true device found. I simple made it light and posted it. I think it only matters if you are using the emulator and have a live device connected and what to work with both.
Let me know if the enumeration script would be handy and I can post it also.
I haven't gone the route of dropbear just yet, but I'm interested in using ssh vs telnet.
As far as ash goes, I reckon the trick is to setup a chroot to use it as the console...maybe override the console service defined in init.rc.
Note I think ash is expecting the passwd file to exist and have meaning, so that may need to be setup to have ash behave a little better in the Android environment.
Thanks! This worked a treat for me.
I was having trouble with lynx and ansi chars within an adb session, the forward made my day .
Actually I got rid of the complex batch above, I just set up two small batch files:
myadbshell1.bat
@echo 1
@adb forward tcp:18022 tcp:22
@adb forward tcp:18023 tcp:23
@adb shell telnetd
@exit
myadbshell2.bat
@echo 2
@putty.exe telnet://127.0.0.1:18023
@exit
Run the first, then the second.
Do your story in putty, when exit everything will close.
Why echo 1 and 2? Because withouy I was getting the two batchs hanging, dunno why. :-?
Everything on windows environment.
In windows I created a .bat file called adb.bat, where c:/adb/ is where I installed the SDK:
Code:
c:/adb/tools/adb remount
c:/adb/tools/adb forward tcp:9999 tcp:23
c:/adb/tools/adb shell telnetd
I run this file as Administrator, and then I can telnet into localhost:9999 with putty. Works great!
Putty on Windows
In windows I created a .bat file called adb.bat, where c:/adb/ is where I installed the SDK:
Code:
c:/adb/tools/adb remount
c:/adb/tools/adb forward tcp:9999 tcp:23
c:/adb/tools/adb shell telnetd
I run this file as Administrator, and then I can telnet into localhost:9999 with putty. Works great!

Running script not possible cyanogen 4.2.1?

I wrote a small script with a wget command:
wget https://xxxxxxxlain.html?url=&meth=plain&action=login&time=480&uid=xxx&pswd=xxxx&submit=1
the script is called sesame
Put in on root of sd
terminal emulator:
Code:
$ su
# chmod 777 sesame
# ./sesame
: permission denied
How can that be?
Because the G1 uses ash, not bash, as its shell/CLI.
Rather than "./", use "sh ./"
IConrad01 said:
Because the G1 uses ash, not bash, as its shell/CLI.
Rather than "./", use "sh ./"
Click to expand...
Click to collapse
also, unless you had previously cd'ed to sdcard you must add the path so
Code:
sh /sdcard/sesame
should work
That's implicit when you understand the "." to mean "current directory".
I.e.; "find . -print" will print out every file in your current directory in a list. Going a step fancier you could also use "find . | grep .apk" to find all .apk's in your active directory.
Fun with commands!

TIP: /osh console utilities are accessible on the phone

I noticed earlier today, that it is possible to use all of the webtop's console utilities on the phone's command line by simply changing the PATH.
The PATH you need:
Code:
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/system/sbin:/system/bin:/system/xbin
To make life really easy, make a symlink in /system/xbin to bash, and put the PATH into /osh/root/.bashrc.
Also, there is a full libc on the phone, so that could open up more possibilities on the phone as well.
This is very nice thanks! One thing though, not sure if it's because I'm using a windows command prompt or not, but using bash through adb I get a bunch of funny characters on the screen for example:
# ls /bin/bash
ls /bin/bash
←[1;32m/bin/bash←[0m
# ls -h /bin/bash
ls -h /bin/bash
←[1;32m/bin/bash←[0m
Do you know how to remove those?
Thanks for the tip!
Those are color codes, the console you are using is reporting itself as capable of displaying colors and really isn't!
Check around for a switch to turn off the color codes (or perhaps use another version of ls like busybox ls)

[MOD] v0.3.1 Working Full Ubuntu for 1.5.7 and 1.8.3 based on Sogarth's script

Sogarth's webtop2sd will be released soon, you really should wait and install that instead of this! Thanks -The Management
No longer breaks on 1.83, thanks to Romracer
Update: This script worked on my phone. Mind you I was installing it from a fresh SBF flash, but it should work on your phone too. Absolutely no guarantees as usual.
Update 11th April 2011, 06:59 PM: Won't be getting CWM package because it'd be huuuuuuuuuge.
Update 28th April 2011. 16:38 PM: Removing BETA tag since there have been no issues with the script for quite some time.
First off I would like to thank Sogarth for making this script in the first place as well as Romracer for fixing it for 1.83. Since he is busy doing more important work I decided to do this little hack for those of us that updated to 1.5.7 and dont feel like flashing back to earlier versions to get full Ubuntu working.
Again, this is only necessary if you're already running 1.5.7 or 1.8.3.
Secondly, I am still working on this script so it may not work for you. If you have a problem you may post in the thread or PM me showing exactly the error message, word for word, that you receive.
Updates will be included in the OP from time to time as I fix errors.
Instructions:
1) install.bat (from your computer)
2) adb shell (get a shell on your phone)
3) su (get root on your phone in that shell)
4) . /data/local/tmp/install.sh (run the install script *on your phone* don't forget the "." and the space after the dot, or you will have to chmod 755 the shell script manually)
5) ?????
6) profit\
Noob instructions, written by Viamonte (I take no credit or responsibility):
Thanks again for all your help. Now the noob instructions:
"1-Download "Terminal Emulator" from the market, on your phone (or any other terminal), and the file anexed in this thread to your computer.
2-Connect the Atrix to the computer via USB, configuring the connection mode to "None" and enabling USB Debugging mode (Settings>Applications>Development>USB debugging)
3-Unzip the file you downloaded on your pc, and run Install.bat. This will push the script to your phone.
4-Go back to your phone and open the emulator you downloaded. Then type "su" (without quotes) and press enter. Then type ". /data/local/tmp/install.sh" (without quotes) and press enter again.
The script should begin running now. It will stop in two moments where you'll be instructed to get a cup of coffee, and may take several minutes to continue form this point. When finished, the Atrix will reboot.
To check if this worked, use the Webtop either on your multimidia dock or your lapdock and verify if new itens appeared on your task bar and on the right upper side of the screen"
0.3.1 release
0.2 release
0.1 first release
Changelog
0.3.1 fix to gconf file's mdate so it does what its supposed to do =)
0.3 Small typo fixes and cpp package install fix by romracer, now works on 1.83 =)
0.2 Fixed some typos in uninstall.sh and make sure the %gconf file wound up in the right spot.
0.1 - first version. NOT CWM install but ready to be packaged for that more or less
Nice, I'll give this a shot later.
Ill give it a shot when I get home!
Sent from Motorola Atrix on TELUS.
My phone is working perfectly, so why not ruin it?
I'm giving this a try right now!
1.4.57 - Rooted and gingerblurred with HDMI Mirroring and Webtop hack.
I'll update as progress goes along:
Edit 1:
Initial try gave me this
Checking device state...
Obtaining temporary root access...pushing shell scripts
A filesystem file already exists. Reset it? [n] y
Mounting the filesystem...
07.sh
--------------------------------------------
EXECUTION FAILED
Unable to mount the filesystem file. ERR 07
--------------------------------------------
Press any key to continue . . .
Edit 2:
Ok, it doesnt work with resetting it. How about removing?
Checking device state...
Obtaining temporary root access...pushing shell scripts
A filesystem file already exists. Reset it? [n] n
A filesystem file already exists. Delete it? [n] y
Deleting the filesystem file...
--------------------------------------
EXECUTION FAILED
Unable to delete the filesystem file.
--------------------------------------
Press any key to continue . . .
Edit 3:
Ok, only one option left then.
Checking device state...
Obtaining temporary root access...pushing shell scripts
A filesystem file already exists. Reset it? [n] n
A filesystem file already exists. Delete it? [n] n
--------------------------------------------------------------------------
EXECUTION FAILED
The filesystem file already exists, but no operations have been selected.
--------------------------------------------------------------------------
Press any key to continue . . .
=====================================================================
Edit 4:
Since execution is failing I'm trying to find the problem. Using ADB Shell i tried to manually run the shell scripts and stumbled here:
(I tried chmod 777 @ 02.sh to see if that was the problem, no change is results)
# ls -l
...
...
-rwsr-sr-x shell shell 87 2011-04-06 12:13 03.sh
-rwxrwxrwx shell shell 82 2011-04-06 12:11 02.sh
-rwsr-sr-x shell shell 251 2011-04-06 12:04 01.sh
# pwd
pwd
/data/tmp/shell
# /data/tmp/shell/02.sh
/data/tmp/shell/02.sh
/data/tmp/shell/02.sh: not found
I had the same issue as flybob when I tried to run the script.
Sent from my MB860 using XDA Premium App
Good effort, but 1.57 changes how we have to run commands as root. On a normal linux box, I'm sure your methods would work fine, but we're not dealing with a normal su binary. You should look into doing this as CWM as opposed to .bat files. I had a hell of a time getting around the restrictions since the psneuter exploit was closed.
Ah, I did not think about that Ririal, thanks for the info. I am not familiar with CWM though.
Why is the /tmp directory in /data ? That would certainly cause every script to fail.
I'll look at this some more tonight.
Ririal said:
Good effort, but 1.57 changes how we have to run commands as root. On a normal linux box, I'm sure your methods would work fine, but we're not dealing with a normal su binary. You should look into doing this as CWM as opposed to .bat files. I had a hell of a time getting around the restrictions since the psneuter exploit was closed.
Click to expand...
Click to collapse
How about a shell script that we can run in terminal emulator ? and the output goes to screen and a log file for debug !
molotof said:
How about a shell script that we can run in terminal emulator ? and the output goes to screen and a log file for debug !
Click to expand...
Click to collapse
most of the script is now run by shell scripts, no reason you couldn't run them in the terminal emulator, just get the order right. There are also a few lines I didn't translate to shell so you'd have to enter them by hand.
In any case I'll keep working on this until Sogarth releases his version with union mounts =D
You might be interested to know this;
# cd /tmp
cd /tmp
# pwd
pwd
/data/tmp
# ls -l /tmp
lrwxrwxrwx root root 2011-04-09 14:47 tmp -> /data/tmp
I'll happily help with the script, i know tons of linux and got my Atrix ready to be bricked
flybob said:
You might be interested to know this;
# cd /tmp
cd /tmp
# pwd
pwd
/data/tmp
# ls -l /tmp
lrwxrwxrwx root root 2011-04-09 14:47 tmp -> /data/tmp
I'll happily help with the script, i know tons of linux and got my Atrix ready to be bricked
Click to expand...
Click to collapse
That's just a symlinked directory. I won't make a difference if you call either.
Yes, just replied to the previous question
Why is the /tmp directory in /data ? That would certainly cause every script to fail.
I'll look at this some more tonight.
Click to expand...
Click to collapse
However, why doesn't the scripts run as wanted...?
# cat /tmp/shell/02.sh
cat /tmp/shell/02.sh
#!/bin/sh
/system/bin/su
/bin/rm /data/ubuntu.disk > /dev/null 2>&1 && echo PASS#
# ls -l /tmp/shell/02.sh
ls -l /tmp/shell/02.sh
-rwxrwxrwx shell shell 82 2011-04-06 12:11 02.sh
# /tmp/shell/02.sh
/tmp/shell/02.sh
/tmp/shell/02.sh: not found
flybob said:
Yes, just replied to the previous question
However, why doesn't the scripts run as wanted...?
# cat /tmp/shell/02.sh
cat /tmp/shell/02.sh
#!/bin/sh
/system/bin/su
/bin/rm /data/ubuntu.disk > /dev/null 2>&1 && echo PASS#
# ls -l /tmp/shell/02.sh
ls -l /tmp/shell/02.sh
-rwxrwxrwx shell shell 82 2011-04-06 12:11 02.sh
# /tmp/shell/02.sh
/tmp/shell/02.sh
/tmp/shell/02.sh: not found
Click to expand...
Click to collapse
Ah ok my mistake, you didn't quote anything I didn't realize that's what you were responding too
Likely noexec flag causing that issue.
Also, you can't invoke su from inside a shell script. It just doesn't work with this su binary.
yeah, I guess not. I hadn't realized that it wasn't a real 'su' before making this... too bad.
If anyone figures out how to get around that we'll be in business Unfortunately that's way beyond my expertise.
Okay, after fiddling a little bit and talking to a friend I may have solved some of the problems, mainly with the scripts executing and su working.
I will have to rewrite a bunch of things but should report back tonight.
the2dcour said:
Okay, after fiddling a little bit and talking to a friend I may have solved some of the problems, mainly with the scripts executing and su working.
I will have to rewrite a bunch of things but should report back tonight.
Click to expand...
Click to collapse
su -c "command"
You'll have to allow superuser on the phone for every single command.
PM'd you my error. I tried manually editing the permissions, but that didn't work.
Running on GladAtrix2 v3
USB debugging on; USB set to none
Checking device state...
Obtaining temporary root access...pushing shell scripts
-------------------------
EXECUTION FAILED
Unable to chmod scripts.
-------------------------
Press any key to continue . . .
Changed /sdcard-ext to /sdcard in script. Got this error
Checking device state...
Obtaining temporary root access...pushing shell scripts
-------------------------
EXECUTION FAILED
Unable to chmod scripts.
-------------------------
* server not running *
Press any key to continue . . .
Running BETA_ubuntu-1.0.6.4.zip. File extracts to BETA_ubuntu-1.0.6.2 directory. Ran ubuntu-1.5.7.bat
Moved BETA_ubuntu-1.0.6.2 to C:\ Same error
The only easy workaround to that I can see at the moment is to
Code:
adb shell
su
chmod 777 /path-to-scripts/*
ls -l /path-to-scripts/*
make sure all the files are executable (should say rwxrwxrwx)
then remove the bit of code from 1.5.7.bat
Code:
set retval=
for /f "tokens=*" %%l in ('%~dps0adb.exe shell "/bin/chmod 6755 /mnt/sdcard-ext/shell/* > /dev/null 2>&1 && echo PASS"') do set retval=%%l
if "%retval%" neq "PASS" set message=Unable to chmod scripts. && goto abort
If anyone can help me fix this problem I should be able to automate the chmod process using ririal's suggestion of su -c. The problem is that there are too many nested quotation marks in this section of the batch file, and I can't for the life of me figure out how to escape quotes so they pass through to adb:
Code:
set retval=
for /f "tokens=*" %%l in ('%~dps0adb.exe shell "/system/bin/su -c [U]'/bin/chmod 6755 /mnt/sdcard-ext/shell/*'[/U] > /dev/null 2>&1 && echo PASS"') do set retval=%%l
if "%retval%" neq "PASS" set message=Unable to chmod scripts. && goto abort
The underlined bit is where I need to escape either single or double quotes.
the2dcour said:
The only easy workaround to that I can see at the moment is to
Code:
adb shell
su
chmod 777 /path-to-scripts/*
ls -l /path-to-scripts/*
make sure all the files are executable (should say rwxrwxrwx)
then remove the bit of code from 1.5.7.bat
Code:
set retval=
for /f "tokens=*" %%l in ('%~dps0adb.exe shell "/bin/chmod 6755 /mnt/sdcard-ext/shell/* > /dev/null 2>&1 && echo PASS"') do set retval=%%l
if "%retval%" neq "PASS" set message=Unable to chmod scripts. && goto abort
If anyone can help me fix this problem I should be able to automate the chmod process using ririal's suggestion of su -c. The problem is that there are too many nested quotation marks in this section of the batch file, and I can't for the life of me figure out how to escape quotes so they pass through to adb:
Code:
set retval=
for /f "tokens=*" %%l in ('%~dps0adb.exe shell "/system/bin/su -c [U]'/bin/chmod 6755 /mnt/sdcard-ext/shell/*'[/U] > /dev/null 2>&1 && echo PASS"') do set retval=%%l
if "%retval%" neq "PASS" set message=Unable to chmod scripts. && goto abort
The underlined bit is where I need to escape either single or double quotes.
Click to expand...
Click to collapse
^ escapes batch, \ escapes shell. Hope this helps. If you zip up and send me the whole process in a single .sh file I can wrap it up in CWM for you.

How to install ubuntu on the Droid 4

How to install ubuntu on the Droid 4
Note to mods: this thread is a branch off of this thread
Huge thanks to zacthespack for creating the ubuntu installer app and original boot script and to zeroktal for modifying the script to work on the D4 and helping me get it working on my device.
I decided to take my experience in setting this up and put it into a how-to so that others could enjoy the experience of having ubuntu on the Droid 4. If zackthespac or zeroktal have any problems with me making and putting this guide up, please let me know and I will remove it.
Knowledge Required:
working knowledge of command line
working knowledge of vi
OR the ability to learn how to use both
Tools Required:
A rooted Motorola Droid 4
BusyBox (Android Market)
Terminal Emulator (Android Market)
Android VNC Viewer (Android Market)
Ubuntu Installer App (Android Market)
zeroktal's ubuntud4.zip file (attached to this post and mediafire)
Vi Cheat Sheet (lagmonster.org)
Step by Step:
Install BusyBox, Terminal, and Android VNC Viewer
Install and run Ubunutu Installer App
Follow the on-screen instructions and click next
Download either the Small or Large image to your phone, (use zeroktal's ubuntud4.zip file instead of the boot script provided in the guide) after the image downloads (will take a while because the file is HUGE) click next
For this screen, the instructions differ from the app.
1. With your D4 plugged into your PC in USB Mass Storage, create a directory (folder) called ubuntu in the EXTERNAL sdcard's root*
2. Extract the image you downloaded to that directory
3. Download and extract the attached .sh (ununtud4.zip) to that directory
4. Disconnect your phone from your PC
5. Open terminal and run the following commands:
su [ENTER]
mount -o remount,rw,exec,suid /dev/block/vold/179:1 /mnt/sdcard-ext [ENTER]
cd /mnt/sdcard-ext/ubuntu [ENTER]
sh ubuntud4.sh [ENTER]
960x540 [ENTER]**​If you get an error message: ubuntud4.sh: 45: syntax error: end of file unexpected (expecting "then") see troubleshooting section below.​killall -TERM Xtightvnc [ENTER]
vncserver :1 -geometry 960x540 [ENTER]**​6. Open androidVNC app and enter the following settings:
Nickname: Anything you want
Password: ubuntu
Address: localhost
Port: 5901
Color Format: 24-bit color (4 bpp)
7. Hit connect
8. Hit your menu soft button and then set input mode to touchpad
9. You have ubuntu on your Droid 4!
To "shut down" ubuntu:
press the menu button, select disconnect in VNC
In terminal type this command 3 times (terminal will close itself when you are done):
exit [ENTER]
To "start up" ubuntu again:
Follow steps 5-8 above
Troubleshooting:
If you get the error message: ubuntud4.sh: 45: syntax error: end of file unexpected (expecting "then") you are about to have fun with vi at the command line.
Do the following from inside terminal:
su [ENTER]
cd /mnt/sdcard-ext/ubuntu [ENTER]
vi ubuntud4.sh [ENTER]​If you see ^M or ^ at the end of any line (remember to scroll all the way to the right to see the end of long lines) remove it. once you do that, everything should work just fine. (See the Vi Cheat Sheet above for help with Vi)
Note: Vol Up + E is [ESC] by default in this terminal emulator
Notes:
* It does not have to be on the external SD, but if you put it on the internal SD you will have to modify things as needed-- if you dont know what needs to be changed, just put it on the external SD.
** Screen size can be whatever you want it to be, but 960x540 is the size of the D4 screen.
*** This is a fairly involved process... especially when it comes to editing the .sh file in vi things can get very frustrating and hard, but just take your time and you will get it. As always, doing anything with root access on your phone, especially on the command line has risks. I am not responsible if anything goes wrong with your phone... proceed at your own risk!
greekchampion04 said:
Notes:
* It does not have to be on the external SD, but if you put it on the internal SD you will have to modify things as needed-- if you dont know what needs to be changed, just put it on the external SD.
** Screen size can be whatever you want it to be, but 960x540 is the size of the D4 screen.
*** This is a fairly involved process... especially when it comes to editing the .sh file in vi things can get very frustrating and hard, but just take your time and you will get it. As always, doing anything with root access on your phone, especially on the command line has risks. I am not responsible if anything goes wrong with your phone... proceed at your own risk!
Click to expand...
Click to collapse
I actually got it up and running on my internal sdcard partition. Pretty much just have to modify the Mount remount command, and a few lines in the script.
Here's the original command
Code:
mount -o remount,rw,exec,suid /dev/block/vold/179:1 /mnt/sdcard-ext
And the modified one
Code:
mount -o remount,rw,exec,suid /dev/block/vold/179:57 /mnt/sdcard
Only things you have to change are the device location(179:57) and mount location(drop the -ext after sdcard)
Now, after that you also have to modify the script a bit. Just go through it, and anywhere that you see sdcard-ext, drop the -ext off the end.
thanks for putting that up for everybody! like i said, if you know what you are doing its not a hard swap to make.
Is anyone else getting just a gray screen when they remote in? What could be causing this?
i had that same problem at first... did you use zeroktal's ubuntud4.zip file? or did you use the ubuntu.sh file included in the app?
I used the sh file included. I did however fix the problem, when mounting at the start i confused vold with void. I did not get the file system mounted properly. This method does work!! however I am currently trying to get bash on my droid to replace sh as the shell. I've checked the forums but have not found anything yet about someone installing bash on the droid 4. With no way for nandroids I feel i should wait before I kill sh.
Sent from my DROID4 using XDA App
If you mod your init.sh in your root directory to the following, your vnc will work on startup without issue. It will also shutdown vnc on exit.
#!/bin/bash
#############################################
# Asks User to screen size and saves as REZ #
#############################################
#echo "Now enter the screen size you want in pixels (e.g. 800x480), followed by [ENTER]:"
#read REZ
##############################################
# Pick which desktop environment to use, this#
# is done by having a xstartup file for each #
# desktop, then renaming the one you want to #
# use to 'xstartup' before boot #
##############################################
echo "Please select which Desktop environment you want to use, type the number to select it then press [ENTER]"
echo "1 - LXDE"
echo "2 - Gnome"
echo "Make your Selection:"
read DESKTOP
if [ $DESKTOP == 1 ]
then
mv /root/.vnc/lxstartup /root/.vnc/xstartup
fi
if [ $DESKTOP == 2 ]
then
mv /root/.vnc/gxstartup /root/.vnc/xstartup
fi
###########################################
# Tidy up previous LXDE and DBUS sessions #
###########################################
rm /tmp/.X* > /dev/null 2>&1
rm /tmp/.X11-unix/X* > /dev/null 2>&1
rm /root/.vnc/localhost* > /dev/null 2>&1
rm /var/run/dbus/pid > /dev/null 2>&1
############################################################
# enable workaround for upstart dependent installs #
# in chroot'd environment. this allows certain packages #
# that use upstart start/stop to not fail on install. #
# this means they will have to be launched manually though #
############################################################
dpkg-divert --local --rename --add /sbin/initctl > /dev/null 2>&1
ln -s /bin/true /sbin/initctl > /dev/null 2>&1
###############################################
# start vnc server with given resolution and #
# DBUS server, (and optionally an SSH server) #
###############################################
dbus-daemon --system --fork > /dev/null 2>&1
/etc/init.d/ssh start
vncserver :1 -geometry 960x540
echo
echo "If you see the message 'New 'X' Desktop is localhost:1' then you are ready to VNC into your ubuntu OS.."
echo
echo "If VNC'ing from a different machine on the same network as the android device use the 1st address below:"
##########################################
# Output IP address of android device #
##########################################
ifconfig | grep "inet addr"
echo
echo "If using androidVNC, change the 'Color Format' setting to 24-bit colour, and once you've VNC'd in, change the 'input mode' to touchpad (in settings)"
echo
echo "To shut down the VNC server and exit the ubuntu environment, just enter 'exit' at this terminal - and WAIT for all shutdown routines to finish!"
echo
###############################################################
# Spawn and interactive shell - this effectively halts script #
# execution until the spawning shell is exited (i.e. you want #
# to shut down vncserver and exit the ubuntu environment) #
###############################################################
/bin/bash -i
#########################################
# Disable upstart workaround and #
# kill VNC server (and optionally SSH) #
# Rename used xstartup to its first file#
#########################################
killall -TERM Xtightvnc
/etc/init.d/ssh stop
Also save the follow lines between ### as remount.sh on your system partition. Then chmod 755 /system/remount.sh. Now you can just run run from a terminal /system/remount.sh and voila it remounts correctly and starts ubuntu(with the above fixes). Im still working on the unmounts.
####### for the internal sd card
mount -o remount,rw,exec,suid /dev/block/vold/179:57 /mnt/sdcard
/mnt/sdcard/ubuntu/ubuntu.sh
######
OR
####### for the external sd card
mount -o remount,rw,exec,suid /dev/block/vold/179:1 /mnt/sdcard-ext
/mnt/sdcard-ext/ubuntu/ubuntu.sh
#######
great stuff!
feel free
Feel free and take, modify, repost or edit anything I touch.
QUESTION:
After I delete all the ^M and ^ what do i do next? I try to hit the command ":x" to exit and save changes but it just creates another line. Also when I press VOL UP + E to escape nothing happens.
PhanTuhC said:
QUESTION:
After I delete all the ^M and ^ what do i do next? I try to hit the command ":x" to exit and save changes but it just creates another line. Also when I press VOL UP + E to escape nothing happens.
Click to expand...
Click to collapse
In vi, the command to save and exit is :wq (probably short for write and quit).
remember, read up on the vi quick-reference guide: http://www.lagmonster.org/docs/vi.html
OK I fixed it but now its not letting me connect with androidVNC. All the settings entered is correct but when I try to connect it says:
"VNC connection failed!" localhost/127.0.0.1:5901 - Connection refused"
ok, i've gone thru this a few times (slowly and deliberately) and must be missing something...the directions seem pretty straightforward! here's what i know...
busy/terminal/vnc are all installed
small 2.5gb image is unzipped in /sdcard-ext/ubuntu directory
the attached .sh file from page 1 is in the same directory
i removed all ^M using vi
but when I try sh ubuntud4.sh i get an error...
"mkdir failed for /data/local/mnt/ubun, No such file or directory"
(plus a few other errors)
should the directory be "ubun" or "ubuntu"? am I typing something incorrectly?
copy and paste new script
Copy and paste the new scripts I posted. They will fix your problem. Remember to use the remount script from /system/ the rest will work perfectly if you are root. I'll check back later on your progress.
Ok, well I started from scratch (deleted both .img and .sh files) and it's still not working.
I have all the apps installed (and yes rooted, SU works just fine)
I used Ubuntu Installer app to download the image zip (tried both the large and small img)
I downloaded the .sh file from the first post
The /sdcard-ext/ubuntu/ folder now has two files: "ubuntu.img" and "ubuntud4.sh"
All ^M characters have been removed from .sh file
Still no joy...
Ideas? What am I missing?
In terminal, I can set SU permissions and the mount/cd commands work just fine...it's the last sh command that spits out a bunch of errors about not being able to create/find the directories.
I'm going to format the sdcard and try again...any help is appreciated.
Update: Even after re-formatting the SD and following the steps exactly, no luck!
Did you remember to remount the sdcard with exec and suid permissions?
Andbuntu will work much better than this method. It works on every single phone with modification to the "environmental variables".
http://code.google.com/p/andbuntu/
Follow the directions in the script to make the process much easier than the first post.
instructions:
generate an image with rootstock on an ubuntu computer.
put it on /sdcard/ubuntu/ubuntu.img
run the script on your phone with "sh /path/to/script"
Here is the script. http://andbuntu.googlecode.com/svn/trunk/uboot
Also, run "firstRun" to make things like terminals work properly.
Adamoutler: That didnt work for me. The permissions were incorrect on the mounted partitions.
Sent from my DROID4 using XDA App

Categories

Resources