[Guide] How to enable init.d script support on stock ROM - Asus Transformer TF700

*****************************************************************************************************************************************************
Credit for discovering this method goes to Sr. Staff gurus @_that (bet you could have guessed) and @becomingx for parsing GNU code to figure out file naming limitations (no dots!) to make this work.
******************************************************************************************************************************************************
This short Guide accompanies the need to run my B2R startup script (or any script) as root at boot. If you are rooted and have busybox installed on a stock ROM or any ROM that does not have init.d support thru init.rc, here's how you can add it. This is an alternative method to either using Script Manager (SManager) or hijacking the install-recovery.sh file directly to run a startup script. Enabling this support allows you to be able to run all executable scripts located in init.d as root at boot.
IMPORTANT: Your init script name can NEITHER have any dots in the filename NOR use an extension. Name it something like autostart or start-up or init_script. Also when you write a script, NEVER forget to start it with the hash-bang-path to shell (#!/system/bin/sh) and NEVER forget to press ENTER after the last character of the last line of code. You can't just use any simple text editor to create the file - you must pay close attention to "line ends". I use ES Note Editor on device and Notepad++ configured for UNIX/OSX line ends on PC. Always save the file AS PLAIN TEXT. Read "Additional Information" below on line ends.
[NOTE: /system/etc = /etc (symlink)]
1. Mount your /system rw
Code:
mount -o remount,rw /system
2. Make directory /system/etc/init.d
Code:
mkdir /system/etc/init.d
3. Create a shell script (using a text editor with UNIX line ends [LF only] ) named "/system/etc/install-recovery.sh" with the following contents:
Code:
#!/system/bin/sh
/system/bin/logwrapper /system/xbin/busybox run-parts /system/etc/init.d
4. Put your init script in init.d and remember to make both /system/etc/install-recovery.sh and your script in /system/etc/init.d executable.
Code:
cd /system/etc
chmod 755 install-recovery.sh
cd /system/etc/init.d
chmod 755 name_of_your_init_script
5. Immediately reboot or if not, mount your /system ro
Code:
mount -o remount,ro /system
If you have busybox installed in /system/xbin this enables support for running init.d scripts from ROMs that do not offer native support thru init.rc.
Additional Information:
Every file has what are know as line ends or more technically end of line (EOL) conversions. These are HIDDEN characters that you normally don't see (if the line end are in the native OS format) at the end of lines in a text editor when editing files. This is the character that tells the OS where one line stops and the next starts in any file. In order to see the line ends you must enable "show all characters".
Your text editor must support UNIX line ends (LF only, not CR + LF = CRLF). Do NOT use Windows Notepad as it only creates Windows line ends (CRLF).
Always use UNIX line ends - a Windows editor like Notepad will create CRLF line ends, while your shell script MUST use LF line ends or it will fail to execute. Otherwise your first line will look like this to Linux:
Code:
#!/system/bin/sh^M
The ^M above is the common convention to display the control character Ctrl+M, which is CR (carriage return) before the LF (line feed) or (CRLF). The consequence is that the system can't find your shell under the name "sh^M" (or any subsequent command "some_command^M") and your script will fail.
This is VERY important to understand and also how to configure any cross-platform text editor. Using notepad++ in Windows without changing the default settings still results in CRLF at the end of lines because it knows its running in Windows and thinks you want Windows line ends. In order to change this behavior, Under the Edit menu find EOL conversion, and select Unix/OSX format. Also toggle the paragraph symbol on the top bar (backwards P with double verticles; show all characters) and now its clear as day what line ends you have, where they are, and if you have one after the end of the last line or not. Now its WYSIWYG. Once these setting are toggled, saving the file in Windows results in Unix/OSX line ends (LF) and when you open notepad++ the next time the settings are retained. See screenshot before attachment at the end of this post.
Example for changing default EOL conversion to Unix LF for an older version of notepad++:
http://techtips-it.blogspot.com/2011/04/can-i-convert-file-format-in-notepad.html
If done correctly, the output you will see if VIEWED (not edited) using Windows notepad will show a small hollow rectangle representing each LF. You will see one for each line end, and two together at the end of the last line itself - the first is the EOL LF for that line, and the subsequent is the LF you entered after the last line. If notepad just shows what you would normally see in the XDA code block with no extra special characters as described, you have Windows line ends and your script will fail to execute.
If you have multiple scripts to run at boot, the real purpose of init.d, you should name your init scripts prepended with two digits between 00 and 99. (Fairly) Evenly divide the range into 3 groups like 2# (20-29), 5# (50-59), and 8# (80-89). Scripts in the 20 series will be run first, followed by 50 series scripts, ending with 80 series scripts. They will be executed from lowest number to highest number, in that order. This allows you to define the load order for a group of init scripts. We didn't use 00-19 or 90-99 in case we need to put a future script before the first or after the last one without having to rename the rest of the scripts to do so.
Example init script names: 20firststart, 50mid_start, 80end-boot
******************************************************************************************************************************************************
Download the attachment and remove the txt extension and copy it into /system/etc and make sure it is executable. Make directory /system/etc/init.d, put your executable boot scripts in there, and reboot to run your executable init.d scripts as root.
This method replaces the depreciated method of directly hijacking install-recovery.sh with a single boot script run as root. Why have only one when you can have many?
Linkback to dev thread
http://forum.xda-developers.com/showthread.php?t=2191777

Reserved
Sent from my LG-LS970 using xda app-developers app

elfaure said:
@_that, please review and bless.
Click to expand...
Click to collapse
elfaure said:
IMPORTANT: Your init script name can NEITHER have any dots in the filename NOR use an extension. Name it something like autostart or start-up or init_script.
Click to expand...
Click to collapse
I still recommend using the common Unix convention of 2 digits + lowercase name for init.d scripts, e.g. 50something, 60dothislater, 90somethingtodolast. The numbers allow for clearly defining the order in which multiple startup scripts are executed.
elfaure said:
Also when you write a script, NEVER forget to start it with the hash-bang-path to shell (#!/system/bin/sh) and NEVER forget to press ENTER after the last character of the last line of code. You can use any simple text editor to create the file. I use ES Note Editor on device and Notepad++ on PC. Always save the file AS PLAIN TEXT.
Click to expand...
Click to collapse
And always use UNIX line ends - a Windows editor like Notepad will create CRLF line ends, while your shell script MUST use LF line ends. Otherwise your first line will look like this to Linux:
Code:
#!/system/bin/sh^M
The ^M above is the common convention to display the control character Ctrl+M, which is CR (carriage return) before the LF (line feed). The consequence is that the system can't find your shell under the name "sh^M" and your script will fail.
elfaure said:
4. Remember to make it executable and to create the /system/etc/init.d directory.
Click to expand...
Click to collapse
You already created init.d in step 1.
Looks like it could work like this. If you want to be sure, remove your existing scripts and rmdir your init.d directory, then follow your own guide and see if everything is OK. Then you can bless it yourself. In software development, peer review is always good, but testing is even more important.

_that said:
I still recommend using the common Unix convention of 2 digits + lowercase name for init.d scripts, e.g. 50something, 60dothislater, 90somethingtodolast. The numbers allow for clearly defining the order in which multiple startup scripts are executed.
And always use UNIX line ends - a Windows editor like Notepad will create CRLF line ends, while your shell script MUST use LF line ends. Otherwise your first line will look like this to Linux:
Code:
#!/system/bin/sh^M
The ^M above is the common convention to display the control character Ctrl+M, which is CR (carriage return) before the LF (line feed). The consequence is that the system can't find your shell under the name "sh^M" and your script will fail.
You already created init.d in step 1.
Looks like it could work like this. If you want to be sure, remove your existing scripts and rmdir your init.d directory, then follow your own guide and see if everything is OK. Then you can bless it yourself. In software development, peer review is always good, but testing is even more important.
Click to expand...
Click to collapse
Thanks for the review! I will make some edits, test drive the guide, and bless it myself. I was already going to add the two digit numerical discussion. I'm not trying to get you to do any extra or my work here, God knows you are a very busy multi-tasking hundreds of tasks , I just thought I was on newb patrol after posting a non-working script and then mandated to your must review list.

Is this method works on other phone too?
I really do want the init.d support on stock rom
Sorry for my bad English...
Sent from my HTC Desire 200 using XDA Premium 4 Mobile app

dicks93277 said:
Is this method works on other phone too?
I really do want the init.d support on stock rom
Click to expand...
Click to collapse
The method is reasonably generic that it is worth trying on your device.

so sad that i can't make this work on my phone
but still thanks for your reply @_that

Awesome it works on my Panasonic T41 running MIUI 5 beta
Could you tell how to do the same thing from init.rc ???
and also one script is not working
Code:
#!/system/bin/sh
su
mount -o rw,remount /
mkdir -p /rex
mount -o bind /data/data/com.spartacusrex.spartacuside/files/system /rex
mount -o rw,remount /system
mkdir -p /system/vendor/bin
mount -o /rex/bin /system/vendor/bin
Is there any thing wrong with it ?? I used unix terminators and also set the permissions to 755

uttarayan21 said:
Awesome it works on my Panasonic T41 running MIUI 5 beta
Could you tell how to do the same thing from init.rc ???
and also one script is not working
Code:
#!/system/bin/sh
su
mount -o rw,remount /
mkdir -p /rex
mount -o bind /data/data/com.spartacusrex.spartacuside/files/system /rex
mount -o rw,remount /system
mkdir -p /system/vendor/bin
mount -o /rex/bin /system/vendor/bin
Is there any thing wrong with it ?? I used unix terminators and also set the permissions to 755
Click to expand...
Click to collapse
The 'su' command with no arguments starts an interactive shell, everything after 'su' waits for the user to exit that shell, which you can't do. Init.rc and subsequent scripts are run as root anyway, including init.d scripts, so just delete the 'su' line and it should work.
Sent from my LGL41C using Tapatalk

Kor1134 said:
The 'su' command with no arguments starts an interactive shell, everything after 'su' waits for the user to exit that shell, which you can't do. Init.rc and subsequent scripts are run as root anyway, including init.d scripts, so just delete the 'su' line and it should work.
Sent from my LGL41C using Tapatalk
Click to expand...
Click to collapse
Thanks !!! It worked !!!!

uttarayan21 said:
Thanks !!! It worked !!!!
Click to expand...
Click to collapse
You're welcome [emoji6]
Sent from my LGL41C using Tapatalk

Why don't use service from init.rc ??
elfaure said:
*************************************,
3. Create a shell script (using a text editor with UNIX line ends [LF only] ) named "/system/etc/install-recovery.sh" with the following contents:
Code:
#!/system/bin/sh
/system/bin/logwrapper /system/xbin/busybox run-parts /system/etc/init.d
Click to expand...
Click to collapse
But it is better to add a service to init.rc and launch sysinit from there for init.d support !!!
Maybe you should update your guide with that !!!
:laugh: :good:

uttarayan21 said:
But it is better to add a service to init.rc and launch sysinit from there for init.d support !!!
Maybe you should update your guide with that !!!
:laugh: :good:
Click to expand...
Click to collapse
Changing init.rc requires repacking the boot image.

_that said:
Changing init.rc requires repacking the boot image.
Click to expand...
Click to collapse
Yeah it does but if you install SuperSU then the install-recovery.sh file will be modified and init.d will be lost !!!

Related

[HOW-TO] ROM-HACKING: init.rc ext2-auto-mount / ROM Signing / ROM Kitchen

AS MENTIONED IN THE INTRODUCTION TEXT THIS HAS ONLY BEEN TESTED ON AMON RA ROM 1.6.2 BUT SHOULD REALLY WORK ON ANY ROM THAT HAS NO EXT2 AUTO-MOUNT. AND YEAH THIS WHOLE PROCESS HAS BEEN DONE ON A 32a BOARD. FOR THOSE THAT TRY THIS ON OTHER ROMS LET ME KNOW HOW IT GOES.
I've searched and shuffled through the entire forum and made inquiries to ROM authors without much light being shed on this issue. I doubt I am the only one who has been looking for a way of doing this so I decided to do a small HOW-TO. Here I will explain step by step as to how you can implement a script to be part of your ROM that will auto mount an ext2 partition on boot up if such partition is present. I have included all the tools I've used in order to pull this off, and as the title suggests this has only been done on Amon Ra's latest 1.6.2 ROM. In order to follow these instructions you are expected to allready have set up an adb enviroment on your linux box and for the signing process to work you must have sun-java present, the gnu java wont work. And of course a microSD card with an ext2 partition
1. Download install.sh to your home directory
Code:
wget http://www.grindhouse.no/androidtools/install.sh
chmod a+x install.sh
2. Now execute the install.sh script which will create a directory to work in and download a tool and script package and unpack it.
Code:
./install.sh
When the install.sh script is done you need to move the mkbootimg preferebly to your tools directory of your SDK.
Code:
mv toolstomove/mkbootimg <path/to/sdk/tools/mkbootimg>
3. Unpack the RA1.6.2 ROM into a directory in your home dir. In this HOW-TO we will use directory name "ra1.6.2" as an example through out the entire process.
4. Copy the boot.img from ra1.6.2 to the ROM-cooker dir
Code:
cp $HOME/ra1.6.2/boot.img $HOME/ROM-cooker/boot.img
cd $HOME/ROM-cooker
5. Use unpack.pl to extract the ramdisk from the boot image. I've modified the script a little so it automates the entire process and decompresses the ramdisk to a directory
Code:
./unpack boot.img
6. Now you can either replace the init.rc file here with the one I've included in this package or you can add these lines by yourself. In wich case do the following
Code:
cd boot.img-ramdisk
pico init.rc
Press CTRL+w and then CTRL+t and input 27. hit enter. This will take you to line 27 of init.rc so you can add a line right before the init process remounts the rootfs in read-only mode. Add following line:
Code:
mkdir /sdext2 0771 system system
Now scroll down to the end of the init.rc file and add the following:
Code:
service mountsdext2 /system/bin/mountsd
user root
group root
oneshot
7. You have now edited (or replaced) your init.rc file and prepared it to execute a script on boot that will detect an ext2 partition and boot it if there is one to be found. Now you have to make the mountsd script a part of the ROM. Do the following:
Code:
cd $HOME/ROM-cooker
mv toolstomove/mountsd $HOME/ra1.6.2/system/bin/mountsd
rm -rf toolstomove
8. Now that the init.rc file is sorted out and mountsd has been placed in /system/bin of the ROM so it is time to re-pack the boot.img:
Code:
cd $HOME/ROM-cooker
./repack boot.img-kernel boot.img-ramdisk boot.img
rm $HOME/ra1.6.2/boot.img
mv boot.img $HOME/ra1.6.2/boot.img
9. Your ROM now has a new boot image with an updated init.rc and the /system/bin dir has the script needed to auto-mount the microsd ext2. Now you must re-zip the ROM and sign it. Do the following:
Code:
cd $HOME/ra1.6.2
zip -r update.zip *
mv update.zip $HOME/ROM-cooker/update.zip
cd $HOME/ROM-cooker
./sign.pl update.zip
10. The ROM is now signed and you now have a file called update-signed.zip. Connect the phone to your computer and execute thus:
Code:
./push update-signed.zip
11. Now you are ready to flash the modified ROM which will auto-mount an ext2 partition on your microSD. There is no need to wipe before flashing. If you have no prior experience with ROM flashing or whatever just backup your current install. If you're using OpenHOME or anything similar, nothing will be changed or damaged but if you're using MontAlbert's themes with the ROM you will have to flash them again after flashing this modified ROM.
Code:
adb reboot recovery
12. Flash from choose zip and of course choose update-signed.zip. Reboot. After the system boots up again you can now check whats what with either one of the commands:
Code:
[email protected]:~$ adb shell mount | grep sdext2
/dev/block/mmcblk0p2 on /sdext2 type ext2 (rw,noatime,nodiratime,errors=continue)
[email protected]:~/boot$ adb shell busybox df -h | grep sdext2
/dev/block/mmcblk0p2 893.7M 13.0K 846.0M 0% /sdext2
13. Voila! Your RA 1.6.2 ROM now detects and mounts your microSD ext2 partition on boot. Woohoo?
I hope the HOW-TO was easy reading and that you have succeeded in hacking up your ROM. I know that certain ROMs have this as a built-in function but Amon Ra's does not. But since alot of people including myself use his ROM because of the high speed and stability I thought I should contribute to his project and add a cool (and missed?) function to it.
Mind you that you can use the ROM-cooker set to further adjust and hack up the ROM as you see fit. Happy learning!
Very nice!
Now the question many people will ask : why would you automount ext2 if you don't use apps2sd ?
I personally have ubuntu on my ext2 And besides this approach can be used for a number of things, people who have had the need, or wanted to experiment with init.rc doing things on boot, the mountsd script can easily be altered to do what ever needed.
For me its been a learning curve finding these things out, so by sharing it I may spare some people breaking their backs over this whole init.rc thing. people may want to modify init.rc for whatever reason, so I'm sure people wont have a problem finding a way of putting this to use, and its a subject that isnt all that covered on the forum .. and hey .. at least they get a rom kitchen out of the whole shabang
Very interesting! Thank you.
I used your unpack-program to unpack a recovery-image. It seems to work fine. What I am trying to do is change the state the recovery-image returns the phone to. Would it be possible to just replace your mountsd-script with, for example, a script that installs apps? Or is there a better way to do what Im trying to achieve?
Cheers,
edit: I noticed that on the emulator it is sufficient to just place an apk-file in "data/app" to get it installed. Could it be possible that this is all I need a script to do? :O or could I hurt my poor phone by doing so you think?
sandis84 said:
edit: I noticed that on the emulator it is sufficient to just place an apk-file in "data/app" to get it installed. Could it be possible that this is all I need a script to do? :O or could I hurt my poor phone by doing so you think?
Click to expand...
Click to collapse
That's indeed all you need to do.
Hi!
So I tried to create a signed update.zip, but it failed. It didnt create a "update-script"-file, so my device refused to install it. I wrote my own "update-script"-file, but then it complained "no digest" for the file. How do I solve this?
post the contents of your script people might see whats up
so is this all on linux?
also where are the script files for your tutorial
thanks for the time to put together
sitimber said:
so is this all on linux?
also where are the script files for your tutorial
thanks for the time to put together
Click to expand...
Click to collapse
Says where its at in the first line : )
Code:
wget http://www.grindhouse.no/androidtools/install.sh
But now that I checked, I have to apologize, I see I have a missed payment with my hosting, I'll fix that within the day. Also sorry I havent been answering the few questions here I've been afk cause of surgery.
sitimber said:
post the contents of your script people might see whats up
Click to expand...
Click to collapse
well, I looked in another "update-script" file and found this:
assert compatible_with("0.2") == "true"
assert getprop("ro.product.device") == "dream" || getprop("ro.build.product") == "dream"
show_progress 0.5 0
write_radio_image PACKAGE:radio.img
show_progress 0.5 10
Click to expand...
Click to collapse
So I figured that nothing was essential other then the line "write_radio_image PACKAGE:radio.img". Also ofcourse I made sure it contained the name of my image-file instead of "radio.img". This gave me the "no digest" message, so now I feel unsure on how to create a working update.zip.
edit:
SOLVED! How silly of me. When you sign the update, a hash of each file is put in manifest.mf. Since I added the update-script after signing the file, ofcourse the digest(hash) was missing. Now everything works alot better and I can proceed... until I get stuck again
Cheers,
edit2:
Just to get a better understanding, what exactly does each line do here? Or where can I read about this?
Code:
service mountsdext2 /system/bin/mountsd
user root
group root
oneshot
edit3:
Ok, so I have experimentet, but I still dont manage to solve those last steps. I tried to edit init.rc and just add "mkdir /testdir 0000 system system" where the other directories were created. I then repacked it, zipped it, signed it, put it on my sdcard, started up a custom recovery, installed the update and rebooted. Everything seems to work fine. But when I start adb and check around, I dont see the "testdir"-directory. Also when I check in init.rc my line is gone. Do you guys have an idea of where I went wrong?
sitimber said:
so is this all on linux?
also where are the script files for your tutorial
thanks for the time to put together
Click to expand...
Click to collapse
it doesnot necesarily have to be linux ...you can also do it in windows using cygwin and dsxda's android rom kitchen

[BASH][CWM] BASH shell for android, credit: nubecoder

First off, all credit goes to nubecoder. Original post:
[Bash] android_bash: Bash, cross-compiled and modified for the android platform.
Introduction...
Most (All) modern Linux distributions utilize bash (Bourne Again SHell) rather than sh (Bourne SHell). Android, by default uses sh. Bash has numerous advantages over sh, sush as tab completion and history support.
Some ROM developers include bash in their ROMs by default. It makes adb, terminal, and scripted commands much easier and more powerful/flexible. I noticed that Sidekick 4G ROMs don't come with bash, hence this thread.
How to Install BASH...
Simpy flash this zip through Clockworkmod recovery: (if ORANGE, check mounts. Not sure if neccessary, but it doesn't hurt)
android_bash-4.1.11(2)_installer-SK4G.zip
Then load your preffered terminal emulator application, type bash, press enter, and there you go.
What's the difference between the SK4G version, and the original Epic 4G version?
- Modified device/product check in updater-script to "SGH-T839"
- Modified $PATH variable in /data/local/.profile to "/sbin:/system/bin:/system/xbin:/data/local/tmp:/bin"
- Modified $PATH variable in /system/etc/bash.bashrc to "/sbin:/system/bin:/system/xbin:/data/local/tmp:/bin"
- [Personal preference] Add alias su='su -c bash' to /data/local/.bash_aliases
- [Personal preference] Modified $PS1 to PS1="\[$txtgrn\]\w $ \[\e[m\]"
- [Personal preference] Modified root $PS1 to PS1="\[$txtred\]\w # \[\e[m\]"
- [Personal preference] Modified location of .bash_history from /sdcard/.bash_history to /data/local/.bash_history
Click to expand...
Click to collapse
As any experienced bash user should know, if you want to revert/modify my personal preferences, just modify "/data/local/.bashrc", "/data/local/.bash_aliases", or "/system/etc/bash.bashrc" to your liking.
Extras...
mntsystem Make /system partition read-only or read-write. Usage:
# mntsystem [ro|rw|status]
Unzip mntsystem.zip, copy mntsystem to /system/bin, chmod 744 /system/bin/mntsystem
Click to expand...
Click to collapse
defaultshell Replace sh with bash, or revert. Usage:
# defaultshell [bash|sh|current]
Unzip defaultshell.zip, copy defaultshell to /system/bin, chmod 744 /system/bin/defaultshell
Click to expand...
Click to collapse
More extras (bash scripts) to come! Please post you own as well!!
PS: I was confused on where I should post this (General vs. Development), figured it isn't "technically" ROM related, so I posted in General. Please move if necessary. Thanks.
mntsystem extra added!
Awesome
Oh man, I have been missing BASH so much, thank you! Now I will finally have a fully-functioning terminal on my phone. I can't wait to tab-complete (seriously).
One question about installation, though. I'm supposed to "install zip from sdcard" in CWM, correct? Will this replace anything I already have, or just copy over the files for BASH? Does it leave sh as the default shell?
nteleky said:
I'm supposed to "install zip from sdcard" in CWM, correct? Will this replace anything I already have, or just copy over the files for BASH? Does it leave sh as the default shell?
Click to expand...
Click to collapse
Yes, flash through Clockworkmod. And, no it will not replace any files already on your phone (unless you already have bash, or some bash configuration files on your phone). Yes, it will leave sh as the default shell.
I can make a bash script to "replace" sh with bash, and post in the Extras if you want. When I say "replace", I mean backup /system/bin/sh, then symlink bash to /system/bin/sh. Therefore any time you try to execute a script through sh, it actually is executed by bash.
Although, for your information bash is/should-be fully backwards compatible with any sh script. I say should be, because:
Bash (Unix shell) - Wikipedia said:
The vast majority of Bourne shell scripts can be executed by Bash without modification, with the exception of Bourne shell scripts stumbling into fringe syntax behavior interpreted differently in Bash or attempting to run a system command matching a newer Bash builtin, etc.
Click to expand...
Click to collapse
Very rare chance though.
I personally keep sh as the default though, android system level scripts are designed for sh (its works), I just use bash for any script that I decide run (through a shell, or adb). So, I start connectbot with a profile that runs "/system/bin/bash" automatically at start.
New extra!
defaultshell Replace sh with bash, or revert. Usage:
# defaultshell [bash|sh|current]
Unzip defaultshell.zip, copy defaultshell to /system/bin, chmod 744 /system/bin/defaultshell
Click to expand...
Click to collapse
Hey
I'm a noob and I'm curious if this could run on my galaxy s 2 running stock?
The bash binary (with supporting files) should work on any rooted android device, however the flashable zip file I posted WILL ONLY WORK on the sidekick 4g.
If you want to install bash, you can download the flashable zip, extract it and copy the the files to their correct location (Quick, easy solution), or you can modify the update-script to work with your phone. Be sure the mounts are the same! Then alter the device check. (More difficult at first, but results in easily reuseable and distributable, flashable zip)
Sent from my SGH-T839 using XDA App
hey after I go to the emulator and type bash.. what should it read?
Sent from my SGH-T839 using XDA App
Should be a green prompt that reads:
/ #
If you cd to, for example, to /sdcard, then the prompt will read:
/sdcard #
If you enter su, then the prompt will become red and use a $ instead of #.
If your prompt says sh-4.1 # then you invoked bash as sh, ie you symlinked (or renamed) bash to sh (usually /system/bin/sh).
Sent from my SGH-T839 using XDA App
well when i enter bash this comes up... 0localhost:// $
and the last two are green ..
What terminal emulator are you using?
Sent from my SGH-T839 using XDA App
The free one.. lol. Idle I just typed emulator and that's the first one in the list ..
Sent from my SGH-T839 using XDA App
I'm not sure why its doing that. Although, all it means is that bash is being accessed from localhost, aka from the phone itself (not an outside source). It doesn't mean anything is wrong.
If it bothers you, you can use connectbot (free on the market, also includes an ssh client) instead. Just create a profile and make sure its local. Then it will work as expected.
Sent from my SGH-T839 using XDA App
Ok. Thanks .. ill let u know if it works
Sent from my SGH-T839 using XDA App
Well it work. Lol.. thank you
Sent from my SGH-T839 using XDA App
bc54 said:
The bash binary (with supporting files) should work on any rooted android device, however the flashable zip file I posted WILL ONLY WORK on the sidekick 4g.
If you want to install bash, you can download the flashable zip, extract it and copy the the files to their correct location (Quick, easy solution), or you can modify the update-script to work with your phone. Be sure the mounts are the same! Then alter the device check. (More difficult at first, but results in easily reuseable and distributable, flashable zip)
Sent from my SGH-T839 using XDA App
Click to expand...
Click to collapse
I tried doing this for my Droid 3, by changing updater-script file to the values I get from my terminal emulator, like so:
Code:
assert(getprop("ro.product.device") == "cdma_solana" || getprop("ro.build.product") == "solana_vzw");
But CWM tells me it fails because "(bad)". Do you have to somehow change the update-binary file as well?
no i didnt change the update-binary file.
however i think the source of you problem is the "/dev/" names the sidekick uses for its partitions.
for example the sidekick "/dev/" name for the partition mounted to "/system" is "/dev/block/stl9"
the droid 3 most likely uses a different "/dev" naming scheme.
find out the "/dev/" name for "/system" on the droid 3.
in the update-script file, replace "/dev/blocl/stl9" with the corresponding name for the droid 3.
find out the "/dev/" name for the "/data" partition on the droid 3.
in the update-script file, replace "/dev/blocl/stl10" with the corresponding name for the droid 3.
then rezip it, and flash. if that fails, then you could just manually copy the files to their respective location using adb, a terminal emulator app, or even a file manager.

Set bash as default shell

For a long time I have been running bash on my phone. However at some point you get tired of having to manually enter bash all the time from ssh, adb etc. Therefore I transferred my boot.img to my computer, changed the "console" line in init.rc to point at bash instead of sh and flashed it back to my phone. To my surprise this did not help. Neither adb nor ssh switched to bash by making this change.
I then created a symlink from bash to sh, but this does not work 100% as bash switches to sh mode when arg(0) = "sh", I don't like that.
So I made a script that calls bash and replaced sh with that. But for some reason this can make problems with you boot process some times.
This is where bind mounts come in.
By adding a small init.d script that bind mounts my bash calling script with the sh binary (yes bind mount also works for files), the boot process gets to use it's bellowed sh while I get to use bash as default from everywhere. Because the script is mounted to the sh binary (Not linked), a reboot will reset it back to to original file.
Now we just add /system/etc/bash.bashrc and place an alias from sh to bash so that the custom script is not called more than it has to. Also I have added the option to add a custom .bashrc in /mnt/sdcard/ that is called from /system/etc/bash.bashrc, and a /system/etc/debian_chroot file support for those of you that has a chroot system installed.
Why use bash?
Well you can add custom layout to your shell, create/change global variables which normally only can be done from init.rc, create aliases, execute custom scripts and so on to make your shell environment just the way you like it.
The update.zip contains a bash binary that looks for /etc/bash.bashrc, the bash call script to replace sh, a bash.bashrc file that creates the android missing user variables and more, and the init.d script that mounts the bash call script.
Requirements
init.d support
busybox
Download
Bash Route 1.0.0 (MD5: ebb539f5d07944ead77439b89e76f524) - bash_route-signed.zip
Sh is actually a symlink to mksh, so just delete it, and replace (not true for /sbin/sh, its linked to busybox)
From my fingers to your eyez
cdesai said:
Sh is actually a symlink to mksh, so just delete it, and replace (not true for /sbin/sh, its linked to busybox)
From my fingers to your eyez
Click to expand...
Click to collapse
It does not matter. The point is when someone/something makes a call to sh, bash switches to sh mode. It does not matter if you link bash to sh, mksh or copies bash to either two or whatever. You need to replace arg(0) with "bash" instead of "sh". The only way to do this is to make a script that answers the call and redirects that call to bash along with the message (the rest of the arguments). That way arg(0) will be replaced with "bash" and the bash shell will run it's regular mode instead of the "sh" mode.
dk_zero-cool said:
It does not matter. The point is when someone/something makes a call to sh, bash switches to sh mode. It does not matter if you link bash to sh, mksh or copies bash to either two or whatever. You need to replace arg(0) with "bash" instead of "sh". The only way to do this is to make a script that answers the call and redirects that call to bash along with the message (the rest of the arguments). That way arg(0) will be replaced with "bash" and the bash shell will run it's regular mode instead of the "sh" mode.
Click to expand...
Click to collapse
Necrobumping this thread for a few reasons.
1.) You have posted in the Android Software and Hacking General section. I was looking for something similar to this for GS3-LTE. Your updater script is specifically for MTD devices....like i9000 ICS or so on.
2.) There are mistakes in your script to install. unmount is not a linux busybox command. umount is though.
I will try out your idea. Thanks
You got this still? The zip has gone down.

[MOD] Enable Stock Hotspot on Verizon

I have gotten the built-in wireless tether to work. I know there's been some discussion about getting Wireless tether without FoxFi and similar.
Since we cannot use the recovery method directly, you can still use the tools and everything from it.
So to begin:
Obviously, you must have root for this to work.
1) Download the patch.zip from the original thread. [here: http://forum.xda-developers.com/showthread.php?t=2768837 ]
2) extract the zip to somewhere on sdcard. I extracted mine to the Download folder. You may need to edit the script below to reflect your locations.
3) okay, this part gets a little weird, but bear with me...
Save this code as run.sh in Download folder or wherever you extracted. You can over-write the old run.sh if you save it in toggle folder where original was located-- BE SURE TO EDIT AS REQUIRED
Code:
#!/sbin/sh
cp /mnt/sdcard/Download/toggle/sqlite3 /data/local/tmp/sqlite3
chmod 0777 /data/local/tmp/sqlite3
mount -o remount,rw /dev/block/mmcblk0p23 /system
cp /system/framework/framework-res.apk /system/framework/framework-res.apk.bak
cp /mnt/sdcard/Download/system/framework/framework-res.apk /system/framework/framework-res.apk
/data/local/tmp/sqlite3 /data/data/com.android.providers.settings/databases/settings.db < /mnt/sdcard/Download/toggle/toggles.sql
4) now open up adb on pc (preferred!!! So you can still see progress and if necesary you can undo/alter/fix things) or terminal emulator (untested but should work, may be weird since you have to reboot phone while it's interface is locked up)
Run:
adb shell
su
sh /mnt/sdcard/Download/toggle/run.sh [or where ever you saved it]
5) Your phone will probably lock up now because you've just replaced the framework-res.apk while the system was running.
adb reboot or reboot by other methods.
6) Profit ;]
I DO NOT WARRANTY OR GUARANTEE THIS METHOD. USE AT YOUR OWN RISK
I believe the sqlite edits serve the purpose of showing the icon in the quick settings pull down. Otherwise, just replacing the framework-res.apk with the correct changes is enough: See this thread for the changes needed:
http://forum.xda-developers.com/showthread.php?t=2759119
Incidentally, I was attempting to make the changes on my own and recompile the framework-res.apk, and I must've done something not quite right because the phone hung at the verizon logo. Thankfully adb was up so I was able to remount system as rw to replace the edited framework-res.apk from the original thread OP linked. Interestingly enough, as soon as I finished copying the edited file, the phone continued booting just fine, and I'm posting from the native tethered connection now.
Edit: I was able to do the changes on the framework-res.apk extracted/decompiled from my phone after all. I'm guessing that the phone didn't like deflate method as opposed to store method (no compression) on the resources.arsc file in the apk file. Had to use the 7zip command line tool to save the modified resources.arsc file without compression to the original apk:
7z u -mx0 framework-res.apk.zip resources.arsc
where -mx0 means no compression (copy)
Got it enabled by just replacing the framework-res.apk, and noticed speeds were really slow. I get 1.88mbps on LTE at home (so-so coverage), but only .15mbps on my iPad connected to my phone via Wi-Fi.
I did this: http://forum.xda-developers.com/showpost.php?p=53431713&postcount=9
SO MUCH EASIER than what you guys were doing. :good:
Droid_Evo_8 said:
I did this: http://forum.xda-developers.com/showpost.php?p=53431713&postcount=9
SO MUCH EASIER than what you guys were doing. :good:
Click to expand...
Click to collapse
It's a manner of preference. In terms of overhead, this native method should technically be quicker to enable, as it does not have to wait for the exposed module to intercept the call and return an empty array of apps to execute for the provision check. That being said, we're probably talking miliseconds at most. While I use xposed for other modules sometimes, others might prefer not to, and this native method does not require it.
vacaloca said:
It's a manner of preference. In terms of overhead, this native method should technically be quicker to enable, as it does not have to wait for the exposed module to intercept the call and return an empty array of apps to execute for the provision check. That being said, we're probably talking miliseconds at most. While I use xposed for other modules sometimes, others might prefer not to, and this native method does not require it.
Click to expand...
Click to collapse
I don't know much about adb or terminal emulator so I'm fine with it. :good:
Here's to hoping for an easy tethering mod!
fillyo said:
Here's to hoping for an easy tethering mod!
Click to expand...
Click to collapse
I'm not sure how easier it can get than installing xposed framework + X Tether mod and rebooting, or replacing the framework-res.apk file on your phone with the one listed in the OP... either will work. This of course assumes you have the Verizon model. Replacing the premade framework-res.apk on any other S5 model would probably cause issues and wouldn't solve anything .
I just made it 'harder' on myself by deciding to copy the original framework-res.apk from my phone, and using the latest apktool and aapt to extract the apk, make the modifications, rebuild it, and replace it on my phone (after renaming the original to .bak). I mostly did this to refresh my memory on how to do it as I had done the process with another phone a while back to do the same mod. As I mentioned earlier, the sqlite stuff is only necessary if you want a toggle in the quick settings bar... otherwise you can just go into settings menu and enable it that way.
vacaloca said:
I'm not sure how easier it can get than installing xposed framework + X Tether mod and rebooting, or replacing the framework-res.apk file on your phone with the one listed in the OP... either will work.
Click to expand...
Click to collapse
I don't see the framework-res.apk file in OP, am I missing something? I have no idea how to decompile mine to make changes.
fillyo said:
I don't see the framework-res.apk file in OP, am I missing something? I have no idea how to decompile mine to make changes.
Click to expand...
Click to collapse
It's linked to in step (1). It's inside the zip file that's meant to be flashed in a recovery... however, because our bootloader is still locked, we cannot flash a recovery, so the way to do it is by replacing the framework-res.apk file as the filesystem is live, which as the OP mentions, will trigger a soft reboot as this file is used extensively by Android apps.
vacaloca said:
It's linked to in step (1). It's inside the zip file that's meant to be flashed in a recovery... however, because our bootloader is still locked, we cannot flash a recovery, so the way to do it is by replacing the framework-res.apk file as the filesystem is live, which as the OP mentions, will trigger a soft reboot as this file is used extensively by Android apps.
Click to expand...
Click to collapse
I got the framework-res apk from the zip package, I guess I am a little nervous since this is from a dev edition, correct? Anyone else successfully just replace framework-res from the zip package on their retail Verizon GS5?
fillyo said:
I got the framework-res apk from the zip package, I guess I am a little nervous since this is from a dev edition, correct? Anyone else successfully just replace framework-res from the zip package on their retail Verizon GS5?
Click to expand...
Click to collapse
The OP (presumably), user in post #3, and myself before I did the changes manually.
SO I followed these instructions and this is what i get both from adb and Term Em.
mount: No such file or directory
: Read-Only file systemramework-res.apk.bak
: Read-Only file systemramework-res.apk
/mnt/sdcard/download/toggle/run.sh[8]: /mnt/sdcard/download/toggle/sqlite3: can't execute: permission denied
I use the same folder structure you did, created a download folder and extracted the zip...
Thoughts?
tangoboyz said:
SO I followed these instructions and this is what i get both from adb and Term Em.
mount: No such file or directory
: Read-Only file systemramework-res.apk.bak
: Read-Only file systemramework-res.apk
/mnt/sdcard/download/toggle/run.sh[8]: /mnt/sdcard/download/toggle/sqlite3: can't execute: permission denied
I use the same folder structure you did, created a download folder and extracted the zip...
Thoughts?
Click to expand...
Click to collapse
Seems at least like 2 errors... the mount command can't find the input or output directories, thus you attempt to copy the files and get read-only file system, and it looks like sqlite3 needs to be changed to executable... chmod +x sqlite3
Also make sure you're running as root, obviously.
I saw a similar post int the android development subforum, and they seem to believe you will bootloop if you try to overwrite your framework-res. I chickened out and just did the xposed and x tether mod.
vacaloca said:
Seems at least like 2 errors... the mount command can't find the input or output directories, thus you attempt to copy the files and get read-only file system, and it looks like sqlite3 needs to be changed to executable... chmod +x sqlite3
Also make sure you're running as root, obviously.
Click to expand...
Click to collapse
I am rooted. Here's what i had in my run.sh:
#!/sbin/sh
cp /mnt/sdcard/Download/toggle/sqlite3 /data/local/tmp/sqlite3
chmod 0777 /data/local/tmp/sqlite3
mount -o remount,rw /dev/block/mmcblk0p23 /system
cp /system/framework/framework-res.apk /system/framework/framework-res.apk.bak
cp /mnt/sdcard/Download/system/framework/framework-res.apk /system/framework/framework-res.apk
/mnt/sdcard/Download/toggle/sqlite3 /data/data/com.android.providers.settings/databases/settings.db < /mnt/sdcard/Download/toggle/toggles.sql
NOW does this look right??
#!/sbin/sh
cp /mnt/sdcard/Download/toggle/sqlite3 /data/local/tmp/sqlite3
chmod +x 0777 /data/local/tmp/sqlite3
mount -o remount,rw /dev/block/mmcblk0p23 /system
cp /system/framework/framework-res.apk /system/framework/framework-res.apk.bak
cp /mnt/sdcard/Download/system/framework/framework-res.apk /system/framework/framework-res.apk
/mnt/sdcard/Download/toggle/sqlite3 /data/data/com.android.providers.settings/databases/settings.db < /mnt/sdcard/Download/toggle/toggles.sql
I'm sorry as I'm very new to this.
tangoboyz said:
I am rooted. Here's what i had in my run.sh:
#!/sbin/sh
cp /mnt/sdcard/Download/toggle/sqlite3 /data/local/tmp/sqlite3
chmod 0777 /data/local/tmp/sqlite3
mount -o remount,rw /dev/block/mmcblk0p23 /system
cp /system/framework/framework-res.apk /system/framework/framework-res.apk.bak
cp /mnt/sdcard/Download/system/framework/framework-res.apk /system/framework/framework-res.apk
/mnt/sdcard/Download/toggle/sqlite3 /data/data/com.android.providers.settings/databases/settings.db < /mnt/sdcard/Download/toggle/toggles.sql
NOW does this look right??
#!/sbin/sh
cp /mnt/sdcard/Download/toggle/sqlite3 /data/local/tmp/sqlite3
chmod +x 0777 /data/local/tmp/sqlite3
mount -o remount,rw /dev/block/mmcblk0p23 /system
cp /system/framework/framework-res.apk /system/framework/framework-res.apk.bak
cp /mnt/sdcard/Download/system/framework/framework-res.apk /system/framework/framework-res.apk
/mnt/sdcard/Download/toggle/sqlite3 /data/data/com.android.providers.settings/databases/settings.db < /mnt/sdcard/Download/toggle/toggles.sql
I'm sorry as I'm very new to this.
Click to expand...
Click to collapse
The original script should work assuming the files are in the right path... when I mentioned make sure you are running as root meant, make sure you run the 'su' command and get the # prompt before you run the script, otherwise the script won't run with root permissions and will fail.
For the third line, you (and the OP) can replace the mount command with:
Code:
mount -o,remount rw /system
----
As an aside, the chmod 0777 part in the original script already does mark the file as executable... chmod works with generic +rwx (read,write,execute) distinctions or the regular numbering permissions (777 means rwx for everyone)
Edit: the last line of the script should start with: /data/local/tmp/sqlite3
because that's the one that you set the permissions to rwx, not the one in your sdcard
vacaloca said:
The original script should work assuming the files are in the right path... when I mentioned make sure you are running as root meant, make sure you run the 'su' command and get the # prompt before you run the script, otherwise the script won't run with root permissions and will fail.
For the third line, you (and the OP) can replace the mount command with:
Code:
mount -o,remount rw /system
----
As an aside, the chmod 0777 part in the original script already does mark the file as executable... chmod works with generic +rwx (read,write,execute) distinctions or the regular numbering permissions (777 means rwx for everyone)
Edit: the last line of the script should start with: /data/local/tmp/sqlite3
because that's the one that you set the permissions to rwx, not the one in your sdcard
Click to expand...
Click to collapse
Hmm still no dice... Something isn't working right. Really I wanted the Hotspot in the pull down menu. I am currently paying for hotspot anyway....
Just found that wanam xposed has an option to skip provisioning check. Anyone tried this yet? Seems to enable native tethering but doesn't give a quick settings button.
dlscott1111 said:
Just found that wanam xposed has an option to skip provisioning check. Anyone tried this yet? Seems to enable native tethering but doesn't give a quick settings button.
Click to expand...
Click to collapse
Yes, we have tried it and it works. The quick settings button, as I have mentioned earlier in this thread, is what the sqlite3 executable and the file commands it takes in (just a simple text file of DB commands) take care of. You could also just get sqlite editor ($3 from the play store, IIRC) and do them manually if you don't like command line tools. it's basically adding "WiFiHotspot" to system -> notification_panel_active_app_list_for_reset and notification_panel_default_active_app_list in the settings.db file in /data/data/com.android.providers.settings/databases/
Or you could just do it the free with the command line sqlite3 using the tools already at your disposal

INIT.D SUPPORT Kernel method *adds INIT.D folder*

HI guys
I just discovered a way to make init.d work on my rom and it should work on other roms as long as everything is followed down to the T
Basically there are 5 things you need to do
1: BootImageExtractor *links to follow* need to get it from my other laptop
2: Notepad++ *ask google*
3: Rashr *or any other apps that can flash kernels I just use this one*
4: Rooted Device
5: Rootexplorer *or any apps that let you dig deep into the root of THE android*
Ok lets start
First up is to unpack your boot.img and you should see your RAMDISK folder
now go ahead and look for init.rc and open it with notepad++ now add this code either at the very top or below the import scripts.
Code:
import /init.d.sh
You can use any name really as long as you have the same import script and name of the sh file
Now on to the next step which is to create a .sh file
Open up notepad++ and add this code in
Code:
#!/system/bin/sh
on property:sys.boot_completed=1
start sysinit
service sysinit /sbin/sysinit.sh
oneshot
class late_start
user root
group root
disabled
Now save as and use all types and name it init.d.sh and be sure its in the ramdisk folder
Having fun yet?
now last but not the least the sysinit.sh file!
same method as above but with a different code and is saved in the sbin folder
Code:
#!/system/bin/sh
mount -o remount,rw /;
mount -o rw,remount /system
# init.d support
if [ ! -e /system/etc/init.d ]; then
mkdir /system/etc/init.d
chown -R root.root /system/etc/init.d
chmod -R 755 /system/etc/init.d
fi
# start init.d
for FILE in /system/etc/init.d/*; do
sh $FILE >/dev/null
done;
And there you have it folks!
I would like to credit where I got the idea from but alas the guy who gave me the boot.img says he got it from another site and got it randomly.... so would like to thank my buddy Car *actually a human not a machine*
I already tried using the 00test script by Ryuinferno to see if it works and after two reboots I found the test log file in /data
I am new at this so please be gentle and I am still working on this because I want to integrate the scripts of Ryuinferno into the kernel *scripts being the 00test and the 00setperm* he will allow me to use them.
Again thanks XDA! my new home
Feedback please ^_^
Reserved
Where is the difference to the easy to use apps from other devs?
-CALIBAN666- said:
Where is the difference to the easy to use apps from other devs?
Click to expand...
Click to collapse
This is just an alternate method
and there are some phones who cant get init.d to work even with the universal init.d app * i know cause my device has that problem*
I am not saying those apps are not working, infact I use those when I help mates with their phones performance *its easier yes*
and this is something like kernel injection so just flashing a kernel will add init.d and would/could be useful for some devs or guys who just want to know how things tick *like me*
Ok,cool,thanx for answer bro.greeetz!
Working...
Thanks

Categories

Resources