Ok so I was able to make a bootable boot.img but now I'm trying to get the init.d scripts working. Basically I'm looking to run some commands on boot and felt this is the best way. What I did was put the following in my boot.img's init.rc file:
Code:
# Execute files in /etc/init.d before booting
service sysinit /system/bin/logwrapper /system/xbin/busybox run-parts /system/etc/init.d
disabled
oneshot
Then in my update-script file I added the following to make the directory and containing files executable:
Code:
set_perm_recursive 0 2000 0755 0750 SYSTEM:etc/init.d
set_perm 0 0 0755 SYSTEM:etc/init.d
Then I packaged up the boot.img, added to an update.zip (with custom rom) and flashed it. However it doesn't appear that the scripts inside /system/etc/init.d are running. Anyone have any ideas for me? Anything I'm forgetting to do?
I don't think you can add a directory and have it execute every script within the directory. I believe you need to explicitly call the scripts within the directory. At least that's how every other init.d implementation I've ever worked with functioned.
Good luck!
cent
CentroniX said:
I don't think you can add a directory and have it execute every script within the directory. I believe you need to explicitly call the scripts within the directory. At least that's how every other init.d implementation I've ever worked with functioned.
Good luck!
cent
Click to expand...
Click to collapse
Could you elaborate. I'm not too familiar with the init.d stuff with android right now. So how would I call these scripts at startup? I can't tell where in other roms these scripts are being called.
chuckhriczko said:
Could you elaborate. I'm not too familiar with the init.d stuff with android right now. So how would I call these scripts at startup? I can't tell where in other roms these scripts are being called.
Click to expand...
Click to collapse
Ok, so if you had a script in /etc/init.d called 'doit', you would invoke it by calling /etc/init.d/doit.
So I'd try:
Code:
# Execute files in /etc/init.d before booting
service sysinit /system/bin/logwrapper /system/xbin/busybox run-parts /system/etc/init.d/doit /system/etc/init.d/doit2
disabled
oneshot
I'll be honest that I have zero experience with startup scripts in Android, but I have over 15 years experience as a *nix adminitrator. In every *nix I've ever used, you can't just call upon a directory and have every script within it execute; You have to explicitly call each script.
CentroniX said:
Ok, so if you had a script in /etc/init.d called 'doit', you would invoke it by calling /etc/init.d/doit.
So I'd try:
Code:
# Execute files in /etc/init.d before booting
service sysinit /system/bin/logwrapper /system/xbin/busybox run-parts /system/etc/init.d/doit /system/etc/init.d/doit2
disabled
oneshot
I'll be honest that I have zero experience with startup scripts in Android, but I have over 15 years experience as a *nix adminitrator. In every *nix I've ever used, you can't just call upon a directory and have every script within it execute; You have to explicitly call each script.
Click to expand...
Click to collapse
Sounds good to me. I'll try that and keep this thread updated.
in the custom kernels i built for android 2.1 this is the method i used to call custom scripts in init.rc . pretty sure it should work for you, just change the paths and commands as you need!
## SDX processes
# install busybox
service busybox /sbin/busybox --install -s /bin/
oneshot
# run custom SDX functions
service sdx /sbin/sdx.sh
oneshot
for those wanting to learn the technical details on the init.rc google android has a great article on the commands for their init.rc file.
http://source.android.com/porting/bring_up.html - scroll down to the section title Android Init Language
joeykrim said:
in the custom kernels i built for android 2.1 this is the method i used to call custom scripts in init.rc . pretty sure it should work for you, just change the paths and commands as you need!
## SDX processes
# install busybox
service busybox /sbin/busybox --install -s /bin/
oneshot
# run custom SDX functions
service sdx /sbin/sdx.sh
oneshot
google android has a great article on the commands for their init.rc file but i cant seem to find it at the moment ... will post back if i get it.
Click to expand...
Click to collapse
Even better. Thanks!
CentroniX said:
Ok, so if you had a script in /etc/init.d called 'doit', you would invoke it by calling /etc/init.d/doit.
So I'd try:
Code:
# Execute files in /etc/init.d before booting
service sysinit /system/bin/logwrapper /system/xbin/busybox run-parts /system/etc/init.d/doit /system/etc/init.d/doit2
disabled
oneshot
I'll be honest that I have zero experience with startup scripts in Android, but I have over 15 years experience as a *nix adminitrator. In every *nix I've ever used, you can't just call upon a directory and have every script within it execute; You have to explicitly call each script.
Click to expand...
Click to collapse
I just realized the run-parts command in busybox runs a bunch of scripts in a directory (description if you run busybox runparts by itself) so this should work.... but it doesnt...
From the documentation joeykrim linked:
Services
Services are programs that init launches and (optionally) restarts when they exit.
Services take the form of:
service <name> <pathname> [ <argument> ]*
<option>
<option>
Click to expand...
Click to collapse
So you'd want:
Code:
service <name> /etc/init.d/your-script-here
oneshot
You'll need to add that block for each script you wish to run.
Furthermore, the documentation states
disabled - This service will not automatically start with its class. It must be explicitly started by name.
Click to expand...
Click to collapse
So the fact that you have the 'disabled' option set might be the reason it's not executing.
CentroniX said:
From the documentation joeykrim linked:
So you'd want:
Code:
service <name> /etc/init.d/your-script-here
oneshot
You'll need to add that block for each script you wish to run.
Furthermore, the documentation states
So the fact that you have the 'disabled' option set might be the reason it's not executing.
Click to expand...
Click to collapse
Well that disabled is why it wasn't trying to run the script however when I removed disabled it kept looping at the first boot screen (before the animated one). So I just tried taking the code out of the init.rc and putting it in the bootcomplete.supersonic.rc file. This allowed the phone to boot but it looks like the scripts aren't running at all. Ugh. lol
Ok so I figured it out. In all of the init.d setups I have seen they create a service in the init.rc that will load all the scripts in the init.d directory and then after the file system loads they start that service. Well, the boot process for the Evo is apparently a little different. HTC changed things to have seperate rc scripts for when the boot and shutdowns are complete. So the bootcomplete.supersonic.rc file is what we want to modify.
This script doesn't work with the init.rc commands but it does work with simple linux shell commands. So simply adding
Code:
/system/xbin/busybox run-parts /system/etc/init.d
to the bottom of this file will call all scripts inside the /system/etc/init.d folder on boot completion.
Good to know, and glad you got it working!! Hopefully we'll see a kickass ROM from you soon!
CentroniX said:
Good to know, and glad you got it working!! Hopefully we'll see a kickass ROM from you soon!
Click to expand...
Click to collapse
Well it will be better than my last (hopefully released today) but nothing truly kick ass until we get kernel source in which the camera works. Oh the possibilities.
chuckhriczko said:
This script doesn't work with the init.rc commands but it does work with simple linux shell commands. So simply adding
Code:
/system/xbin/busybox run-parts /system/etc/init.d
to the bottom of this file will call all scripts inside the /system/etc/init.d folder on boot completion.
Click to expand...
Click to collapse
so you added that line to bootcomplete.supersonic.rc ?
interesting HTC modified the boot order and setup, but not surprising.
glad we now know how to execute multiple scripts.
out of curiosity and hopefully not off topic, what are you executing in multiple scripts which couldn't be executed in one script called by the original init.rc file?
for reference, when running one individual script, the code i posted above, adheres to google's standard and should work fine.
# run custom SDX functions
service sdx /sbin/sdx.sh
oneshot
joeykrim said:
so you added that line to bootcomplete.supersonic.rc ?
interesting HTC modified the boot order and setup, but not surprising.
glad we now know how to execute multiple scripts.
out of curiosity and hopefully not off topic, what are you executing in multiple scripts which couldn't be executed in one script called by the original init.rc file?
for reference, when running one individual script, the code i posted above, adheres to google's standard and should work fine.
# run custom SDX functions
service sdx /sbin/sdx.sh
oneshot
Click to expand...
Click to collapse
Oh I could have put it all in one script but for cleanliness I wanted multiple scripts. This way they can more easily be read and modified. I hate ugly dirty cluttered code and directories.
Actually, you could've left the lines the way they were...
Right above class_start default, put the following two lines in:
start sysinit
on property:cm.filesystem.ready=1
The last line is to stop init.rc until you set the cm.filesystem.ready property (you do that from one of the scripts in /system/etc/init.d)
chuckhriczko said:
Ok so I figured it out. In all of the init.d setups I have seen they create a service in the init.rc that will load all the scripts in the init.d directory and then after the file system loads they start that service. Well, the boot process for the Evo is apparently a little different. HTC changed things to have seperate rc scripts for when the boot and shutdowns are complete. So the bootcomplete.supersonic.rc file is what we want to modify.
This script doesn't work with the init.rc commands but it does work with simple linux shell commands. So simply adding
Code:
/system/xbin/busybox run-parts /system/etc/init.d
to the bottom of this file will call all scripts inside the /system/etc/init.d folder on boot completion.
Click to expand...
Click to collapse
tkirton said:
Actually, you could've left the lines the way they were...
Right above class_start default, put the following two lines in:
start sysinit
on property:cm.filesystem.ready=1
The last line is to stop init.rc until you set the cm.filesystem.ready property (you do that from one of the scripts in /system/etc/init.d)
Click to expand...
Click to collapse
interesting approach! thanks for sharing this!
i assume this on property cm.filesystem.ready feature must be exclusive to android?
would the logic also follow, you'd set ready to 0 in the last of the scripts located under /system/etc/init.d ?
would there be any downside to this approach? if there was an error in the script files and they stopped, would loading of the init.rc also stop and severely stall the boot up process?
joeykrim said:
in the custom kernels i built for android 2.1 this is the method i used to call custom scripts in init.rc . pretty sure it should work for you, just change the paths and commands as you need!
## SDX processes
# install busybox
service busybox /sbin/busybox --install -s /bin/
oneshot
# run custom SDX functions
service sdx /sbin/sdx.sh
oneshot
for those wanting to learn the technical details on the init.rc google android has a great article on the commands for their init.rc file.
http://source.android.com/porting/bring_up.html - scroll down to the section title Android Init Language
Click to expand...
Click to collapse
Also:
https://android.git.kernel.org/?p=p...5790acb05904ddd109ed33de3863a4b413d53;hb=HEAD
And take a look at:
http://www.androidenea.com/2009/08/init-process-and-initrc.html
leonnib4 said:
Also:
https://android.git.kernel.org/?p=p...5790acb05904ddd109ed33de3863a4b413d53;hb=HEAD
And take a look at:
http://www.androidenea.com/2009/08/init-process-and-initrc.html
Click to expand...
Click to collapse
hey man does this work with the desire too??????? cause i have been unable to achieve custom boot scripts with desire init.rc
Im confused can someone help me figure it out!
ok so here the confusion
set_perm_recursive(0, 0, 0777, 0777, "/system/etc/init.d"); changhong z-me updater script
set_perm_recursive(0, 2000, 0755, 0755, "/system/etc/init.d"); ideos x6 updater script
I don't know which 1 to put in the update script!?!
Im trying to port cm7 to changhong z-me and using ideos x6 as port.
Here is Bash and Busybox binaries with some configuration files I uses in my galaxy Young
I use Bash instead of builtin sh because of its well known features like
* persistent history
*reverse search in history
*Auto completion etc....
I ues Jackpal's Android-Terminal-Emulator App and those who uses ConnectBot may have to edit one line in the file 'rc'
simply extarct the zip file in sdcard (say '/sdcard/Bash_and_Busybox' )
open ur terminal App (Mine is Jackpal's Android-Terminal-Emulator)
type
Code:
busybox cp /sdcard/Bash_and_Busybox/* ./
chmod 777 ./bash ./busybox ./runbash
and to run the bash , simply use
Code:
./runbash
Hope this will be help full.
Yes,I really want to meet the 10 post threshold of xda
Click to expand...
Click to collapse
https://github.com/jackpal/Android-Terminal-Emulator/wiki
open source terminal emulator by jackpal
Does either bash or busybox require a rooted phone or they will work with an unrooted one as well?
I made a small script to defrost ALL disabled packages, useful for enabling frozen APKs or for re-enabling them after a reboot.
It will enable apps disabled by user too, so keep that in mind.
Just push it via ADB to /system/bin or /system/xbin, then chmod 755 to make it executable.
You can use a file manager with root features to move the file, but remember to set permissions to -rwxr-xr-x.
It requires root, so you have to run su command in terminal before executing it.
rewritten, it's faster now
Did anyone successfully install debian kit on the galaxy note 10.1 (2014) ?
I tried,
sh /storage/emulated/0/debian-kit-1-6.shar
unpacks properly, but then nothing happens. A wizard is supposed to start.
I tried both 1-6.shar from Doviak, and 1-5.shar from sven-ola
I did the following. Start with unrooted device. Accept KK OTA upgrade. Now
I have SM-P600 with Android 4.4.2. Root with CF. This fails.
Flash openrecovery-twrp-2.6.3.3-lt03wifiue.img.tar with Odin. Then boot into TWRP and
install UPDATE-SuperSU-v1.94.zip. Now some apps ask for root access and it seems to be
granted; installed sdfix, and at least one app (aplinequest) that could not write after
the KK upgrade can now write to extsdcard.
Installed Debian Kit app. All green checks, except red Xs for "Kernel modules supported"
and "Valid 'su' command found". But I know su is working. (I think there was a red X by Debian
Kit already unpacked)
Transfer debian-kit-1-6.shar to device. I follow instructions, Install connectbot. Give 'su'.
Run sh /storage/emulated/0/debian-kit-1-6.shar
Get error messages (I didnt record them), such as md5sum not found, and
a couple of other binaries not found. I give echo $PATH and then look for these binaries
in my path. They are not there. So I install BusyBox Free. Run the shar file again. I
get a list of files extracted, but then nothing happens. Now I see that debian kit wants
to use its own busybox and I didnt need to install busybox, but debian kit did not work
in any case.
I try to run /data/local/deb/autorun with sh autorun. Exits with "Unsupported CPU or architecture"
Investigate and find shell var CPU is set correctly to "armel" on first past, but when the script
runs again with exec, CPU is ''. So I hardcode CPU=armel. Then I can get a little further.
And so on and so on, hardcoding CPU in all the scripts. Trying to get the scripts to see the
correct binaries, etc. Now I have a diskimage installed, can't go forward and can't uninstall.
If anyone can shed some light....
update
Deleted everything and started over. Using adb shell. I notice
that the installer says
Included busybox failed.
and tries to use system tar, sed, etc, which it cannot find.
However, If I put #!/system/bin/sh at the top of debian-kit-1-5.shar
And run ./debian-kit-1-5.shar rather than sh ./debian-kit-1-5.shar,
then the script runs for quite a while and extracts a lot of files.
It fails eventually with
ash: id: Permission denied
In fact, from the adb shell I get
126|[email protected]:/data/local # id
uid=0(root) gid=0(root) context=u:r:init:s0
[email protected]:/data/local # ./deb/armel/busybox ash -c "id"
ash: id: Permission denied
126|[email protected]:/data/local # ./deb/armel/busybox ash -c "/system/bin/id"
ash: /system/bin/id: Permission denied
More Update
It seems that in some cases the user 'shell' has permission to do something, but 'root' does not.
One thing stopping the debian kit install process is that root running a shell located under /data cannot run any executables via
passing a string on the command line. They can run commands interactively (maybe because the command
line uses exec ?). But the user 'shell' can run executables this way. E.g. I copied /system/bin/mksh to the /data partition.
[email protected]:/ $ su
[email protected]:/ # /data/local/bin/mksh -c "id"
/data/local/bin/mksh: id: Permission denied
1|[email protected]:/ # /system/bin/mksh -c "id"
uid=0(root) gid=0(root) context=u:r:init_shell:s0
[email protected]:/ # su shell
[email protected]:/ $ /data/local/bin/mksh -c "id"
uid=2000(shell) gid=2000(shell) context=u:r:init:s0
There are a few posts scattered around other forums mentioning the same problem when trying to
install debian kit, but no responses even recognized that there was a problem.
The solution was to install an selinux permissive kernel. Then installation
went normally.
I think I can help.
injola said:
Did anyone successfully install debian kit on the galaxy note 10.1 (2014) ?
I tried,
sh /storage/emulated/0/debian-kit-1-6.shar
unpacks properly, but then nothing happens. A wizard is supposed to start.
I tried both 1-6.shar from Doviak, and 1-5.shar from sven-ola
I did the following. Start with unrooted device. Accept KK OTA upgrade. Now
I have SM-P600 with Android 4.4.2. Root with CF. This fails.
Flash openrecovery-twrp-2.6.3.3-lt03wifiue.img.tar with Odin. Then boot into TWRP and
install UPDATE-SuperSU-v1.94.zip. Now some apps ask for root access and it seems to be
granted; installed sdfix, and at least one app (aplinequest) that could not write after
the KK upgrade can now write to extsdcard.
Installed Debian Kit app. All green checks, except red Xs for "Kernel modules supported"
and "Valid 'su' command found". But I know su is working. (I think there was a red X by Debian
Kit already unpacked)
Transfer debian-kit-1-6.shar to device. I follow instructions, Install connectbot. Give 'su'.
Run sh /storage/emulated/0/debian-kit-1-6.shar
Get error messages (I didnt record them), such as md5sum not found, and
a couple of other binaries not found. I give echo $PATH and then look for these binaries
in my path. They are not there. So I install BusyBox Free. Run the shar file again. I
get a list of files extracted, but then nothing happens. Now I see that debian kit wants
to use its own busybox and I didnt need to install busybox, but debian kit did not work
in any case.
I try to run /data/local/deb/autorun with sh autorun. Exits with "Unsupported CPU or architecture"
Investigate and find shell var CPU is set correctly to "armel" on first past, but when the script
runs again with exec, CPU is ''. So I hardcode CPU=armel. Then I can get a little further.
And so on and so on, hardcoding CPU in all the scripts. Trying to get the scripts to see the
correct binaries, etc. Now I have a diskimage installed, can't go forward and can't uninstall.
If anyone can shed some light....
Click to expand...
Click to collapse
I have the same tablet and I tried to answer you several times but when I give exact instructions they don't let my reply get to the thread for some reason. So I'll have to be less specific, sorry. Anyway. I rooted with an omnirom based setup. 412. Homemade. Once you get the debian-kit-1-6-testing.jpeg and you've unloaded it to you your root directory try:
#sh /data/local/deb/mk-debian -i
Follow the usage correctly and until your done testing leave:
-h
At the end of the script. But be sure to set it to armel and 2047 and wheezy and set the mirror to:
deb. .org/dists/wheezy/ main contrib non-free
Kali
catch all the protools and for the gpg licence use google search my username KeizerPaPa and I'll give you the gpg on my + account. Goodluck. ]
---------- Post added at 06:40 PM ---------- Previous post was at 06:28 PM ----------
KeizerPaPa said:
I have the same tablet and I tried to answer you several times but when I give exact instructions they don't let my reply get to the thread for some reason. So I'll have to be less specific, sorry. Anyway. I rooted with an omnirom based setup. 412. Homemade. Once you get the debian-kit-1-6-testing.jpeg and you've unloaded it to you your root directory try:
#sh /data/local/deb/mk-debian -i
Follow the usage correctly and until your done testing leave:
-h
At the end of the script. But be sure to set it to armel and 2047 and wheezy and set the mirror to:
deb http .org/dists/wheezy/ main contrib non-free
Kali
catch all the protools and for the gpg licence use google search my username KeizerPaPa and I'll give you the gpg on my + account. Goodluck. ]
Click to expand...
Click to collapse
Make sure you piece the above together correctly, they wouldnt let me type it all together. Thats deb http: //http
Then .kali then .org/dists....... have fun. If ya get stuck on the gpg search me and ask. KeizerPaPa
A reason why mine failed at first was because "Debian kit" is set to resolve ip addresses using "only" your Primary DNS Server (DNS 1). When I finally pinged my Primary DNS server, I found it was not functional. My Secondary DNS server (DNS 2) was functional (this also explains why my internet was slower than it should have been while browsing the internet)
I changed my Primary DNS server by
1) going into the WIFI settings
2) long-pressing on the WIFI I was connected to
3) choosing "Mofify..."
4) checking the "Show advanced..." option
5) changing from "DHCP" to "Static"
6) entering a functional DNS server (such as 8.8.4.4) for "DNS 1"
- Hyp
Well, I have essentially done everything wrong that you can do wrong.
For security considerations, I wanted to disable my baseband modem on my LG G4 H815 (currently having /e/ installed) - see this beautiful post for the instructions.
As I don't have root, I had the genius idea to do it all via the TWRP recovery. Once booted into the recovery, I had to enter my encryption lock, but that didn't work. I had yet another genius idea, thinking that I probably wouldn't have to unlock the encryption, as I only wanted to disable the modem (and didn't care to backup my data). So I entered TWRP leaving the system read-only.
Then I entered the terminal and wanted to disable the relevant services, as described in the post. However, the pm command wasn't available in the TWRP shell, so I had the genius idea to just skip those steps.
I then wanted to override the radio with zeros (as described in the post). However, the exact file from the post didn't exist, so I had the genius idea to overwrite /dev/block/platform/soc.0/f9824900.sdhci/by-name/modem instead. However, I firstly wanted to back it up to my external SD (I assumed that wouldn't be affected by the encryption) and did so with dd. After also having the modem overwritten with 0s (and synced) I rebooted to system, where I got the error that "Settings," stopped working and my phone started rebooting to recovery.
I thought "oh well, I'll just restore the backup modem from the SD", however I had to realize that (probably because I hadn't mounted the SD properly) the file didn't exist on the SD (anymore).
That's the current state. As I don't really want to lose my data (that I didn't backup), I haven't tried re-flashing anything yet (especially as I don't know if this'd help).
Is there any way to recover the "modem" without losing my data? Or, even better, is there a way to continue disabling the modem, with my phone properly booting again?
I really appreciate your help - please let me know if you need further information.
EDIT: It would probably be super helpful (and enough) if someone out there with the H815 could dump the content of their modem dev and share it with me. I don't think (?) that's included in a system image - at least it isn't mounted in system.
EDIT: Let me provide some instructions on how to (presumably) safe my day, if you have an H815 with TWRP recovery and adb on your computer:
Reboot to recovery:
Bash:
adb reboot recovery
In TWRP, mount your Micro SD card or another partition you can read & write to (Mount -> Tick Micro SD card)
Restart adb:
Bash:
adb kill-server
Enter adb shell:
Code:
adb shell
In adb shell, validate that your SD (or other partition) is correctly mounted (you should get the contents of your external SD):
Bash:
ls /external_sd
In adb shell, dump data from modem and exit adb shell:
Bash:
dd if=/dev/block/platform/soc.0/f9824900.sdhci/by-name/modem of=/external_sd/modem.img
sync
exit
Pull dump from device:
Bash:
adb pull /external_sd/modem.img
Upload modem.img from your computer (from the directory you executed above command from) to some cloud
Share a link to the file with me
I'd be very grateful if someone could do this. Please feel free to ask questions about the procedure or to help me in any other way.
Turns out, someone already did upload a modem - it's even linked in the install instructions for /e/. I used this file (flashed via TWRP) and it seems to have fixed my issues.
Of course, now the modem still isn't disabled - so if someone has an idea on how to achieve this without bricking my phone (preferrably also without having to root it), feel free to make me happy.
I now have tried killing the modem with rooting my phone, but it lead to the same error. Before deleting the modem, I ran the following commands in adb shell to mimick the disabled services from the original post as best as possible:
Bash:
su -c "pm disable com.android.cellbroadcastreceiver"
su -c "pm disable com.android.mms"
su -c "pm disable com.android.phone"
su -c "pm disable com.android.providers.telephony"
su -c "pm disable com.android.smspush"
su -c "pm disable com.android.mms.service"
su -c "pm disable foundation.e.message"
su -c "pm disable com.android.server.telecom"
su -c "pm disable com.qualcomm.qcrilmsgtunnel"
su -c "pm disable foundation.e.esmssync"
Do I have to put this in a startup script? And if so, how do I do this?
It does seem as if they stayed deactivated though:
Bash:
$ su -c "pm list packages" -d
package:com.android.providers.telephony
package:com.android.mms.service
package:com.android.terminal
package:foundation.e.message
package:com.qualcomm.qcrilmsgtunnel
package:com.android.cellbroadcastreceiver
package:com.android.server.telecom
package:com.android.smspush
package:foundation.e.esmssync
package:com.android.phone
I'd love to know how I can achieve this.
EDIT: Now my phone reboots as soon as it's disconnected from my computer (and doesn't boot anymore)...