yashsingh1/xdaforums huggingface dataset:
[Asus Transformer TF700] elfaure:
It still blows my mind how difficult this simple modification was to implement and that it couldn't be done in a boot script. Android is missing the easy edit environment variable string for $PATH like in Windows.

I probably should have asked this long before hacking on it, but if I were to have made a syntax error editing the mkshrc file such that the $PATH was never formed (no /system/bin and/or no /system/xbin), would my system still boot?
[Asus Transformer TF700] elfaure:
And a command pipe stringing exercise. _That 's a powerful one-liner there. Why specifically 10 listed? Is that a limitation of one of the three commands?

[MENTION=5234163]shardsx[/MENTION] I bet you could use [MENTION=4878287]_that[/MENTION] 's code above to pipe into your shotgun method to focus the mounts only on the 10 most needed (largest /cache) apps.
[Asus Transformer TF700] _that:
Android doesn't need a user-editable PATH. And the environment editing GUI in Windows is a PITA.

Yes, because Android doesn't need the shell to start up and the initial PATH is set in /init.rc.

Do your homework (listed below the one-liner). :)
[Asus Transformer TF700] elfaure:
Weather or not you agree its needed, it would be nice if Android supported it for users like myself that find a need to expand (add to) their path. I think you have misinterpreted what I am saying here regarding Windows. Editing the PATH in Windows (XP) couldn't be easier:

Start Menu>Rt. Click My Computer>Properties>Advanced Tab>Environment Variables>System Variables (Second List)>6th item in list is PATH>Edit it directly
[Asus Transformer TF700] _that:
Those who use a Unix shell are expected to be able to edit simple config files.

You call *that* easy? And then you get a pathetic one line edit window that shows maybe 50 characters. You cannot add comments, you can't temporarily comment out parts, you can't use variables or conditions, ...

The config file solution is vastly superior.
[Asus Transformer TF700] elfaure:
It may be superior WRT flexibility but where and how to add to $PATH in Android would be considered "cryptic" and "non-user friendly" in comparison to Windows by the average user. Having to add a path inside a for loop in a config file is pretty cryptic and not very user-friendly. Having to seek expert advice on how to get this accomplished is not very user-friendly. Having no menu option in settings>developer options to do this is not very user-friendly. I would think many users would like to customize their paths and be able to easily change that configuration from a menu driven UI. That's my opinion.
[Asus Transformer TF700] _that:
The average user is supposed to use apps from the Play Store and not play with the shell. :)

And for those advanced users that write shell scripts, config files are very user friendly, because they are also just shell scripts.

You absolutely don't have use this loop. You can just as well write something like "PATH=/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin:/data/local/myscripts" at the end of mkshrc, and it will work fine.
[Asus Transformer TF700] elfaure:
I did know that, but I wanted to let the stock for...continue block run its course then simply add to that output and in order to do so you have to add your path addition inside the for loop, making it somewhat cryptic.

I'm glad you posted the above example of a hard path as opposed to a constructed path. And I have a question about that. Why does the Root Checker app show a long path like you have above including /sbin:/vendor/bin:/system/sbin and from the terminal when you "echo $PATH" those are not included?

[Edit]

Attempt to answer my own question. Because init.rc sets up the initial path which is the path including the above + /system/bin:/system/xbin. When you run a terminal shell, mkshrc gets executed resetting the path to what's in that file.
[Asus Transformer TF700] _that:
That's the path I get in an adb shell, which is also set in /init.rc. Some entries seem to be removed by jackpal's terminal emulator, but you can turn that off in the settings ("Verify PATH entries").
[Asus Transformer TF700] elfaure:
Isn't this the reason?

Because init.rc sets up the initial path which is the path including the above (/sbin:/system/sbin:vendor/bin) + /system/bin:/system/xbin. When you run a terminal shell, mkshrc gets executed resetting the path to what's in that file.
[Asus Transformer TF700] elfaure:
Nope I was WRONG again. That did it [MENTION=4878287]_that[/MENTION]. When will I learn? (but its fun to try for yourself).

Why are these additional directories considered "inacccessible" by the terminal app if you are rooted?

[Edit] I can access /sbin but NOT /system/sbin or /vendor/bin from the terminal? I can access /sbin but I see neither /system/sbin nor /vendor/bin from either ES file explorer run as root or root explorer. They seem to be completely masked from the system.

u0_a87@android:/ $ echo $PATH
/Removable/MicroSD/Scripts:/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
u0_a87@android:/ $ su
*** xyzzy 10087 happened ;) ***
u0_a87@android:/ # echo $PATH
/Removable/MicroSD/Scripts:/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
u0_a87@android:/ #
[Asus Transformer TF700] becomingx:
They don't exist in ASUS's ROM is all. That PATH value is set by the default Android init.rc, see line 31 here.

It's possible that some previous versions of Android used `/system/sbin' or `/vendor/bin' and it's just legacy code that hasn't been expunged; or maybe some OEMs might create those in their own ROMs they ship. *shrug*
[Asus Transformer TF700] diofar:
I am trying to execute this script through SManager, but when I press Run, I get the following:

failed: invalid argument

mount: Operation not permitted

failed: No such file or directory

mount: No such file or directory

What is going wrong?
[Asus Transformer TF700] elfaure:
Notice in SManger in the upper left corner the icon for "su" next to "boot". You need to highlight this "su" then press RUN to run the script AS ROOT. Your errors are indicative of not running AS ROOT.

Not all the errors are really errors. The first, second and fourth are not running AS ROOT errors. The third is an error for "rm -rf" since there are no files to delete in that directory. You can silence that error by adding "2>&-" after a space to the end of the line in the script (but I thought I already did that for REV3, but not for REV2.)
[Asus Transformer TF700] diofar:
But I actually do that. I press su and it is highlighted. Do I need to do anything special to super su app?
[Asus Transformer TF700] elfaure:
* [MENTION=5234015]diofar[/MENTION] * Did you get it working? Were those errors you posted from a single script run or multiple runs? Was it a bad su or something else? I noticed you thanked me for one of my posts but you did not post any output or feedback so I hope (almost wrote ass-u-me but I caught myself) I helped you fix the problem. If not, please let me know how I can further assist.

If you run the "mount | grep _cache" line of code and see all the tmpfs mounts for all of your browsers then the script is running to completion and working regardless of (passable) errors you may see at the terminal. You can pretty much disregard all errors EXCEPT the mount errors less "device or resource busy" meaning its already mounted. Both of your mount errors are a problem and those mounts were never created. Both of your failed errors are not really a problem as previously outlined. I'm working on a version that better silences passable errors on execution. See new structure in post below this one.
[Asus Transformer TF700] _that:
I don't understand why you unmount at all - a startup script can expect that no cache directories have been mounted yet.
[Asus Transformer TF700] elfaure:
Yes, true if used as a startup script. But this script doesn't necessarily need to be run on startup on sub 4.2 devices. It could just as well be run after boot in which case mounts may already exist.

Any feedback on silencing this umount line of code when it executes and why I can't seem to redirect stdout and stderr to /dev/null? Can this only be done for some commands but not others? Why does it generate "text file busy" errors? [See my post about this a couple back]
[Asus Transformer TF700] _that:
No idea, thus I tried to argue the problem away. ;)

The usual form that everybody uses in shell scripts is "somecommand >/dev/null 2>&1" - if that doesn't work then I don't know why.
[Asus Transformer TF700] diofar:
Thank you for your interest. I did not find time to answer, as I am currently planning my vacation to Hamburg. But I just tried some things.

So, I run SuperSU and it said that it had to update the binaries. It did that. Then I tried to run again the version 2 of the script with ScriptManager, and it reported the following:

failed: Invalid argument

failed: No such file or directory

mount: No such file or directory

Then, I get a message that everything is successful, and the output:

browser_cache /data/data/com.android.browser/cache tmpfs rw.....

From that, I think that we can understand that everything is fine.

But, if I go to a terminal, and write mount | grep _cache, I am not getting anything as an output.

Also, if I write mount | grep tmpfs, also I can not find any entry for browser cache. I am getting:

tmpfs /storage/emulated tmpfs rw,.....

If I explicitly write the script in the terminal, everything works fine. It looks like SManager does not do the work right.

So, based on all of these, what are your suggestions?
[Asus Transformer TF700] elfaure:
I got to the bottom of it. The error happens when the script file is open for editing in another app when you try to run it. A recent update for ES note editor must have changed something about leaving files open as I have been leaving it open (but not for editing) in another ES window and running it from the terminal in a different window for quite some time now without issue. Now anytime its open weather for editing or not the OS sees it open for editing and gives "text file busy" error. I'm laughing now at the wasted time I spent trying to silence the umount line in relation to this unrelated error which I thought was related.

Also, not knowing the answer to my question means I have to dock you 1/2 a tally point. Not like a full point when you give either the wrong answer or one that doesn't work. But trying to duck the question and getting caught on it is another 1/2 point deduction so you and [MENTION=2446267]becomingx[/MENTION] are back on even ground just -1 point below GOD :) I'm at -45 and heading more negative by the script.
[Asus Transformer TF700] elfaure:
I see your problem. It looks like you are on 4.2 based on your mount | grep tmpfs output (ie:emulated). From what I know about 4.2 you need to run this script as root *at boot* and that is the *only way it will work*. It won't work after boot because of changes in the firmware require the mounts to be created during the booting process. SM is showing you an eronious success inside its shell, but outside its shell it fails because the system has already booted. Re-hightlight su and boot in SM, run it once in SM so these settings stick, reboot, don't re-run the script from either SM or terminal after you reboot, and then go to the terminal and "mount | grep _cache" and you should then see your mount there just like you think you do in SM now. I believe this will solve you problem.

I am on 4.1 so I can't test all aspects of your failure mode. What is interesting is the successful output you get after running the script "browser_cache /data/data/..." in SM is driven from the exact same code that fails for you at the terminal "mount | grep _cache". Take a look at the last line in the script (open it as a txt file). I think this proves its a SM shell issue. I state that this must be run as root AND at boot on 4.2 on the first page write-up, but I should have thought before now to ask you what firmware version you were running (sound of me kicking myself in the head - thump -thump).

Have a great vacation!
[Asus Transformer TF700] _that:
In Android 4.2, apps can still mount stuff for themselves, but no other app will see the mount. So e.g. what you mount in a terminal can be used from programs inside that terminal, but not from another app.
[Asus Transformer TF700] diofar:
Thank you very much for your wishes and help! Yes, I am currently running 4.2. I hope your suggestion solve the problem. I am currently at work, but I will try it in the evening (here in Germany, so morning for USA), and I will post the (hopefully good) results.

Thanks again!
[Asus Transformer TF700] diofar:
Unfortunately it does not work even that way. If I write mount | grep tmpfs or _cache in a terminal, I am not getting what I should. And also I can not notice any performance gain.

What else can I try?
[Asus Transformer TF700] elfaure:
Be aware that after you highlight su and boot for a script in SM, you have to run that scipt in SM at least once for the settings to become permanent for that script. If you back out or reopen SM and browse to your script you should see two icons to the left of your script name, one for su and another for boot. If you don't see these icons then it won't run automatically at boot. SM needs to be a system startup app and is with the default installation unless you disable it in an app like System or Android tuner. If I were you, then I would suggest that you clear all data for the SM app, uninstall it, reinstall it, and try it again. This is the easy way.

There are a couple alternative ways in 4.2 on stock ROM or custom ROM. Most custom ROMs support this, and for stock ROM, it involves running a script that commands the same lines found in custom a ROMs init.rc file which then allows support for init.d scripts (user startup scripts). The script is called "install-recovery.sh". You will find the scripts and method to do this here provided by [MENTION=4878287]_that[/MENTION] and confirmed working by [MENTION=2446267]becomingx[/MENTION]. There is also an ABC daemon which can alternately be used for just the stock browser you can find at the second link near the end and on page 6.

http://xdaforums.com/showthread.php?t=2191777&page=1

http://xdaforums.com/showthread.php?p=41586148#post41586148
[Asus Transformer TF700] diofar:
Yes, I run it first, and the 2 buttons where active.

Anyway, thanks for your help!
[Asus Transformer TF700] elfaure:
Bump for update. Final release.
[Asus Transformer TF700] sbdags:
I've added Chrome Beta back in as well and there are 3 more:

#Chrome Beta Browser
if [ -d /data/data/com.chrome.beta ];
then
umount /data/data/com.chrome.beta/cache 2>&-
rm -rf /data/data/com.chrome.beta/cache/* 2>&-
mount -t tmpfs -o size=50m chrome_cache_beta /data/data/com.chrome.beta/cache
fi

#Floating Browser
if [ -d /data/data/gpc.myweb.hinet.net.PopupWeb ];
then
umount /data/data/gpc.myweb.hinet.net.PopupWeb/cache/ 2>&-
rm -rf /data/data/gpc.myweb.hinet.net.PopupWeb/cache/* 2>&-
mount -t tmpfs -o size=50 float_cache /data/data/gpc.myweb.hinet.net.PopupWeb/cache
fi

#UC Browser HD
if [ -d /data/data/com.uc.browser.hd ];
then
umount /data/data/com.uc.browser.hd/cache/ 2>&-
rm -rf /data/data/com.uc.browser.hd/cache/cache/* 2>&-
mount -t tmpfs -o size=50 UC_cache /data/data/com.uc.browser.hd/cache
fi

#Ninesky Browser
if [ -d /data/data/com.ninesky.browser ];
then
umount /data/data/com.ninesky.browser/cache/ 2>&-
rm -rf /data/data/com.ninesky.browser/cache/* 2>&-
mount -t tmpfs -o size=50 ninesky_browser /data/data/com.ninesky.browser/cache
fi

Thanks to Tylor for those last 3 :good:
[Asus Transformer TF700] elfaure:
Another way to run this script as root at boot (Tested on 4.1 only)

[MENTION=5234015]diofar[/MENTION]

I have some good news for you. [MENTION=4878287]_that[/MENTION] and I just figured out how to run this script EASILY as root at boot. Here's all you have to do (on stock ROM; may work for others too):

NOTICE: This trick should only be used on ROMs that do NOT have init.d support. For those that do, simply copy the script (name unchanged) into your init.d directory and reboot. You may have to make it executable by using a terminal, changing to the /init.d or /etc directory, and running "chmod 755 scriptname.sh" on it.

1. Make sure you don't already have an install-recovery.sh script located in /etc=/system/etc

2. Rename the script from autostart#.sh to install-recovery.sh

3. Mount your /system rw (either with a terminal as shown below, with a root browser or app Remount)

su
mount -o remount,rw /system

4. Copy the renamed script into /etc

5. Reboot

6. If not reboot immediately, mount your /system ro (either with a terminal as shown below, with a root browser or app Remount)

mount -o remount,ro /system

If someone on 4.2 tries this and it works please let me know. Should if it worked in SM.

Thks
[Asus Transformer TF700] elfaure:
Thanks guys! More browsers!! Arg. Looks like it'll never be "done". But cut n paste couldn't be any easier. Its a continuously expanding work in progress kinda like the universe. How many browsers is "too many"? Axe any?? Personally I can't stand UC but I haven't tried HD and some of the ones I added I'm not too sure about. On a similar note I found Dolphin and Dolphin HD were the same app if I'm not mistaken. Any input would be appreciated.

[Edit] OK [MENTION=518363]sbdags[/MENTION] let's add them all. What about my question about Dolphin HD and Dolphin. Same app or different? When I downloaded them both they were the same apk.
[Asus Transformer TF700] sbdags:
Never enough. Doesn't hurt to add them and then if someone does use it it helps! :)
[Asus Transformer TF700] elfaure:
OK [MENTION=518363]sbdags[/MENTION] let's add them all. What about my question about Dolphin HD and Dolphin. Same app or different? When I downloaded them both they were the same apk. Same question for UC.

***************************************************

Another few questions, off topic but since your here...

wrt Lagfix, should it be run on the /system partition too or just the /cache and /data partitions?

Can a single SD have multiple physical format types for its different partitions (exFAT and FAT32, exFAT and EXT4, FAT32 and EXT4) or are those just virtually mounted file systems and format types? In other words, if you partition an SD can you then format each partition for a different file system? I would think you must be able to.

If you have an SD already formatted exFAT and you were to partition it, would you have to reformat the exFAT partion in order to format the other partition for FAT32 (if its possible)? I have a 64GB exFAT SD and I would like a small FAT32 partition so I could use it for recovery (update.zip) and firmware flashing. Or can the internal SD be used?
[Asus Transformer TF700] Tylorw1:
I tried adding major browsers, and can easily add more if need be. I tried to add all the main ones I have seen used. Floating Browser actually runs AMAZINGLY with B2R, have you tried it? Great for multitasking.

Tylor
[Asus Transformer TF700] _that:
You can run it on /system but the effect will be limited - the free space on /system (which isn't much, maybe 100 MB) will be marked unused.

Yes, every partition has its own file system.

You can use the internal SD for the recovery. To make space for another partition on your SD card, you either need to delete the existing partition and create and reformat a new smaller one, or you find a tool that can shrink an exFAT partition with reshuffling your existing data.
[Asus Transformer TF700] sbdags:
I'll try it today :)
[Asus Transformer TF700] elfaure:
Just downloaded FB. Tiny! I will cache mount it up to RAM and check it out. Thanks for the new additions with included code. You guys couldn't make it any easier for me to add new mounts. I'll also add you to the credit list for REV5 buddy. This script has gone viral. Thanks!
[Asus Transformer TF700] elfaure:
I discovered how to APPEND rather than PREPEND custom paths to $PATH. You need to switch the $p:$PATH to $PATH:$p in mkshrc.

for p in ~/.bin /Removable/MicroSD/Scripts; do
[[ -d $p/. ]] || continue
[[ :$PATH: = *:$p:* ]] || PATH=$PATH:$p
done
[Asus Transformer TF700] elfaure:
Tylor, you forgot to add an "m" after all the 50's
[Asus Transformer TF700] _that:
It's time to introduce a function to clean up this mess and reduce the script's length by 80%, don't you think so? :)
[Asus Transformer TF700] Tylorw1:
Haha I knew I messed up, so what is it caching with? 50 bytes? lmao

Tylor
[Asus Transformer TF700] elfaure:
Defaulted to 4KB.
[Asus Transformer TF700] johnlgalt:
Since there are so many different browsers, would it be easier to start using variables for the browser .apk names and using the if statements to check to see if the browser exists, then perform the function for each existing browser using the set variables and a loop?

In the short run it might seem a bit longer to do, but in the long run adding browsers would be a lot easier as you'd only have to add in a couple of variables without altering the loop itself....

---------- Post added at 01:43 PM ---------- Previous post was at 01:42 PM ----------

I like the way you think :P
[Asus Transformer TF700] elfaure:
Match browser list mount script ("Sniper" mount technique)

Please disregard last post and request for help. Consider it "development". I got it working (finally). Here it is (although needs some cleanup).

You asked and you shall receive. So the idea is you simply enter a browser list in the value separated variable BROWSER_LIST and that list is then matched against the list of all possible /cache directories and only those in the browser list get mounted to tmpfs. All I have to do now is mask the firefox directory from the match list and add that as a separate mount and its golden.

[MENTION=933916]that[/MENTION] : I think this one is worth a full point!

Question: Which is more efficient, the grep way or the ls way for expanding CACHE_FULL_PATH?

Thanks [MENTION=5234163]shardsx[/MENTION]! ps-I got the "rm -rf ..." to silence by putting quotes around it. You can still use the "f" option silently this way.

#!/system/bin/sh

#Add browser app list below
BROWSER_LIST="com.android.browser com.dolphin.browser com.mx.browser"
#com.android.chrome
#********************************************************************************************************

for CACHE_FULL_PATH in $(find /data/data/ | grep '.*/cache$')
#for CACHE_FULL_PATH in $(ls -d /data/data/*/cache)

do
#echo "CACHE_FULL_PATH $CACHE_FULL_PATH"
CACHE_NAME=${CACHE_FULL_PATH/'/data/data/'/''}
CACHE_NAME=${CACHE_NAME/'/'/'_'}
#echo "CACHE_NAME $CACHE_NAME"
for OBJ in $BROWSER_LIST
do
#echo "BROWSER_LIST $OBJ"
#if [ "/data/data/$OBJ/cache" = "$CACHE_FULL_PATH" ]
if [ "$CACHE_FULL_PATH" = "/data/data/$OBJ/cache" ]
then
#for OBJ in $BROWSER_LIST
#do
umount $CACHE_FULL_PATH #2>&-
#rm -r ${CACHE_NAME}/* #2>&-
rm -rf "$CACHE_NAME"/* 2>&-
mount -t tmpfs -o size=50m $CACHE_NAME $CACHE_FULL_PATH
#done
fi
done
done

# RESET VARIABLES / ARRAYS TO NIL ***************************************************************************
unset BROWSER_LIST
unset CACHE_FULL_PATH
unset CACHE_NAME