Init.d Explanation? - G Tablet Q&A, Help & Troubleshooting

I was playing around with some scripts from Caulkin on some other versions of Froyo to try and improve performance. I have read up on the init.rc script and use of the init.d folder. I have set all this up and have edited the init.rc script to run the init.d scripts, but it gets overridden by the base init.rc on reboot. I had read somewhere that you cannot directly edit the init.rc and that it will be overridden on boot from the boot.img. Can someone confirm that? I thought most roms now have the ability to use init.d out of the box, but it doesn't look like it on Brilliant Corners. Can someone confirm that? Do you know of any Froyo ROMS, other than Caulkins, that has init.d capability? Thanks

markmac said:
I have set all this up and have edited the init.rc script to run the init.d scripts, but it gets overridden by the base init.rc on reboot.
Click to expand...
Click to collapse
Are you using the run-parts program?
I had read somewhere that you cannot directly edit the init.rc and that it will be overridden on boot from the boot.img. Can someone confirm that?
Click to expand...
Click to collapse
That's correct.

Thanks for the response. I was editing the init.rc directly which obviously won't work. So i need to look into building my own boot.img or another option. I was using run-parts setup as a service. I would have thought most kernels/ROMs would support this now, but it does not appear that way.

markmac said:
So i need to look into building my own boot.img or another option.
Click to expand...
Click to collapse
You don't need to build your own new image; you can just modify the existing one by flashing. Take a look at the attachements in these 2 posts where I've done just that. Just make sure the script is idempotent if other people will use it.
Post 1
Post 2

Thanks will definitely check this out.

Looked at this. So to update the init.rc file I would have to edit and package into a boot.img file, then flash the img file with adb or nvflash correct?

markmac said:
So to update the init.rc file I would have to edit and package into a boot.img file, then flash the img file with adb or nvflash correct?
Click to expand...
Click to collapse
No. That's too much work for the user. My technique is meant to be like flashing a new kernel. No external utilities are needed. Just CWM (or, possibly, even standard recovery).

Related

[Q] Start up script for X10?

Anyone know how to get a script to run at every boot? I've tried putting it in /etc/, /etc/init.d, and modifying the xRecovery init.rc with no luck. Any guidance would be greatly appreciated. Thanks.
have you tried to edit the modded chargemon file? it's a part of Xrec and is a simple script which do the mounting, so appending you things at its end could do the job... I think
Adolf1994 said:
have you tried to edit the modded chargemon file? it's a part of Xrec and is a simple script which do the mounting, so appending you things at its end could do the job... I think
Click to expand...
Click to collapse
Thanks, but no dice. Script still didn't run.
kxhawkins said:
Thanks, but no dice. Script still didn't run.
Click to expand...
Click to collapse
whts the script exactly? u want to execute some other script thru chargemon?
oh btw permission are verified right? (chmod 755 <scriptname>)
Some sysctl settings, like busybox sysctl -w parameter=value
Code:
/system/etc/install-recovery.sh
This file never existed, but it's being called from init.rc during the system boot.
Rename your script accordingly and enjoy.
Cheers,
z
AWESOME, thanks so much. I'll try that in just a second...
Nope doesn't work. Would of been nice if you could of report your results after you tried it. (Changed permissions to 777 as well.)
Tried editing init.rc and a post boot script file also at / both ignored and files reverted back to originals on boot (with 1st Jan 1970 as time-stamp).
There is a init file full of random symbols and a few lines of what looks like it should belong in init.rc (mount /system ect), could this be a signed file that reloads the other files on boot or something similar? (Attached to post, had to be zipped cos this forum has a stupid limit on .txt files.)
Seems SE has gone out of its way to stop commands being executed at boot time! I'm running stock ROM. Anyone got any other ideas?
Figured it (Get in!)
I edited /system/etc/hw_config.sh
Look at that init with HTML viewer and scroll down a lot
Sent from my X10i using XDA Premium App

Obtaining root by modifying default.prop(ro.secure)?

To get a privileged shell you need to modify the following lines to the given values in the default.prop file
ro.secure=0
ro.debuggable=1
persist.service.adb.enable=1
Click to expand...
Click to collapse
I have the extracted the recovery image of my phone model : So is it possible to modify the following values in the default.prop file, repack the image and flash it using fastboot(bootloader is unlocked) to get a privileged shell, and then copy the su binary after remounting system as read/write?
Do I need to change any other values in any of the files? And will it work, theoretically at least?
What are the chances of it messing up anything?
[I posted this on android.stackexchange but not much activity there]
No chances of bricking at all
Going further I would suggest you to tag in a shell script within init.rc so that it copies superuser apk and binary automatically as you boot
That's great
And is there any way to confirm that the recovery (downloaded) that I have is indeed from my device? Is the data within the prop files such as build and model no. etc enough?
Sent from my A9 using xda app-developers app
It didn't work. Either it wasn't the stock recovery in the first place, or the process isn't that easy. This can be closed now.
Modify boot.img
I think it is only the boot.img which is to be flashed. You don't need to flash recovery as whole.
If you have root access, you could manually edit default.prop. But, the modifications exist only till reboot. Once you reboot, boot.img will reload all the necessary system files to original. So, edit boot.img.
Adriel David said:
Hello I want to modify default.prop to modify it I need root access now I rooted my phone and cwm installed I want to make a flashable zip backup of default.prop can you provide me the script to be flashed by cwm because I am afraid bricking my phone
Click to expand...
Click to collapse
default.prop is on ramdisk or initrd which is part of the boot.img.
I use abootimg to edit boot, some use mkbootimg. Google editing initrd will give you info you need
varun.chitre15 said:
No chances of bricking at all
Going further I would suggest you to tag in a shell script within init.rc so that it copies superuser apk and binary automatically as you boot
Click to expand...
Click to collapse
Sorry to call on such an old post, but wouldnt this mean that on each boot (if modified on boot.img. On each fireup of recovery if on recovery.img) the superuser apk and binaries are reinstalled? Because this /is/ init.rc we're referring to. Please correct me if I am wrong, and also tell me if this is the best way to go about it I'm trying to come up with a way to root my device without using dirtycow haha

Adding a custom init.rc script

i know we can add a init rc script.. by using..
import /init.something.rc in init.rc or init.<hardware>.rc
but they have to be included in the ramdisk.. so i have to like unpack boot.img, decompress ramdisk,
modify files, compress, repack, flash.. modify files, compress, repack flash.. @[email protected]
is there some way i can get it to load a custom rc script.. in /system or some other partition? so i can just edit the rc script there..
i will add it later to ramdisk.. i just need this for testing.. is there some workaround for this??
hey
psych.half said:
i know we can add a init rc script.. by using..
import /init.something.rc in init.rc or init.<hardware>.rc
but they have to be included in the ramdisk.. so i have to like unpack boot.img, decompress ramdisk,
modify files, compress, repack, flash.. modify files, compress, repack flash.. @[email protected]
is there some way i can get it to load a custom rc script.. in /system or some other partition? so i can just edit the rc script there..
i will add it later to ramdisk.. i just need this for testing.. is there some workaround for this??
Click to expand...
Click to collapse
go here
http://forum.xda-developers.com/showthread.php?t=2073775
moonbutt74 said:
go here
http://forum.xda-developers.com/showthread.php?t=2073775
Click to expand...
Click to collapse
and i know how to unpack/repack boot.img and edit ramdisk... done it like hundereds times..
the problem is that the device i am working on does not have fastboot.. so testing my changes in ramdisk is really difficult...
i just want to add a custom rc script.. somewhere in /system partition.. so i can just edit the rc script there. without having to pack/repack the boot.img
something like this should be added in init.rc or init.<hardware>.rc
Code:
import /system/etc/init.custom.rc
but i don't know where to add that..
hey
psych.half said:
and i know how to unpack/repack boot.img and edit ramdisk... done it like hundereds times..
the problem is that the device i am working on does not have fastboot.. so testing my changes in ramdisk is really difficult...
i just want to add a custom rc script.. somewhere in /system partition.. so i can just edit the rc script there. without having to pack/repack the boot.img
something like this should be added in init.rc or init.<hardware>.rc
Code:
import /system/etc/init.custom.rc
but i don't know where to add that..
Click to expand...
Click to collapse
okay so, probably not what you really want but maybe useful
http://forum.xda-developers.com/galaxy-s3/help/how-to-modify-init-rc-init-d-t2135610
http://forum.xda-developers.com/showthread.php?t=1276578
maybe enabling the boot script thing and biting the bullet for a one time dd will work out
when i'm testing something i switch my boot and recovery to save button ware [DON'T DO THAT IF YOUR SANE!!]
else you'll have to find some way to get the fastboot thing going, maybe test in emulator instead?
moonbutt74 said:
okay so, probably not what you really want but maybe useful
http://forum.xda-developers.com/galaxy-s3/help/how-to-modify-init-rc-init-d-t2135610
http://forum.xda-developers.com/showthread.php?t=1276578
maybe enabling the boot script thing and biting the bullet for a one time dd will work out
when i'm testing something i switch my boot and recovery to save button ware [DON'T DO THAT IF YOUR SANE!!]
else you'll have to find some way to get the fastboot thing going, maybe test in emulator instead?
Click to expand...
Click to collapse
that requires, the root filesystem to be rw.. the initramfs is saved in mmc... :| i will have to look into implementing it..
i have done that.. OwO
hmm.. i will see..
anyways thanks for helping...
confused
psych.half said:
that requires, the root filesystem to be rw.. the initramfs is saved in mmc... :| i will have to look into implementing it..
i have done that.. OwO
hmm.. i will see..
anyways thanks for helping...
Click to expand...
Click to collapse
so, you're not rooted?
can you adb?
what device?
moonbutt74 said:
so, you're not rooted?
can you adb?
what device?
Click to expand...
Click to collapse
i am rooted.. :| i meant, changes to root filesystem are lost on reboot..
the rw kernel mentioned there saves the changes to rootfilesystem...
yeah.. adb works :v
fastboot...
psych.half said:
i am rooted.. :| i meant, changes to root filesystem are lost on reboot..
the rw kernel mentioned there saves the changes to rootfilesystem...
yeah.. adb works :v
Click to expand...
Click to collapse
maybe something helpful in this
http://forum.xda-developers.com/showthread.php?t=2317790
so what device ? what are you trying to achieve?

[resolved] need Init.d script to execute a file on system/bin

Resolution on post #10, in post #11 a second resolution and on post #12 the confirmation.
I need a init.d script to run or execute a service that is on system/bin
Is this possible?
Which commands to use?
I researched a lot, and I do not find anything about it.
The file name is jellyservice.
Jellyservice is a normal service that need to be running before run a app, without that, the app does not run.
I know that:
1. The jellyservice is presented on stock rom and the stock rom use init.rc to call the jellyservice at boot, and i can change the init.rc by change the boot.img (unpack, change, repack), but i wanna to be able to run it on any device wit any kernel, and don't wanna to change it kernel for it rom.
2. I can use SManager to run the file on boot. but i don't wanna to need a app just init.d, init.d is already implemented and working on almost every custom rom, so I put the init.d file on a zip that flash the apk, libs etc, and no more app or config is need.
Thanks.
baybutcher27 said:
I need a init.d script to run a service that is on system/bin
Is this possible?
Which commands to use?
I researched a lot, and I do not find anything about it.
The file name is jellyservice.
Jellyservice is a normal service that need to be running before run a app, without that, the app does not run.
I know that:
1. The jellyservice is presented on stock rom and the stock rom use init.rc to call the jellyservice at boot, and i can change the init.rc by change the boot.img (unpack, change, repack), but i wanna to be able to run it on any device wit any kernel, and don't wanna to change it kernel for it rom.
2. I can use SManager to run the file on boot. but i don't wanna to need a app just init.d, init.d i already have implemented on rom, so I put the init.d file on a zip that flash the apk, libs etc, and no more app or config is need.
Thanks.
Click to expand...
Click to collapse
Is this what you are looking for, or I am missing something?
http://forum.xda-developers.com/showthread.php?t=1933849
And this, which is more up to date:
http://www.xda-developers.com/init-d-support-for-any-rooted-phone/
Ciuffy said:
Is this what you are looking for, or I am missing something?
http://forum.xda-developers.com/showthread.php?t=1933849
And this, which is more up to date:
http://www.xda-developers.com/init-d-support-for-any-rooted-phone/
Click to expand...
Click to collapse
No you did not read what I wrote.
As I said, i wanna a script of init.d that runs or execute a file, i already have init.d working...
baybutcher27 said:
No you did not read what I wrote.
As I said, i wanna a script of init.d that runs or execute a file, i already have init.d working...
Click to expand...
Click to collapse
Sorry, I was assuming you could find help there. By the way, you should be able to do this just by using a script like:
#!/system/bin/sh
-Give permission
/path/jelliservice
Then place it in init.d or write a specific script for init.d to run the above one.
http://android.stackexchange.com/questions/6558/how-can-i-run-a-script-on-boot
Sorry if there's a bigger obstacle I'm not aware of.
Ciuffy said:
Sorry, I was assuming you could find help there. By the way, you should be able to do this just by using a script like:
#!/system/bin/sh
-Give permission
/path/jelliservice
Then place it in init.d or write a specific script for init.d to run the above one.
http://android.stackexchange.com/questions/6558/how-can-i-run-a-script-on-boot
Sorry if there's a bigger obstacle I'm not aware of.
Click to expand...
Click to collapse
No is all good.
but??? that willl run the service, or just give a permission.
I don't really know much about init.d script and the web does not help in that thing i wanna.
i'm implemented it now to see what that script does. :good:
baybutcher27 said:
No is all good.
but??? that willl run the service, or just give a permission.
I don't really know much about init.d script and the web does not help in that thing i wanna.
i'm implemented it now to see what that script does. :good:
Click to expand...
Click to collapse
Oh, so you are just asking for help with the actual script, fine. See if you can figure it out yourself from that post, I'm trying to build an easy example right now. I seem to not have this jelliservice you are talking about, maybe you can give me a few more insights about this.
Ciuffy said:
Oh, so you are just asking for help with the actual script, fine. See if you can figure it out yourself from that post, I'm trying to build an easy example right now. I seem to not have this jelliservice you are talking about, maybe you can give me a few more insights about this.
Click to expand...
Click to collapse
ok.
i tested that you post doesn't do what i need.
i have this on init.d to now if it works.
#!/system/bin/sh
touch /data/local/tmp/init.d_log_test.txt
echo "done" >> /data/local/tmp/init.d_log_test.txt
so i change the "done" of the last line to wherever and it time i reboot it change to wherever i wrote.
so init.d is working fine.
The jellyservice is a service that only exist on motorola stock rom on devices that have dedicated hardware of DTV.
it is started by i .rc file:
init.mmi.dtv.rc
and the content of that .rc is:
Code:
on boot
# DTV feature
service dtv-jelly /system/bin/jellyservice
class main
user system
group system audio camera graphics inet net_bt net_bt_admin net_raw sdcard_rw
iknow that is possible to implemented that .rc on any device by add it to the kernel or boot.img but it will be need to do on any rom and that is allot of work and will be impossible.
so i have created a tread to give support for that DTV to any custom rom, and i wanna to make a more completed .zip to the app.
see the thread here
baybutcher27 said:
ok.
i tested that you post doesn't do what i need.
i have this on init.d to now if it works.
#!/system/bin/sh
touch /data/local/tmp/init.d_log_test.txt
echo "done" >> /data/local/tmp/init.d_log_test.txt
so i change the "done" of the last line to wherever and it time i reboot it change to wherever i wrote.
so init.d is working fine.
The jellyservice is a service that only exist on motorola stock rom on devices that have dedicated hardware of DTV.
it is started by i .rc file:
init.mmi.dtv.rc
and the content of that .rc is:
Code:
on boot
# DTV feature
service dtv-jelly /system/bin/jellyservice
class main
user system
group system audio camera graphics inet net_bt net_bt_admin net_raw sdcard_rw
iknow that is possible to implemented that .rc on any device by add it to the kernel or boot.img but it will be need to do on any rom and that is allot of work and will be impossible.
so i have created a tread to give support for that DTV to any custom rom, and i wanna to make a more completed .zip to the app.
see the thread here
Click to expand...
Click to collapse
You are right, it's not easy to test this out because of default .rc hardcoded into kernel... in order to do this you would have to edit .rc to run that service that runs userinit.sh... Have you already done this? And, are you able to start the service manually?
Ciuffy said:
You are right, it's not easy to test this out because of default .rc hardcoded into kernel... in order to do this you would have to edit .rc to run that service that runs userinit.sh... Have you already done this? And, are you able to start the service manually?
Click to expand...
Click to collapse
i didn't try implemented that .rc on boot.img, that is too much work, and need to be done on it kernel or rom update, but yes can be done.
The file is just like any other executable, just like a .sh or any file you can execute using a app that can execute files like, root browser or SManager.
all the process to run the file is on the thread i just post.
The thing is i already know how to run it via app, but i don't wanna to stop there i wanna to run it via init.d because is a very simple way, but very difficult to find the commands.
Exists any command on init.d that can run a file commands like, run, execute, open or start ?
any of those work? and how to use they?
have any website that have all the command available on init.d?
Hey, you can run a binary from sh by just invoking its path, for example:
Code:
#!/bin/sh
/system/bin/jellyservice
The proccess will spawn with UID 0 (root)
You can change that if you have a good root binary by doing this:
Code:
#!/bin/sh
su system -c '/system/bin/jellyservice'
If you're using supersu I think you have to enable root at boot (Look at the application settings)
baybutcher27 said:
i didn't try implemented that .rc on boot.img, that is too much work, and need to be done on it kernel or rom update, but yes can be done.
The file is just like any other executable, just like a .sh or any file you can execute using a app that can execute files like, root browser or SManager.
all the process to run the file is on the thread i just post.
The thing is i already know how to run it via app, but i don't wanna to stop there i wanna to run it via init.d because is a very simple way, but very difficult to find the commands.
Exists any command on init.d that can run a file commands like, run, execute, open or start ?
any of those work? and how to use they?
have any website that have all the command available on init.d?
Click to expand...
Click to collapse
so i resolve this :silly: :laugh: :victory:
after writing I read, and is so lame.
if the file is just like any other executable way not put it in the init.d folder?
and i put, rename to 99jellyservice
and the init.d run it and the apk that need that file to be running before you open it work.
@Ciuffy
Thanks you help me to find a way...
nagalun said:
Hey, you can run a binary from sh by just invoking its path, for example:
Code:
#!/bin/sh
/system/bin/jellyservice
The proccess will spawn with UID 0 (root)
You can change that if you have a good root binary by doing this:
Code:
#!/bin/sh
su system -c '/system/bin/jellyservice'
If you're using supersu I think you have to enable root at boot (Look at the application settings)
Click to expand...
Click to collapse
the 1° option work perfectly!, but i use like this
Code:
#!/system/bin/sh
/system/bin/jellyservice
i think doesn't make a difference.
Thanks man I will use your way, is better that my. :good:
baybutcher27 said:
the 1° option work perfectly!, but i use like this
Code:
#!/system/bin/sh
/system/bin/jellyservice
i think doesn't make a difference.
Thanks man I will use your way, is better that my. :good:
Click to expand...
Click to collapse
Yeah basically the only difference is that Android has no /bin/sh but /system/bin/sh. I though about just putting that there honestly but I couldn't get any of this working on my cyanogenmod so I was trying to figure out why >.>, but I'm probably missing something.
Anyway, glad I could help!

Add/Inject persistent custom daemon

Hi guys,
I have a nooby question about how can I add a custom daemon to run every time a boot completes?
I know I can unpack the system.img, patch it and flash it again, I know I can also create a flashable ZIP and do the init.rc trick like Magisk does, BUT I'm looking for another way.
My specific question is if there is another way to add an executable to the device persistently and run it after boot completes?
Let's say we are talking on a way which works for most of the common devices.
zachionio said:
Hi guys,
I have a nooby question about how can I add a custom daemon to run every time a boot completes?
I know I can unpack the system.img, patch it and flash it again, I know I can also create a flashable ZIP and do the init.rc trick like Magisk does, BUT I'm looking for another way.
My specific question is if there is another way to add an executable to the device persistently and run it after boot completes?
Let's say we are talking on a way which works for most of the common devices.
Click to expand...
Click to collapse
Run a init.d script.
jwoegerbauer said:
Run a init.d script.
Click to expand...
Click to collapse
Will the script persist after reboot? From what I know , every system modifications would not persist after reboots and init.d exists in system.img.
zachionio said:
Will the script persist after reboot? From what I know , every system modifications would not persist after reboots and init.d exists in system.img.
Click to expand...
Click to collapse
Any System modifiction isn't needed at all: You simply install Init.D Scripts Support app.
More info: https://www[dot]naldotech[dot]com/how-to-run-execute-init-d-scripts-android-no-root/

Categories

Resources