[HOWTO] Remove bash Color Codes - Fascinate Android Development

Anyone who uses the latest roms, mods, etc. is probably using bash. Bash is awesome, bash is great bash is...annoying if you use Windows with adb.
Familiar sight?
bash-4.1# ls
ls
←[1;36mbin←[0m ←[1;32minit.rc←[0m ←[1;34msbin←[0m
←[1;34mcache←[0m ←[1;32minit.smdkc110.rc←[0m ←[1;34msdcard←[0m
←[1;34mconfig←[0m ←[1;32minit.smdkc110.sh←[0m ←[1;34msqlite_stmt_journals←[0m
←[1;34mdata←[0m ←[1;36minit_samsung←[0m ←[1;34msys←[0m
←[1;34mdbdata←[0m ←[1;34mlib←[0m ←[1;34msystem←[0m
←[1;32mdefault.prop←[0m ←[1;32mlpm.rc←[0m ←[1;32msystem.prop←[0m
←[1;34mdev←[0m ←[1;34mmnt←[0m ←[1;34mtmp←[0m
←[1;34mefs←[0m ←[1;34mpreinstall←[0m ←[1;34muserdata←[0m
←[1;36metc←[0m ←[1;34mproc←[0m ←[1;36musr←[0m
←[1;32mfota.rc←[0m ←[1;32mrecovery.rc←[0m ←[1;34mvoodoo←[0m
←[1;36minit←[0m ←[1;34mres←[0m
Now my way:
bash-4.1# ls
ls
bin init.rc sbin
cache init.smdkc110.rc sdcard
config init.smdkc110.sh sqlite_stmt_journals
data init_samsung sys
dbdata lib system
default.prop lpm.rc system.prop
dev mnt tmp
efs preinstall userdata
etc proc usr
fota.rc recovery.rc voodoo
init res
Requirements:
Root.
Clockworkmod Recovery.
My busybox.
My color code removal patch.
Patch
http://dl.dropbox.com/u/2056318/bash_nocolor_1.1.zip
Install both via cwm. Make a nandroid backup first, JUST IN CASE.
If my patch hosed ls on your phone, this should fix it. Sorry about that.
http://dl.dropbox.com/u/2056318/bash_nocolor_fix.zip

Great Work!

What is this?

Did you remove all color from bash, or is it just not doing ls in color by default?
I would recommend people use something like mintty or console2 as their terminal on Windows instead of a regular cmd anyway, for anyone who actually uses the terminal frequently. Well, so console2 gets the same stupid behavior as the standard cmd with escape codes in adb for some reason, but it works with bash color escape codes in general (I have them in my $PS1). Mintty does support escape codes in adb shell, and is generally pretty nice, but doesn't have tabs unfortunately. Just a tip for people.
Nice job for those who don't want to change their terminal, of course. I just feel that for power users mintty is a better solution.

It removes them from ls, which is which is the only place the problem will lie for most windows users. I require my busybox, as there are many versions out there, but mine is the latest, and I know it supports ls. My patch removes the ls binary from Android and replaces it with my own symlink.
As for those options, I will stick with my powershell, but thanks. A poweruser should be using Linux anyway (I do normally).

Ah, yeah, that's probably true. But why is the default ls with colors in Android anyway? I normally need to create an alias to set ls to ls --color=auto or something along those lines usually. Is it just not getting the terminal info properly? I'm just curious about this I guess.
I'm a weird person who uses Unix shells on Windows, I guess because I like games too much.

Its not. ls in itself is a binary, not a symlink. It is running through the bash shell. Bash, is what supports colors. By default Android does not run bash, but sh.

Oh huh, didn't realize Android used sh by default. Guess I never paid attention.

Do you drop busybox in /system/bin to install it? That is, if you aren't flashing it from cwm.

Hate to be the bringer of bad news, but something in this breaks WiFi. After installing it, I can no longer connect to my router, it just stalls at "Obtaining address". When I check the router, it's already assigned an address.
I reflashed DL09 cleanly, and it connects right away. I re-apply this fix, and WiFi stops working again.

I did say make a nandroid backup....right?
Anyway, you are correct. Patch has been removed until I can figure something else out.

I did say make a nandroid backup....right?
Anyway, you are correct. Patch has been removed until I can figure something else out. Please revert to an earlier nandroid.

First post updated with a better fix that disables color for bash, system wide. Thanks to enderst from irc for the help.

Related

[MOD] Change WiFi hostname - for custom ROMs (Sept 23)

This is useful for identifying phones on the local networks by looking at DHCP lease tables in the routers. It doesn't make your phone appear on Windows networks, since the phone needs to broadcast NetBIOS name for that. If you want your phone to show up on Windows networks (and share files) - you need Samba server, and JimmyChingala is working on one.
ROM developers can insert the option to customize hostname using the way described below in their Spare Parts options. Feel free to do so.
[SOLUTION]
The following shell command does the job of changing WiFi hostname:
echo YOURHOSTNAME > /proc/sys/kernel/hostname
Click to expand...
Click to collapse
For the change to stay, it should be executed on each boot. And here the things start being more problematic.
For custom ROMs:
Most, if not all, custom ROMs include some user init shell script that will be executed on boot, making the solution easy.
Enter the following line in the Terminal / ADB shell:
echo "echo YOURHOSTNAME > /proc/sys/kernel/hostname" >> the_path_and_name_of_userinit_script.sh
chmod 777 the_path_and_name_of_userinit_script.sh
Click to expand...
Click to collapse
Several examples of custom ROMs and their userinit scripts:
Suggested - will work for most ROMs (creates another file in directory of autoexecuted scripts): /etc/init.d/88hostnameinit
Additional possibility for Enomther's ROM: /data/local/userinit.sh
Additional possibility for CyanogenMOD: /sd-ext/userinit.sh
For stock ROMs:
There is no autorun script for stock ROMs, so they have to be added through modifying boot.img. It's a complicated procedure, and even though guides exist for it - I suggest not to mess with it only because of the hostname. The easiest solution would be to create a script file with the line above using Gscript or other scripting solutions, and execute it after each reboot. If anyone really wishes to modify boot.img - I assume that he/she knows enough about Linux/Android since it can be relatively easily done only on Linux, can find the necessary guides with some googling (like I did), and in this case the modification is easiest to do directly in init.rc - changing "hostname localhost" to "hostname name_of_your_choice".
[ORIGINAL POST]
Hi people,
I'm not much of a dev, but I can find my way around with a bit of Google search And sorry about the links that don't link, new user's permissions don't allow me to...
Anyway, after messing with my router today I've noticed that Nexus transmits "localhost" as its host name to DHCP server, causing my DD-WRT to show it as "*". I went to Google and to my surprise, discovered that there isn't such an option in any Nexus ROM yet.
Found this: LINK_www_laslow_net_?p=501
To change your hostname on Cyanogen 5.x, add the following line to the bottom of /system/etc/init.d/01sysctl -- and make sure you make a backup of 01sysctl before editing it!
echo NEWHOSTNAME > /proc/sys/kernel/hostname
Click to expand...
Click to collapse
I tested it, and it didn't work. After booting, the file still read "localhost" in it, and the hostname on DHCP server reflected it.
But, I didn't get frustrated, connected with ADB, manually executed the command:
echo MyHostName > /proc/sys/kernel/hostname
checked that the file was overwritten, disabled WiFi, deleted DHCP lease, enabled WiFi back - and voila, I have a new hostname!
Then I went to search for hostname setting, which got me to /init.rc:
on boot
# basic network init
ifup lo
hostname localhost
domainname localdomain
Click to expand...
Click to collapse
Well, I guess that's the place. A tiny problem, though - it's in the boot image, which can't be easily modified. Thanks to the latest thread on update.zip creation I can probably do it myself, but I wanted to share the findings and ask for the correct way to implement.
There's a "dirty but functional" way of "disable WiFi - override /proc/sys/kernel/hostname - enable WiFi", and it's probably not a problem to stick it somewhere in the boot sequence, or even write an app that writes those changes to one of the boot scripts and allows configuration of host and domain names. But it's not the best way - DHCP might already give out a lease, and the new host name might not register.
And there's a correct (?) way of doing it, introducing it into init.rc. Since it's "on boot", I suppose that it runs after mounting the partitions - which means that the partitions are already accessible.
In this case, the best way would be executing a small shell script that would check for existence of, say, "/system/etc/settinghostdomainnames.rc" and create a default one if it's not there, then use "import /system/etc/settinghostdomainnames.rc" and set a manual trigger, like the guy is trying to do here:
LINK_groups.google.co.jp_group_android-developers_browse_thread_thread_e2f432707b735ff0
"trigger someeventtobringupnetworkinterface"
That would allow to use a custom setting for host and domain names that can be changed by SW, and adding that as another option into ROM Settings app or external app.
But the guy in question didn't succeed. What did he miss? Would it be better to do something like "on fakesystemproperty=something" and instead of manual trigger, doing "setprop fakesystemproperty something"?
I can probably test it and find out myself, but it would take loads of time compared to one of the kernel devs, and I don't even have the environment set up for modifying boot images. I was kinda hoping that one of the kernel devs would test it. I can write and post the modifications to init.rc and the custom script, they're very simple.
So, who can help me with answering the questions in the thread, and/or testing the modification?
Thanks! It's back.
Oh well, I'll keep preparing Ubuntu VM anyway
OK, first test fired - updated /init.rc in my own boot.img, checked the values. It's working, hostname is indeed modified.
Now I'll try to rewrite /init.rc in such way as to load the hostname setting from elsewhere, while not screwing the security. Will post results soon.
Setting it to the same value as the BT value would be ideal. I'm not sure how you could do that though, because the init scripts run before the frameworks load
Looking forward for a fix to this problem.
Update, but only partially on topic:
God, I hate SH scripting. Couldn't even google a normal tutorial that would explain where I went wrong. A script of 10 lines, and I can't make it work.
Let's see, I need something like this:
#!/system/bin/sh
echo "on service-exited-network_prepare" > /system/etc/net_init.rc
echo " ifup lo" >> /system/etc/net_init.rc
if [ -e "/system/etc/net_init.domain" ];
then
echo "hostname `cat /system/etc/net_init.host`" >> /system/etc/net_init.rc
else
echo "hostname localhost" >> /system/etc/net_init.rc
fi
if [ -e "/system/etc/net_init.domain" ];
then
echo "domainname `cat /system/etc/net_init.domain`" >> /system/etc/net_init.rc
else
echo "domainname localdomain" >> /system/etc/net_init.rc
fi
echo >> /system/etc/net_init.rc
Of course, this thing fails miserably with -
Syntax error: end of file unexpected (expecting "then")
What the hell am I doing wrong? Never used SH before, mostly tcsh and perl.
Thanks.
Oh well, I guess I got the problem.. Unix vs Windows file format. Sorry for bothering.
its always bothered me that you cant change the device name for wifi networks, and ive always looked for a way to change it.
kudos to you for the ambition and diligence to do it!
dont give up, if you can get it smoothed out enough im sure cyanogen will implement it in his next mod. ive always wished there was an option in wifi settings to change device name. itd be very useful for lan ip configuring and when your connected to a random hotspot lol
Ok, after fighting for a day, I still didn't manage to import another .RC file and run on service exit (I don't even see the trace of the process I'm trying to start - the first thing it does is attempting to write log, and there is no log, no matter where I put the start command), but at least for a "quick-and-dirty way" there's a very simple solution, given SD-EXT partition (I believe everyone creates it):
open terminal application, type the following command:
echo "echo YOURHOSTNAME > /proc/sys/kernel/hostname" > /sd-ext/userinit.sh
That would override the hostname of the system before boot completion.
After some reading, I believe there's nothing bad in setting the hostname twice - once default localhost in init.rc, and then overriding it using /proc/sys directory, Linux is designed to cope with that and hopefully so does Android.
So, as to pershoot's request, it's possible to write a small application to read Bluetooth device name value and write it as WiFi hostname, and include it in boot process right before 20userinit.
Now this is a task I'm not suitable for, I have no knowledge of frameworks whatsoever. Anybody up to the task?
Jack_R1 said:
After some reading, I believe there's nothing bad in setting the hostname twice - once default localhost in init.rc, and then overriding it using /proc/sys directory, Linux is designed to cope with that and hopefully so does Android.
So, as to pershoot's request, it's possible to write a small application to read Bluetooth device name value and write it as WiFi hostname, and include it in boot process right before 20userinit.
Now this is a task I'm not suitable for, I have no knowledge of frameworks whatsoever. Anybody up to the task?
Click to expand...
Click to collapse
I requested it and I'm not pershoot
Oops Sorry, my bad. Fever and lots of time in front of the computer don't do me good...
Kudos to you Jack_R1. Watching this.
Let me know if you need any help with shell scripting.
Gonna watch this and try it out later, the solution so far.
is this a stable fix?
is this confirmed to work?
Sorted out, updated with the most current info and several examples of custom ROMs.
Jack_R1 said:
Sorted out, updated with the most current info and several examples of custom ROMs.
Click to expand...
Click to collapse
I am running CM6 with a2sd and somehow the /sd-ext/userinit.rc is not executed. Even if I change permissions of the file to 777, it's not executed.
I also haven't found in init.d the script which executes userinit.rc, might be because I am running custom kernel? (wildmonks).
The only way for me to do it was to put the script in /etc/init.d/88userinit file and change it's permissions to 777
It's /scripts/userinit.sh, not userinit.rc
The execution of /sd-ext/userinit.rc used to be in /init.rc, in boot.img.
But the preferred way for most of the ROMs is to use /etc/init.d/ scripts anyway, since a lot of ROMs use them.
Changed the 1st post to reflect it.

Optware for Android released by Novaports

Optware was originally developed as a distribution mechanism for software for the Open Source Linux project for the Linksys NSLU2 (a small low cost network storage device). That consumer storage device ran on Linux, and the community opened it up, but they needed a lightweight distribution mechanism for their lightweight devices.
Since 2004 Optware has been adopted by a variety of Linux communities and device developers including the webOS community working on the Palm Pre and Pixi, and developers for devices as diverse as Asus WL-500g,WL-HDD, WL-500gx, WL-500gP routers, the Synology DS-101 and DS-101g+ NAS devices.
At its core, Optware is a package manager to allow you to easly install and uninstall cross-compiled linux applications on your device over the internet. At this time, optware supports the automatic download and installation of over 1500 programs. (See the list at the end of the wiki article.)
Why should I use Optware?
Like the original slug, android devices lack a distribution mechanism to install Linux/command line tools programs and utilities. Many in the Android community who want or need to do command line processing on their device use a chroot of some sort (Debian seems popular) to get their distribution and package management tools. With Optware, it becomes possible to simply run whatever utility or program you want on the native underlying Linux.
Additionally, Optware For Android installs openSSH making it possible to access your Nook from any PC with SSH capability, and sets up an unprivileged username/password login system for the device at the command line. All in all then, since it can be installed with a single script, since it's lightweight, and since it's designed for small and embedded devices, Optware is a perfect fit for the Android community.
Optware for Nook is the first Optware for Android release by the Novaports team and is their gift to the Android community members who have helped them so much with information on Android devices.
What does it do?
The Optware bootstrap installed the IPKG package manager. It installs the optware Busybox. It installs openSSH and makes the ssh demon persistent. It creates an unprivileged user with a username and password you choose.
See Installation instructions and details at the Optware for Android page at Nookdevs.com
For completeness of licensing compliance, the source code for all optware package can be found at the following locations:
1) build scripts at svn.nslu2-linux.org in the /svnroot/optware/ area
2) tarballs at sources.nslu2-linux.org in the /sources area (this is a *large* directory)
To contribute code to Optware, see www . nslu2-linux . org in the /wiki/Optware/AddAPackageToOptware area
-- Rod Whitby
-- Original NSLU2-Linux Project Lead and Optware Architect
This works beautifully! Thank you!
Gonna try this and see if i can get samba to work.. a SMB mount over wifi would be awsome...
Many thanks!
I don't suppose there's a quick and easy way to completely remove optware?... not looking forward to culling through scripts and manually un-doing it all.....
adduser: not found
When it gets to the part in the install script to add the username of the unprivileged user, I enter a name, then it says: adduser: not found.
If it helps, I am using Rooted Stock 1.1.
Anyone get Optware to install on CM7 (newer nightly)
I am running CM7 #103 and would love to have optware installed.
But I get Fail if I try to use the method from Nookdevs
Tonight when I have more time I will look at the errors and see if I can tell what is up.
It looked like partially due to missing dir's for one (/tmp)
madrascafe said:
Gonna try this and see if i can get samba to work.. a SMB mount over wifi would be awsome...
Click to expand...
Click to collapse
The market has your answer and it's free:
https://market.android.com/details?id=com.funkyfresh.samba&feature=search_result
Am I the only one that wants Optware on CM7?
It goes fine on a manualnootered 1.2.0 NC But I prefer CM7 (And use the nightlies)
I would love to get this going on my NC as well. Running CM7 N121 w/ 6/30/2011 OC kernel. Was able to manually work past the tmp directory problem you mentioned, but I can't seem to execute the ipkg binary or installed. I've verified it indeed exists in the path I'm trying to execute it from, it has +x perms for user/ group/ other, but it always gives the error below:
/data/opt/bin/ipkg: not found
I've tried messing with bin directory and ipkg binary ownership, but no dice. If anything it should at least find it even if permissions aren't correct.
Looks like the contents of the binary reference ELF libraries which sounds like an issue attempting to execute in an Android environment. Going to see if I can chroot an environment that will work for it.
Sent from my NookColor using Tapatalk
This is happening because it's looking for /lib/ld-linux.so.3, and not finding it. I worked around by
ln -s /data/opt/lib/ld-linux.so.3 /lib/ld-linux.so.3
I also had to make these links:
ln -s /data/opt /opt
ln -s /data/tmp /tmp
And then set this:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/lib
export PATH=$PATH:/opt/bin/:/opt/sbin
in my bash profile to get things to start working.
One problem is my symlinks seem to get erased every reboot. I worked around by re-creating them in my bash profile, but I wish I knew how to make them permanent. This may be a ROM specific thing - this was written for a rooted stock nook, and I'm on an Epic running SFR.
I do not have a ld-linux.so.3 file on my NC w/ CM7 125
I have many other errors that show up:
Downloading the latest ipkg-opt package from the Optware package feed:
Connecting to ipkg.nslu2-linux.org (140.211.169.161:80)
wget: can't open 'ipkg-opt_0.99.163-10_arm.ipk': File exists
(NOTE the above file 'ipkg-opt_0.99.163-10_arm.ipk' does not exist
(on my NC - from a find / -name ipkg-opt_0.99.163-10_arm.ipk)
Updating the Optware package database:
ERROR: Failed to update the local Optware package database
Updating the Optware package database:
/data/optware-bootstrap-0.0.1.shar: ipkg-opt: not found
ERROR: Failed to update the local Optware package database
Any ideas?
The actual file it needs is /data/opt/lib/ld-linux.so.3 - you need to create a symlink in /lib in order to see it. But I think that file comes from the optware installer - if the installer is failing, you won't have it there either. It sounds like you may have bits of a previous install that failed, and it's preventing the install from running properly. Try looking at the log in /data/tmp for more info. After that, try rm -rf /data/tmp/* to clean up the old install and trying again.
Thank You for any pointers.
I deleted everything in /data/tmp first last attempt - like you suggested.
Same result
I have it down to only this error now when I run it (optware-bootstrap-0.0.1.shar):
Updating the Optware package database:
optware-bootstrap-0.0.1.shar: ipkg-opt: not found
ERROR: Failed to update the local Optware package database
ipkg-opt should be in /data/opt/bin. Check to see if it's there... if not, something went wrong in one of the previous steps - probably somewhere around "Downloading the latest ipkg-opt package from the Optware package feed". See if wget is actually downloading anything, where it's putting it, and what it's doing with it afterwards.
If it is there, try running it manually. If you see /data/opt/bin/ipkg or /data/opt/bin/ipkg-opt but it claims it's not there when you run it, it may be a library linking error. Mine was looking for /lib/ld-linux.so.3 but it was actually installed at /data/opt/lib/ld-linux.so.3. mount -o remount,rw followed by ln -s /data/opt/lib/ld-linux.so.3 /lib/ld-linux.so.3 fixed that. I also had to run
ln -s /data/opt /opt
ln -s /data/tmp /tmp
before things started working.
By the way:
ntfsprogs - NTFS filesystem libraries and utilities
Could that be of any use? At the moment, it's not possible to mount NTFS storage on the NC
i would love to know how you guys get to this point even. When i try to install the very fist line of the script is an error and then nothing at all happens .... something about not finding busybox or something of that nature.
So you guys are getting WAY farther than I've been able to.
Tkx Tonygoes.
It is there in /data/opt/bin but it reports /data/opt/bin/ipkg: not found
I cannot find a ld-linux.so.3 on my NC at all.
I did the other links et al fro your comments also
obsid:
Try post 12 above:
and I had some other suggestions from someone:
might try thses FIRST the script seems to do it but may not actually get it done.
mount -o remount,rw / /
mount -o remount,rw /dev/block/mmcblk0p5 /system
you should also if tried before do this: rm -rf /data/tmp/
then do the items in post #12 above
NOTE for me the ln -s to ld-linux.so.3 does not work as I do not have that file on my system

[krn.module] CIFS kernel module for X10 GB (SAMBA shares)

Hello guys,
I've compiled the CIFS module for our X10 (stock kernel version for 2.3.3, that is 2.6.29-00054-g5f01537 ).
Introduction
CIFS is for allowing to mount SAMBA/CIFS shares from Windows (mostly), so that they appear like a folder on the phone.
Specifically, you can watch movies on your X10 from a share, without first copying them to the phone. In fact you can mount any SAMBA share and do all operations with it.
There are two modules that do the job: cifs.ko (which is the main one) as well as nls_utf8.ko which just provides UTF-8 support for file/folder names within the shares.
Installation
Once you have unpacked the zip and extracted the two modules into the folder of your choice, the commands are these:
Code:
adb push "nls_utf8.ko" /sdcard/nls_utf8.ko
adb push "cifs.ko" /sdcard/cifs.ko
adb shell
su
mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
cd /system/lib/modules
cp /sdcard/nls_utf8.ko .
cp /sdcard/cifs.ko .
insmod nls_utf8.ko
insmod cifs.ko
mkdir /sdcard/cifs
mount -o username=<yours>,password=<yours>,iocharset=utf8 -t cifs //<serverip>/<sharename> /sdcard/cifs
Now you can cd to your /sdcard/cifs and see the files shared there.
Observations
1. nls_utf8.ko is not mandatory and if your files don't have UTF-8 characters and only ascii, you can skip it IF you remove the isocharset=utf8 from the mount command above.
2. Music will stutter with all players I've tried. found an opinion that might be android lowlevel subsystem for reading mp3 files, and that they don't buffer enough - and given the latency over WIFI, this will create pauses / stuttering in the music. However, you can still copy the audio files, etc.
3. Movie playing works! I've tried RockPlayer for few minutes and didn't have an issue (seems it handles buffering very well) since it is software and thus they don't rely on some Android codec / etc.
4. Skip works! Again in Rock Player, you can skip in the movie and it takes a bit to skip there, but it does.
5. umount usually fails, since I assume, Android apps don't really exit and don't really free the resources. Once a file open, it doesn't let me un-mount saying that the resource / device is busy.
Download
Use it at your own risk!
cifs.zip
Chefs can bundle the files within the ROMs they offer - but please add this link into descriptions so that people can discuss issues they might encounter.
Cool.. Will try..
Sent from my X10i using XDA Premium App
nice! i am gonna try this!
New toy I'll give this a go tonight and report back. Thanks!
Hi viulian,
Thanks for the module. Would you mind if I include it in the hotfix for my rom?
Cheers,
z
zdzihu said:
Hi viulian,
Thanks for the module. Would you mind if I include it in the hotfix for my rom?
Cheers,
z
Click to expand...
Click to collapse
Absolutely no problem Z please do.
This module definetly requires an app to manage CIFS, mounting them with selected user/pass/path.
You can try cifs manager, its good.
Btw i thought the new sources weren't released yet.
I'm using old 2.1 sources and I could build these modules using Sony's blog post about how to compile kernels (with their CodeSourcery compiler) and a bit of Google foo.
Btw, I have another one ready, the cpufreq_interactive one which I'm creating a new thread now.
Later edit:
Although initially I read posts complaining about Sony's decision to keep the old 2.1 kernel (2.6.29) instead of the recommended (2.6.32) for GingerBread, it turned out that it was actually a smart move
Basically, the cifs module at least was much more difficult to port, due to the slow_work.ko module that needed to be compiled as well and inserted before.
viulian said:
Hello guys,
I've compiled the CIFS module for our X10 (stock kernel version for 2.3.3, that is 2.6.29-00054-g5f01537 ).
Introduction
CIFS is for allowing to mount SAMBA/CIFS shares from Windows (mostly), so that they appear like a folder on the phone.
Specifically, you can watch movies on your X10 from a share, without first copying them to the phone. In fact you can mount any SAMBA share and do all operations with it.
There are two modules that do the job: cifs.ko (which is the main one) as well as nls_utf8.ko which just provides UTF-8 support for file/folder names within the shares.
Installation
Once you have unpacked the zip and extracted the two modules into the folder of your choice, the commands are these:
Code:
adb push "nls_utf8.ko" /sdcard/nls_utf8.ko
adb push "cifs.ko" /sdcard/cifs.ko
adb shell
su
mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
cd /system/lib/modules
cp /sdcard/nls_utf8.ko .
cp /sdcard/cifs.ko .
insmod nls_utf8.ko
insmod cifs.ko
mkdir /sdcard/cifs
mount -o username=<yours>,password=<yours>,iocharset=utf8 -t cifs //<serverip>/<sharename> /sdcard/cifs
Now you can cd to your /sdcard/cifs and see the files shared there.
Observations
1. nls_utf8.ko is not mandatory and if your files don't have UTF-8 characters and only ascii, you can skip it IF you remove the isocharset=utf8 from the mount command above.
2. Music will stutter with all players I've tried. found an opinion that might be android lowlevel subsystem for reading mp3 files, and that they don't buffer enough - and given the latency over WIFI, this will create pauses / stuttering in the music. However, you can still copy the audio files, etc.
3. Movie playing works! I've tried RockPlayer for few minutes and didn't have an issue (seems it handles buffering very well) since it is software and thus they don't rely on some Android codec / etc.
4. Skip works! Again in Rock Player, you can skip in the movie and it takes a bit to skip there, but it does.
5. umount usually fails, since I assume, Android apps don't really exit and don't really free the resources. Once a file open, it doesn't let me un-mount saying that the resource / device is busy.
Download
Use it at your own risk!
cifs.zip
Chefs can bundle the files within the ROMs they offer - but please add this link into descriptions so that people can discuss issues they might encounter.
Click to expand...
Click to collapse
Thanks viulian, very nice modules! May I include it in my rom?
Regards
Erick
Hello Erick, yes. Please add a link in your descriptions / thread / patches page etc, so people would also come here to check for possible issues, share experiences etc.
viulian said:
Hello Erick, yes. Please add a link in your descriptions / thread / patches page etc, so people would also come here to check for possible issues, share experiences etc.
Click to expand...
Click to collapse
For sure, thanks!
Hello friend,
Just wondering if I can install this through android terminal rather than adb?
Same commands/process? Thx
Aphex33 said:
Hello friend,
Just wondering if I can install this through android terminal rather than adb?
Same commands/process? Thx
Click to expand...
Click to collapse
Yes - if you handle copying the module to sdcard separately and then you become root in terminal, then it's the same.
viulian said:
Yes - if you handle copying the module to sdcard separately and then you become root in terminal, then it's the same.
Click to expand...
Click to collapse
Thx for quick response, become root in terminal? Explain please.....buy the way your modules rock! Currently using interactive.ko
Aphex33 said:
Thx for quick response, become root in terminal?
Click to expand...
Click to collapse
When you start the terminal, you notice you have a $ sign displayed to the left of the command prompt. That means you do not have the rights to do most things, since $ is for standard (limited) user.
What you need is to type command
Code:
su
And then your prompt will change to the dash sign #.
That means now you have full control over the phone, and you can start typing the commands.
Please double check what you do, and that you typed correctly - otherwise, as root, you might render your phone useless. Do not attempt if you don't feel confident enough and that you know what you are doing.
viulian said:
When you start the terminal, you notice you have a $ sign displayed to the left of the command prompt. That means you do not have the rights to do most things, since $ is for standard (limited) user.
What you need is to type command
Code:
su
And then your prompt will change to the dash sign #.
That means now you have full control over the phone, and you can start typing the commands.
Please double check what you do, and that you typed correctly - otherwise, as root, you might render your phone useless. Do not attempt if you don't feel confident enough and that you know what you are doing.
Click to expand...
Click to collapse
Thank you once again.
viulian said:
When you start the terminal, you notice you have a $ sign displayed to the left of the command prompt. That means you do not have the rights to do most things, since $ is for standard (limited) user.
What you need is to type command
Code:
su
And then your prompt will change to the dash sign #.
That means now you have full control over the phone, and you can start typing the commands.
Please double check what you do, and that you typed correctly - otherwise, as root, you might render your phone useless. Do not attempt if you don't feel confident enough and that you know what you are doing.
Click to expand...
Click to collapse
Hello, so If I have this correct, after placing the module in the correct place I have to type the commands in the first post word for word, correct? Apologize for being a noob, just wanna make sure.
hello guy
I dont know how to mount files from Windows. Someone explains clearly , please
Sorry for being noob. I think this module is awesome but dont know how to use
Got an exec format error when trying to insmod.
What can i try to solve this please ?
Thanks !

Snowball Mod

I ran the Snowball Mod without a hitch. I then tried to run the update but it won't run for some reason. The window flashes some text quickly but then closes so I'm not even really sure why it's not working. Anyone run into this or have any ideas. Thanks in advance!
I haven't had the time to try out the snowball mod, yet -- so I can't offer any advice. But, I would post the issue in the development thread, that's where the most help will be.
Swyped from my B&N Nook Tablet.
Try running it from a command line to keep it up and be able to read any text.
Also, there is a log.txt, if you post that, it can be more helpful.
Yeah I was goin to but I don't have enough posts. I was hoping someone would see it here.
Well... if you post your log.txt and start it from a command-line window rather than double clicking the update.bat, then we can take a look at what's up.
Log file says:
Snowball is reporting: v2.0.2
NO PACKAGE AVAILABLE
Command line:
Snowball is reporting: v2.0.2
There does not appear to be a package for the version snowball is reporting.
Are you sure you're not reapplying an update?
Perhaps you are accidentally trying to apply an "outdate"?
Thanks a lot!
There is no v2.0.2 update package in the zip folder. I renamed v2.0.1 to v2.0.2 and ran. Not sure if this was a good thing to do or not. Any help or direction would be appreciated. Thanks.
No write permissions
Tried to install snowball mod from a macbook pro by just running the snowball.sh. Started up and the B&N stuff was all there, although it looked like it ran without a hitch.
Looked at the log file in the snowball-mod folder and saw a lot of "Read-only file system" business. The first few lines being:
unzip: can't open nook-update-package.zip, nook-update-package.zip.zip, nook-update-package.zip.ZIP^M
rm failed for nook-update-package.zip, Read-only file system^M
Installing nook-update-package...
cd: can't cd to /mnt/media/nook-update-package^M
sh: Can't open install^M
rm failed for /mnt/media/nook-update-package, No such file or directory^M
Click to expand...
Click to collapse
How do you suggest I get around that?
conundrum768 said:
I haven't had the time to try out the snowball mod, yet -- so I can't offer any advice. But, I would post the issue in the development thread, that's where the most help will be.
Swyped from my B&N Nook Tablet.
Click to expand...
Click to collapse
We need 10 legit posts before we are allowed to post in the dev forum
Robotronik said:
Tried to install snowball mod from a macbook pro by just running the snowball.sh. Started up and the B&N stuff was all there, although it looked like it ran without a hitch.
Looked at the log file in the snowball-mod folder and saw a lot of "Read-only file system" business. The first few lines being:
How do you suggest I get around that?
Click to expand...
Click to collapse
Huh... this is weird... /mnt/media should not be read-only... although, I suppose, perhaps if you had it USB mounted, it might end up read-only.
Ensure that you have Automatic USB mounting turned off before you run the script.
You can actually push this update via wifi if you mod the update.bat (or update.sh for linux users) file.
Just turn on ADB Wifi (I prefer adbWireless app) and add the following to your bat file:
Code:
echo Waiting for device...
[B]adb connect XXX.XXX.XXX.XXX:XXXX[/B]
adb wait-for-device
...
adb shell "chmod 755 /data/local/tmp/update-package.sh ; su -c /data/local/tmp/update-package.sh" >> log.txt
if exist reboot adb reboot
[B]adb connect XXX.XXX.XXX.XXX:XXXX[/B]
echo INSTALLATION SUCCESSFUL
Use your IPort given to you by your ADB Wifi app in place of XXXs. Then just run the .bat!
Run from cmd if you don't want the output to vanish right away.
cfoesch said:
Ensure that you have Automatic USB mounting turned off before you run the script.
Click to expand...
Click to collapse
Okay, that got me a little further. Now:
Extracting nook-update-package...
Archive: nook-update-package.zip
creating: nook-update-package/data/
unzip: can't set permissions of directory 'nook-update-package': Operation not permitted
unzip: exiting
Installing nook-update-package...
sh: Can't open install
Click to expand...
Click to collapse
More permissions issues...
Still posting here because I don't have the 10 total posts to go in the Dev forum...
Anyway, I did the factory reinstall, and reran the snowballmod update. It said the root was still there, so I commented out that check from the snowball.sh, reran the package and everything went swimmingly.
Now, for the update:
The terminal spits out this:
Waiting for device...
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
7 KB/s (46 bytes in 0.006s)
Snowball is reporting: v2.0.2
.zipte-package-v2.0.2
There does not appear to be a package for the version snowball is reporting.
Are you sure you're not reapplying an update?
Perhaps you are accidentally trying to apply an 'outdate'?
Click to expand...
Click to collapse
Where the log file gives me:
Snowball is reporting: v2.0.2
NO PACKAGE AVAILABLE
Click to expand...
Click to collapse
The file "update-package-v2.0.2.zip" is in the directory. In the "update.sh" file replaced all instances of "${VERSION}" with "v2.0.2" and it seemed to work fine.
same
Robotronik said:
Still posting here because I don't have the 10 total posts to go in the Dev forum...
Anyway, I did the factory reinstall, and reran the snowballmod update. It said the root was still there, so I commented out that check from the snowball.sh, reran the package and everything went swimmingly.
Now, for the update:
The terminal spits out this:
Where the log file gives me:
The file "update-package-v2.0.2.zip" is in the directory. In the "update.sh" file replaced all instances of "${VERSION}" with "v2.0.2" and it seemed to work fine.
Click to expand...
Click to collapse
I AM HAVING THE SAME PROBLEM.MYBE..I need help some plz make a better howtos for dummies m
The first thing you need to do, if you have no clue what you're doing, is post the contents of the log file in the snowballmod folder.
The ".zipte-package-v2.0.2" seems to be related to adb shell "snowball-ver" returning DOS formatted text, even though you're in a *nix. I really did not expect this to happen with the linux and osx versions of adb, but apparently, they perform the same as cygwin... (cygwin I expected, after all, the adb.exe is a windows program). I will fix the update scripts to take that into account.
Code:
unzip: can't set permissions of directory 'nook-update-package': Operation not permitted
This message is reported by unzip when it is run by a non-root user on the /mnt/media partition.
You do _NOT_ have to run snowball-update though if you've installed snowball-mod fresh with the most recent version.
robtlebel said:
I AM HAVING THE SAME PROBLEM.MYBE..I need help some plz make a better howtos for dummies m
Click to expand...
Click to collapse
The changes made to the script were posted here:
Robotronik said:
Now, for the update:
The terminal spits out this:
Waiting for device...
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
7 KB/s (46 bytes in 0.006s)
Snowball is reporting: v2.0.2
.zipte-package-v2.0.2
There does not appear to be a package for the version snowball is reporting.
Are you sure you're not reapplying an update?
Perhaps you are accidentally trying to apply an 'outdate'?
Where the log file gives me:
Snowball is reporting: v2.0.2
NO PACKAGE AVAILABLE
The file "update-package-v2.0.2.zip" is in the directory. In the "update.sh" file replaced all instances of "${VERSION}" with "v2.0.2" and it seemed to work fine.
Click to expand...
Click to collapse
I had the same issue with the name of the update file being called incorrectly: ".zipte-package-v2.0.2". With that output the script is looking for a file of that name and it's not finding it. I just changed the value of the variable ${VERSION} to v2.0.2 (since that was what was being reported by Snowball as my current version) and all worked after that.
Easy to fix temporarily:
-open "update.sh" in a text editor
-go to line 66 and change
VERSION=`awk '//{ print $2 }' snowball.version`
Click to expand...
Click to collapse
to
VERSION=v2.0.2
Click to expand...
Click to collapse
or whatever version yours shows to be running (v2.0.1, etc). Something tells me it might be important to input the correct current version number in
-save and close the file and rerun it.
EDIT: or wait until cfoesch fixes the scripts
Scripts should be updated. I changed the awk program from just "//{ print $2 }" to "//{ sub('\r', '', $2); print $2 }" ... this means that it works both ways... *insert your favorite "both ways" joke here*
It should also detect if you haven't turned off automount, and warn you about it. If the nook ends up rebooting, then it would tear the USB mount and could cause file corruption. I got around it by putting things in /data rather than /mnt/media, but then realized, if it has to reboot, then it could cause trouble. So better, to just warn them that automount was on, and quit out.
It also detects better if something went wrong in the installation process, and should report that installation has failed, rather than successful under all cases.
Things may have gotten broken in the process, so keep up the bug reports.
I just can't stop Nookin' Around.........god i need to sleep
I decided to check out the update.sh script (can only go so far currently since I have the latest update).
At least for me, (Ubuntu Linux 11.10) I figured something out about the $OSTYPE call to set the $adb variable. I could echo $OSTYPE in the terminal and got a response, but could not echo it in any scripts. Ended up finding the "uname -o" call and that seems to have gotten it to work, although the printout is different.
snowball-update# echo $OSTYPE
linux-gnu
snowball-update# uname -o
GNU/Linux
Changed lines 7 & 8 and seems to have worked:
case `uname -o` in
GNU*|linux*|Linux*)
Now this last part is probably something on my end but: update.sh: 62: ./adblinux: Permission denied
Thanks again for the work (and everyone else involved in rooting/hacking these things )
Indeed. $OSTYPE seems to be specific to bash, and not all sh implementations.
If you don't mind could you do this command and give me the output? "ls -l /bin/sh" and "sh --version" Those two commands should explain exactly which implementation of sh you have. (For instance, on the NT with snowball-mod, the sh is a minimal implementation, and does not support $OSTYPE. But on most OSes I've seen sh is actually a statically linked bash, as it is the most widely used shell scripting language.)
The case on that you provided though could be a poor choice, as GNU*) would match GNU/freebsd, or GNU/openbsd, or GNU/anykernel. Sure it is unlikely, but it is possible.
The permissions issue is not entirely your end, but it is an expected artifact of extracting from a zip file. Although, is suppose performing a chmod 755 on it prior to use would be a good idea in general.

Is it possible to get some standard linux tools into Android?

Ok, I read through several threads here and there and everything I found out here and there was, well, we do not have these tools/commands, but the discussion went into other directions and where never really answered.
My situation:
I do several thing every day, some of them are fun, others are not. The funny things I mostly do myself by hand. The not so funny things, well, shell scripts are funny.
I startet a terminal on my Android (After 2 days of work to get nslookup and dig running on iOS 5.1.1 together with crontab.) and tested some functions/tools I daily need for some of my shell script:
- chown -> works
- chmod -> works
- nslookup -> works
- dig -> up and running
- simple rm, mv, mkdir, rmdir -> check
- crontab -> WTF?! You serious, I LOVE IT!
- zip -> error <- Ouch, that hurts. Sure, gzip, tar and others are there I hope.
- sudo -> even bigger error
- login -> error <- Don't get me wrong, but when there is root, there are other users, ls -la gives me at least 3 users: root, system, radio, and 4 groups: sdcard_r, cache, system, root
passwd -> Ok, I get it, different usermanagment, but the rightsmanagment seems to be the same than in std. linux. I chowned a dir and chmoded some things for testing purpose and I got no access to these files unless I use a file explorer/manager with root, so there is basicly the same rights managment behind it. Switching chown and chmod back to original state, everything works without root access file manager. Oh and "w" doesn't work, not even "who". lsof returns many things, every app is its own user, well, normal behaviour.
I than tested some variables, that are standard, even on iOS (Without doing more than jailbreaking and installing a terminal.)
sudo echo $SUDO_USER -> error <- clear, we have no sudo.
su echo $SUDO_USER -> empty <- Yep, no sudo, no $SUDO_USER
su echo $SU_USER -> empty <- I guessed it, because, well, we have nothing else to guess.
Since variables return empty even when they are not set or do not exist, we can't say that this will work in any way unless we know every damn variable set in the whole system. $SUDO_USER in a normal *nix enviroment returns empty when no sudo is in use currently. If in use, it will return the current user that is running sudo, normaly the logged in user or the corresponding worker taskname that is set in the system. lsof on Android shows many app_XX entries, so like normal under *nix.
Ok, my question:
Would it be possible to get sudo, zip and the $SUDO_USER running on Android? I don't mind the possible security issues that could come with this, I have several SGS2 and 2 of them have no SIM card, these are only gadget tools for command line and other stuff. There is no data on these SGS2 that are important.
Discussion about pro and cons are not welcome. This is just a possibility question. My Linux skill is to low to get these things done myself, so I ask you people who know more about this. And yes, I try to get some shell scripts running on my androids, why not use these wonderful gadgets for productity when most of the people waste time with FB, twitter and co on their mobiles.

Categories

Resources