Help with update-script - Nexus One Q&A, Help & Troubleshooting

Hello,
I need help setting up permissions for a certain program so I can have it installed from my custom rom and work correctly. The line I have is: set_perm_recursive 0 0 0755 0755 DATA:data/com.swype.android.inputmethod, but I am having trouble figuring out what numbers to put for the permissions. I would appreciate any help or direction to an answer as all of my searching and trials have ended in a failure.
Thanks,
Rsotbiemrptson

Know UNIX?
http://forum.xda-developers.com/showthread.php?t=524268
Look for chmod and chown documentation on the web, really easy to find and see, what the numbers mean.
And here's a suggestion for better Google usage: write "set_perm_recursive parameters" and look at the 3rd result. You won't even have to click on the link.

I don't know how I missed that, just one of those days. I don't know UNIX but I am slowly learning.
Thanks,
Rsotbiemrptson

Related

How to filter ads on your G1

You can find the latest version of this app on the slideme app store.
http://slideme.org/application/adfree
This is the old thread, I started a new thread in the general section => http://forum.xda-developers.com/showthread.php?p=40759351
================================================================================================================================================
Spoiled by ad free browsing on my normal desktop computer it became increasingly annoying seeing all the ads on my phone. However it's really easy to make them disappear, although you most likely will need root on the phone.
Download the hosts.txt file from http://www.mvps.org/winhelp2002/hosts.txt, you may need to run dos2unix over the file to remote \r characters, rename the file hosts and copy it to /system/etc on your phone and say goodbye to most ads.
You may find the list to be imperfect, for example some feedburner URLs are "blocked" as a result which can screw with RSS feeds, although it's annoying giving too much info to Google but like everything else in life some things are a trade off.
If you want to root your phone, try this article.
Thanks for this!
As soon as I read the topic title I realised what you were doing and I never thought of it myself.
My hosts file was /etc/hosts though, not /system/etc/hosts
Dark X Dragon said:
As soon as I read the topic title I realised what you were doing and I never thought of it myself.
Click to expand...
Click to collapse
I've been using this technique for a bit, just didn't think to post about it before did a quick search and noticed no one else had so thought I might as well
My hosts file was /etc/hosts though, not /system/etc/hosts
Click to expand...
Click to collapse
Doesn't seem to matter, I just checked the /etc dir and it has the same hosts file.
Actually, /etc is a symbolic link to /system/etc, so your hosts file is really at /system/etc -- however, accessing the file through either path is equivalent.
Ha ha hosts exists on android!? I had no idea. I'm also a spoiled ad-less pc user. This is great. Thanks.
If you can't download the file above (it appears as text in browser), replace .txt with .zip at the end of the url. This will download the zip file which u can later unzip with an unzip app in the market.
Ok. I can't paste over the original hosts file using the phone? Astro and lynda file managers don't do it for me. And yes I am rooted, running 1.5 dudes build. Can this be done only from a PC?
ShatBag1105 said:
Ok. I can't paste over the original hosts file using the phone? Astro and lynda file managers don't do it for me. And yes I am rooted, running 1.5 dudes build. Can this be done only from a PC?
Click to expand...
Click to collapse
You have a couple of options, you can download the terminal app from the market and use it, or you can use ADB to shell into the phone, or wait for someone to code an app to do it all for you.
For the time being go with installing terminal, then type 'su' to become root. That is unless you have a copy of adb handy, if you can 'adb shell' the following commands are the same, except you can copy and paste.
Then remount the system partition read-write.
Code:
mount -o remount,rw /dev/block/mtdblock3 /system
Then you go into the etc dir
Code:
cd /system/etc
Then you can rm the hosts file
Code:
rm hosts
Then grab the hosts.txt file
Code:
wget http://www.mvps.org/winhelp2002/hosts.txt -O hosts
Always more than one way to skin a cat, but the above works for me(tm)
lbcoder said:
Actually, /etc is a symbolic link to /system/etc, so your hosts file is really at /system/etc -- however, accessing the file through either path is equivalent.
Click to expand...
Click to collapse
Ugghh, I read that ages ago but really didn't commit it to memory. It is now. =)
There's a fair chance I won't get around to it but I'm tempted to take this ad blocking further. Namely an automatic app but there might be more to add to it.
Thanks for the help delta. I figured it had to be done in terminal. And you know, this would definitely become very popular as an app.
I'm a dummy its etc not ect
delta_foxtrot2 said:
Then grab the hosts.txt file
Code:
wget http://www.mvps.org/winhelp2002/hosts.txt -O hosts
Always more than one way to skin a cat, but the above works for me(tm)
Click to expand...
Click to collapse
(I am using the terminal program on the phone)
Until the above step, no problems
After typing in the above I get the following message:
"bad address "www.mvps.org"
I checked for typing errors, tried it 3 times but get the same error message
Any suggestions please?
thanks
nyayo99 said:
(I am using the terminal program on the phone)
Until the above step, no problems
After typing in the above I get the following message:
"bad address "www.mvps.org"
I checked for typing errors, tried it 3 times but get the same error message
Any suggestions please?
thanks
Click to expand...
Click to collapse
Try it without the http://www. It might work like that. This is a lot harder than it should be lol. The g1 is putting up a fight!
ShatBag1105 said:
Try it without the http://www. It might work like that. This is a lot harder than it should be lol. The g1 is putting up a fight!
Click to expand...
Click to collapse
Thanks, but this didn't work either.
Some googling indicated a possible DNS issue.
So I looked up the IP address (209.68.48.119), substituted that into your instructions and presto, everything worked!
Many thanks for the ad killer option for the G1
Aah beautiful work. Just to clarify for newbs like me. The last line is (# wget http://209.68.48.119/winhelp2002/hosts.txt -O hosts). Make sure that -O hosts is a captialized O.
ShatBag1105 said:
Aah beautiful work. Just to clarify for newbs like me. The last line is (# wget http://209.68.48.119/winhelp2002/hosts.txt -O hosts). Make sure that -O hosts is a captialized O.
Click to expand...
Click to collapse
Yes, capital letter o, lower case o stores the output of wget into the file which isn't the desired outcome
I plan on suggesting the following URLs to the hosts.txt guy to block admob ads in apps
p.admob.com
analytics.admob.com
r.admob.com
In the mean time you can manually add it to the hosts file yourself, just copy and past from another line.
After updating the hosts file you may need to reboot or wait for the hostname to expire from the internal lookup cache, unless someone knows a quick way to flush the cache to speed up the process that is.
Thanks for this. Worked great for me. Very helpful tutorial.
Just uploaded "AdFree" to android market, this does all the steps I laid out manually at the touch of a button.
Its funny how
127.0.0.1 localhost
is the only thing blocked in the /system/etc/hosts file. lol.
andonnguyen said:
Its funny how
127.0.0.1 localhost
is the only thing blocked in the /system/etc/hosts file. lol.
Click to expand...
Click to collapse
That isn't "blocked" and in fact nothing gets blocked by the hosts file it just points hostnames to the local system, which usually has no web server running so the connection fails immediately.
However you MUST have localhost listed or various things will fail and cause all sorts of issues.
New version of AdFree is now up, I have the app adding the admob hostnames to the bottom of the list.

UNIX Script Help

Who knows if this is the right sections but, I need some quick help on a shell script to run on my phone. Two questions:
How do I change the following script to search recursively through folders for *.lm and chmod them?
Code:
#!/sbin/sh
for file in /data/app/*.lm ; do
chmod 0644 $file
done
I can't find a switch to search recursively... did I look hard enough?
Second, is there any way that I could find all files in a specified directory (e.g. /test/*.jpg) that were created in timeframe relative to now (e.g. in the last 10 mins)? I want to chmod those too so would need to be able to pass $file.
Now I know the first one's easy so am crossing fingers for a quick reply, thanks in anticipation.
You're trying to make that way harder than necessary.
chmod 0644 /data/app/*.lm
GldRush98 said:
You're trying to make that way harder than necessary.
chmod 0644 /data/app/*.lm
Click to expand...
Click to collapse
I did a poor job of shortening my example above really, it looks stupid upon reflection (I didn't notice that when I first posted it ) chmod is originally part of a larger process that I run on each file in a directory (and want to include subs), I need/want to complete one before I start the next.
The recursive thing is hurting me at the moment though.
Try this, and if the output looks right, change "echo" to "chmod 0644"
Code:
for file in $(find /data/app -iname *.lm); do echo $file; done
fubaya said:
Try this, and if the output looks right, change "echo" to "chmod 0644"
Code:
for file in $(find /data/app -iname *.lm); do echo $file; done
Click to expand...
Click to collapse
Nice, thank you I was not seeing the wood for the trees. I appreciate the fresh perspective.
Well it's not perfect. I tinkered around with it and it doesn't seem to work if you are in the /system/app directory. In fact, "find *.apk" (I used apk since I don't have any lm files) is the only thing that seems to work, and I don't know if it's recursive without testing more. It also doesn't work if you're in the /sdcard or /etc directories and probably others but I gave up testing after those two. Very annoying. I hate busybox and wish someone would port the real gnu tools to Android so we didn't have to use it.
EDIT: To be clear, while it doesn't work as it should, it works perfectly if you "cd /" then do the commands.
Anyway, "find --help" should help with the second part of your question. It looks like "find -mmin 10" may be what you want.
fubaya said:
Well it's not perfect. I tinkered around with it and it doesn't seem to work if you are in the /system/app directory. In fact, "find *.apk" (I used apk since I don't have any lm files) is the only thing that seems to work, and I don't know if it's recursive without testing more. It also doesn't work if you're in the /sdcard or /etc directories and probably others but I gave up testing after those two. Very annoying. I hate busybox and wish someone would port the real gnu tools to Android so we didn't have to use it.
EDIT: To be clear, while it doesn't work as it should, it works perfectly if you "cd /" then do the commands.
Anyway, "find --help" should help with the second part of your question. It looks like "find -mmin 10" may be what you want.
Click to expand...
Click to collapse
Thanks man. I have to agree that whilst busybox is great (and necessary) it seems to have some quirks. I even got the dir wrong in my example, there should only ever be apk's in /data/app - I am searching /data/data/.
I thought I encountered the same as you above last night but I was tired and just stopped... I ran it against /system/ on a fully booted phone and it didn't seem to produce the result I expect but in recovery it did... ? (I changed the sh location as required).
Either way, you've been a great help to move me forward, thanks!

{TOOL}MetaMorph Builder v2-Linux Only[8-5]

This could be considered part of the development forum or the apps and theme forum depending on how you look at it. if you have an issue, just click the report button and request that it be moved. no need to flame and troll and post that you reported it, just do it and move on.
Lots of people have asked me how to put together a theme control file, and its actually VERY easy but this tool makes it even easier.
this is an example of a theme control file created by this tool
Test-Theme.xml
Code:
<themename>Test-theme</themename>
<author>tater-salad</author>
<phone>Android Phone Codename Hulk</phone>
<rom>CM 8</rom>
<item>Phone.apk</item>
<path>/system/app<path>
<item>framework-res.apk</item>
<path>/system/framework</path>
<description>Requires reboot</description>
<item>FM-Reciever.apk</item>
<path>/data/app<path>
<item>My-custom-app.apk</item>
<path>/data/app<path>
run the mm-builder script and follow the on screen directions. you will of course need to put the correct replacement files in their respective directories, but this script will make all the right folders and set up your theme.xml for you. Bash scrip means linux only. This is also a super easy script, so i may get a batch version soon.
You can extract this file to any directory
All thanks to Stericson. W/O him we wouldnt have a metamorph app to begin with
######################################################################################################
v2
includes these additions
Code:
mkdir $app
mkdir $app/res
mkdir $app/res/drawable
mkdir $app/res/drawable-mdpi
mkdir $app/res/drawable-land-mdpi
mkdir $app/res/drawable-port-mdpi
these are the commonly used directories when it comes to theming. now all the sub-folders should be set up right.
So you are saying this will create the res folder and other folders needed?
ya.
it works by reading the user input.
you specifiy what apps you will be morphing, and the script adds the necessary lines to the .xml and creates the folders for them too.
EDIT:
nevermind, i see what you mean. it doesnt set up the sub-folders.
let me work that up and ill have a new version up-if you want to use before then you will need to make the sub-directories yourself.
ban_dover said:
ya.
it works by reading the user input.
you specifiy what apps you will be morphing, and the script adds the necessary lines to the .xml and creates the folders for them too.
Click to expand...
Click to collapse
EDIT: Since this is Andrizoid, for all I know its a virus you stole from someone and put your info in.
droidkevlar said:
Very cool. If you get a winblows version out, this will make it very easy to change icons for all apps. Nice work!
Click to expand...
Click to collapse
as i said in the other thread, batch is pretty alien coming from bash, but im sure it can be done pretty easily.
it is really easy to install ubuntu on a VB though. i have wyndoze on a VB with Ubuntu as the host, so thats why all my stuff is bash haha.
once i start messing aroud on my VBox and get a feel for batch ill start working on it. its a really simple script if you look at it so it shouldnt involve too much hassle.
adding
Code:
mkdir $app
mkdir $app/res
mkdir $app/res/drawable
mkdir $app/res/drawable-mdpi
mkdir $app/res/drawable-land-mdpi
mkdir $app/res/drawable-port-mdpi
drawable, drawable-mdpi, drawable-port-mdpi, and drawable-land-mdpi seem to be the only onces ever used in a theme-i checked like 15 of them that i have saved. let me know if i missed any commonly used folders and ill be sure to get them in soon.
noticed that i missed two "/" characters in the script that will cause the them xml to not run right. ill fix it in a minute. just look at the other thread under development though-i dont want 2 threads
droidkevlar said:
EDIT: Since this is Andrizoid, for all I know its a virus you stole from someone and put your info in.
Click to expand...
Click to collapse
Are you serious? That's just stupid, leave him alone.

[Q] Permanently change system file

i want to change the file "sys/devices/i2c-0/0-0066/leds/jogball-backlight/period" to "2"
to do this i have to edit the permissions for it to work, but every time i reboot it reverts back to the original file
does anyone know how i can change this file permanently?
when i change it, it says file backed up as "period.bak" but i cant find where this is backed up to
This is not a real file. This is a virtual file - interface to device driver parameters. To change it permanently, you need either to see where the initial value comes from and change it there somehow, or to overwrite the driver interface file each boot.
Don't suppose you know where the original file is?
Sent from my Nexus One using XDA App
I don't know if this will work as it is piecing together multiple responses in multiple threads, but I believe if you add a script into the /etc/init.d folder, it will run it.
I believe it needs to be called something that has numbers at the front. Something like 99setpulserate
Code:
#!/system/bin/sh
if [ -e /sys/devices/i2c-0/0-0066/leds/jogball-backlight/period ]
then
/system/xbin/echo "2" > /sys/devices/i2c-0/0-0066/leds/jogball-backlight/period;
fi;
Again, save it something like 99setpulserate and give it 777 permissions
Code:
chmod 777 /etc/init.d/99setpulserate
Hope this works. Let me know.
bassmadrigal said:
I don't know if this will work as it is piecing together multiple responses in multiple threads, but I believe if you add a script into the /etc/init.d folder, it will run it.
I believe it needs to be called something that has numbers at the front. Something like 99setpulserate
Code:
#!/system/bin/sh
if [ -e /sys/devices/i2c-0/0-0066/leds/jogball-backlight/period ]
then
/system/xbin/echo "2" > /sys/devices/i2c-0/0-0066/leds/jogball-backlight/period;
fi;
Again, save it something like 99setpulserate and give it 777 permissions
Code:
chmod 777 /etc/init.d/99setpulserate
Hope this works. Let me know.
Click to expand...
Click to collapse
sorry, 777 permissions? as in tick all of em? never mind
maxib123 said:
Don't suppose you know where the original file is?
Sent from my Nexus One using XDA App
Click to expand...
Click to collapse
Most probably it's hard-coded somewhere in the system, which would require recompiling. Overwriting the value each boot, for example with init.d scripts as suggested above, would be much simpler. Just make sure that the value is initialized by the time you're executing your script, and that the ROM is configured to run them.
Jack_R1 said:
Most probably it's hard-coded somewhere in the system, which would require recompiling. Overwriting the value each boot, for example with init.d scripts as suggested above, would be much simpler. Just make sure that the value is initialized by the time you're executing your script, and that the ROM is configured to run them.
Click to expand...
Click to collapse
how would i do that?
bassmadrigal said:
I don't know if this will work as it is piecing together multiple responses in multiple threads, but I believe if you add a script into the /etc/init.d folder, it will run it.
I believe it needs to be called something that has numbers at the front. Something like 99setpulserate
Code:
#!/system/bin/sh
if [ -e /sys/devices/i2c-0/0-0066/leds/jogball-backlight/period ]
then
/system/xbin/echo "2" > /sys/devices/i2c-0/0-0066/leds/jogball-backlight/period;
fi;
Again, save it something like 99setpulserate and give it 777 permissions
Code:
chmod 777 /etc/init.d/99setpulserate
Hope this works. Let me know.
Click to expand...
Click to collapse
just checking, does the "99setpulserate" file just need to be a new file, or do i copy it over and rename it?
I'm not exactly sure what you mean. It needs to be a new file, but you can copy the text and past it in (if you use adb, or the browser on the phone).
The numbers at the beginning are the order in which things should be run (if I remember correctly from my old linux classes, Slackware uses the RC files which is slightly different). So technically, you can pick any number, but it is best to leave user scripts at 99 so that everything that needs to get loaded beforehand can get loaded.
bassmadrigal said:
I'm not exactly sure what you mean. It needs to be a new file, but you can copy the text and past it in (if you use adb, or the browser on the phone).
The numbers at the beginning are the order in which things should be run (if I remember correctly from my old linux classes, Slackware uses the RC files which is slightly different). So technically, you can pick any number, but it is best to leave user scripts at 99 so that everything that needs to get loaded beforehand can get loaded.
Click to expand...
Click to collapse
yeh... its doesnt work :L
maxib123 said:
yeh... its doesnt work :L
Click to expand...
Click to collapse
What if you manually run the file?
Code:
sh 99setpulserate
See if it is a screwup in the script or my understanding of the init system of Android (I am leaning towards the second one, because I double checked the script and it seems fine).
bassmadrigal said:
What if you manually run the file?
Code:
sh 99setpulserate
See if it is a screwup in the script or my understanding of the init system of Android (I am leaning towards the second one, because I double checked the script and it seems fine).
Click to expand...
Click to collapse
2: not found
tried on adb and emulator
Include the full path to the script when you run it from shell.
I don't know why it wouldn't be working, but I suppose worst case, you could always just add the contents of the script (except for the first line) to the 20userinit file at the bottom.
maxib123 said:
Don't suppose you know where the original file is?
Sent from my Nexus One using XDA App
Click to expand...
Click to collapse
i can show you exactly where the source code is for this file. its the microp.c file in arch/arm/mach-msm folder of the source code kernel.
EDIT: here is the actual file source code.
https://github.com/CyanogenMod/cm-k....37/arch/arm/mach-msm/board-mahimahi-microp.c
you could possibly have someone compile a kernel with changes to this that would set it to your value so you wouldnt have to mess with it each boot up. but i havent look at the code yet to know, so i'll take a look and see.
EDIT: so it looks like when powered up this driver defines the particular data in question from this register address:
Code:
#define MICROP_I2C_WCMD_JOGBALL_LED_PERIOD_SET 0x5D
so you could easily just add some code to set it to your value of 2 upon initialization. i want to say that you can permanently set that register address to a different value. but it seems like its getting cleared upon each reboot, so your best option is to just have the code set it manually.
probably easier than compiling your own kernel would be to just create some simple BASH script that does this upon boot up. though the more fun proper way is change the code.
Jack_R1 said:
Include the full path to the script when you run it from shell.
Click to expand...
Click to collapse
Yeh I did
Sent from my Nexus One using XDA App
How about creating a pre-modified version of the period file, and have the init overwrite the current one at each boot, rather than trying to edit it in the fly...?
danger-rat said:
How about creating a pre-modified version of the period file, and have the init overwrite the current one at each boot, rather than trying to edit it in the fly...?
Click to expand...
Click to collapse
what do i need to do to do that?
If you look at that code, its not an actual file but just a virtual register read from the hardware. So your only option is to create a startup init script to write your desired value to that register (file) on boot up.
why has it changed? it used to be how i want it on the older versions of cyanogen, isnt there some files i could just take from those files and take it over?? seems like a much simpler option :L

root: chmod 4777 or 4755?

just wondering which i should do because ive seen both, or if it didnt really matter which. thanks for the help, and a big thanks to everyone that was involved in this achievement!
EDIT: now ive seen 6755 too... whats the permission differences between all of these?
EDIT 2: i did 4755 ill do some more research and change it if i find a reason to, or someone tells me why i need to before hand
if it matters, i used 4755 and its giving me the correct permissions
It "Should" not matter ether way as long as you have the suid bit set along with read rights for owner. The file system will be read-only so what you really need is the ability for the file to run and to run at root privileges.
Looking at other files in the /system/bin directory they are mostly set to 755. So I would go with 4755.

Categories

Resources