SuperSU /su/su.d - SuperSU

Hey all,
I have rooted my Nvidia Shield TV, and now i am trying to do some "startup" scripts. Since it does not have init.d i was glad when i saw this directory and read the documentation... however my simple script does not seem to work, or maybe i am getting it wrong...
The directory and the file named 00mytest are both chmod 700
Code:
#!/su/bin/sush
(
echo "test" >> /data/test.txt
)&
but the file does not get created i thought maybe remounting or something but choosing /mnt/sdcard/Download does not work as well
Any help would be appreciated.

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!

[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.

Can't run a script

hello I'm trying to run a script but I can't it gives me the errors in screenshot. I run it as root. I'm s-off.
here's the script. (note that I can do this manually with a file explorer)
chmod 777 /sys
chmod 660 /sys/android_camera_awb_cal/awb_cal
cp /sdcard/htcm8awb/awb_cal /sys/android_camera_awb_cal/awb_cal
MaRcIuPT said:
hello I'm trying to run a script but I can't it gives me the erros in screenshot. I run it as root. I'm s-off.
here's the script. (note that I can do this manually with a file explorer)
chmod 777 /sys
chmod 660 /sys/android_camera_awb_cal/awb_cal
cp /sdcard/htcm8awb/awb_cal /sys/android_camera_awb_cal/awb_cal
Click to expand...
Click to collapse
Need some more information, please. First off, do you have an HTC One m7 (Sprint) or an HTC One M8? From your script, it looks like it is made for the M8. This is the thread for the m7 Sprint variant.
MarkBell said:
Need some more information, please. First off, do you have an HTC One m7 (Sprint) or an HTC One M8? From your script, it looks like it is made for the M8. This is the thread for the m7 Sprint variant.
Click to expand...
Click to collapse
I have the m7 international (I believe this section is for m7 any version), I'm only replacing a file with the script.
MaRcIuPT said:
I have the m7 international (I believe this section is for m7 any version), I'm only replacing a file with the script.
Click to expand...
Click to collapse
Did you ever have any luck? Can you try asking the question to the person who wrote the script?
It's quite possible the script is for the m8 since the script names an m8 folder, but I'm not an expert on scripts by any means. @clsA: Do you know what may be going on here?
Do those directories referred to in your screenshot actually exist on your phone?
Also: I was wrong about this being Sprint variant exclusive. My bad on that.
MaRcIuPT said:
hello I'm trying to run a script but I can't it gives me the errors in screenshot. I run it as root. I'm s-off.
here's the script. (note that I can do this manually with a file explorer)
chmod 777 /sys
chmod 660 /sys/android_camera_awb_cal/awb_cal
cp /sdcard/htcm8awb/awb_cal /sys/android_camera_awb_cal/awb_cal
Click to expand...
Click to collapse
Try using SManager to run the script. It might help.
MarkBell said:
Did you ever have any luck? Can you try asking the question to the person who wrote the script?
It's quite possible the script is for the m8 since the script names an m8 folder, but I'm not an expert on scripts by any means. @clsA: Do you know what may be going on here?
Do those directories referred to in your screenshot actually exist on your phone?
Also: I was wrong about this being Sprint variant exclusive. My bad on that.
Click to expand...
Click to collapse
I can rename the folder.... it's simply a folder. the scrip is made for m7. not m8. It does work for some in init.d and some don't.. like me. and I tried to run the script to see why and this is what happens. the folders are there because as I said I can do that step by step in ES explorer, change permissions then replace the file I want.
Atishay Jain said:
Try using SManager to run the script. It might help.
Click to expand...
Click to collapse
with Smanager I get the message is attached. :\
I tried to run a cp command in a terminal (root) and it says the same thing " I/O error" the other steps in script I did successfully in a terminal.
Tried too with 'busybox cp' command and I get " cp: can't create '/sys/android_camera_awb_cal/awb_cal': File exists " so I know the file exists that's why I wan't to replace it xD my head hurts. Searched a lot why I can't copy and no success.
MaRcIuPT said:
I can rename the folder.... it's simply a folder. the scrip is made for m7. not m8. It does work for some in init.d and some don't.. like me. and I tried to run the script to see why and this is what happens. the folders are there because as I said I can do that step by step in ES explorer, change permissions then replace the file I want.
with Smanager I get the message is attached. :\
I tried to run a cp command in a terminal (root) and it says the same thing " I/O error" the other steps in script I did successfully in a terminal.
Tried too with 'busybox cp' command and I get " cp: can't create '/sys/android_camera_awb_cal/awb_cal': File exists " so I know the file exists that's why I wan't to replace it xD my head hurts. Searched a lot why I can't copy and no success.
Click to expand...
Click to collapse
I am not able to get the exact reason for the problem but most such things get solved on updating busybox. Try doing that. Use the tool by jrummy from the market or download the busybox wraithdu installer script from the v6 supercharger thread by zeppelinrox.
MaRcIuPT said:
hello I'm trying to run a script but I can't it gives me the errors in screenshot. I run it as root. I'm s-off.
here's the script. (note that I can do this manually with a file explorer)
chmod 777 /sys
chmod 660 /sys/android_camera_awb_cal/awb_cal
cp /sdcard/htcm8awb/awb_cal /sys/android_camera_awb_cal/awb_cal
Click to expand...
Click to collapse
i would guess you're using Windows Notepad (or similar) to edit/create that script?
you need to use UNIX style EOL delimiters for those commands to work.
EDIT: i've attached an example, the same script (just lists directory contents), looks the same in the Script Runner, once saved with Windows EOL delimiters, gives the first output,
same script with UNIX EOL, gives the second output.
nkk71 said:
i would guess you're using Windows Notepad (or similar) to edit/create that script?
you need to use UNIX style EOL delimiters for those commands to work.
EDIT: i've attached an example, the same script (just lists directory contents), looks the same in the Script Runner, once saved with Windows EOL delimiters, gives the first output,
same script with UNIX EOL, gives the second output.
Click to expand...
Click to collapse
Yes I used the notepad to edit the original. now with your help I did understand and used the notepad++, converted to UNIX EOL and saved as script (sh). No errors now on missing directories but I can't copy/replace the file even with cp -f to force it. I can't understand which command ES explorer uses when I manually copy the file, because it replaces the file successfully.
MaRcIuPT said:
Yes I used the notepad to edit the original. now with your help I did understand and used the notepad++, converted to UNIX EOL and saved as script (sh). No errors now on missing directories but I can't copy/replace the file even with cp -f to force it. I can't understand which command ES explorer uses when I manually copy the file, because it replaces the file successfully.
Click to expand...
Click to collapse
Not sure, but
Are you running the script as root?
And maybe you need file permission to be 666 instead of 660.
Sent from my HTC One using Tapatalk
nkk71 said:
Not sure, but
Are you running the script as root?
And maybe you need file permission to be 666 instead of 660.
Sent from my HTC One using Tapatalk
Click to expand...
Click to collapse
Yeah Always run on root. Tried 666 and 777. Tried with cp, cat, rm first then CP. No success.
Sent from my HTC One using XDA Free mobile app

Categories

Resources