Init.d scripts not executing on boot - Sony Xperia M4 Aqua

I have installed term_init.sh for Init.d support. The scripts run perfectly from SM script manager app. However, they never run upon booting.
I have rooted - Marshmallow.
Any ideas please?

Try this:
1. Create /system/etc/install-recovery.sh (if not exist) set perms to 0755 (rwxr-xr-x) and ownership to 0:2000 (root:shell)
and write:
#!/system/bin/sh
/system/bin/sysinit
2. Create /system/bin/sysinit and set perms to 0755 (rwxr-xr-x) and ownership to 0:2000 (root:shell)
and write:
#!/system/bin/sh
run-parts /system/etc/init.d
3. Create dir /system/etc/init.d and set perms to 0755 (rwxr-xr-x) and ownership to 0:2000 (root:shell)
4. Create /system/etc/init.d/00test and set perms to 0755 (rwxr-xr-x) and ownership to 0:2000 (root:shell)
and write:
#!/system/bin/sh
echo "init.d executed script at boot" > /data/initd.log
5. Reboot and check if /data/initd.log file exist

Thanks!
Yes, the term-init.sh which I installed does everything you have noted above with all permissions. The script executes within Script Manager App but won't execute on boot as intended. Thus, the log file doesn't appear in /data/test.log
Still stuck?

I never do that, so I don't know what can go wrong, but try add init.d service to init.rc:
# Run init.d scripts
service sysinit /system/bin/logwrapper /vendor/bin/busybox run-parts /system/etc/init.d
class main
user root
group shell
oneshot

Related

is there any ways to open support for init.d on version 1.5.7??

i have rooted perfectly,and built the folder /system/etc/init.d and i gave limits of authority to it.besides,i modify the file install-recovery.sh,the content is
【
#!/system/bin/sh
if ! applypatch -c MTD:recovery:2048:b01ab98799f9db633bbc6b43fe0df8fe5cebb820; then
r=`/data/sqlite3 /data/data/com.android.providers.settings/databases/settings.db "select * from system where name='stay_on_while_plugged_in';"`
if [ $r eq "" ]; then
/data/sqlite3 /data/data/com.android.providers.settings/databases/settings.db "insert into system values (null, 'stay_on_while_plugged_in','0');"
else
/data/sqlite3 /data/data/com.android.providers.settings/databases/settings.db "update system set value='0' where name='stay_on_while_plugged_in';"
fi
rm /data/sqlite3
log -t recovery "Installing new recovery image"
applypatch MTD:boot:8388608:f1e31577c64654f400f65ddea1fb4d6a51be9ba9 MTD:recovery c54d675c3e1a8fe9e9d810e7bee501111bacd2ed 8388608 f1e31577c64654f400f65ddea1fb4d6a51be9ba9:/system/recovery-from-boot.p
else
log -t recovery "Recovery image already installed"
fi
# chmod the init.d dir
busybox chmod -R 755 /system/etc/init.d
# run init.d
/system/bin/logwrapper /system/bin/busybox run-parts /system/etc/init.d
】.
but when i reboot the phone,the file Won't enforced.i wonder why?
after testing,when i copy the sh script from init.d to install-recovery,it works.but it confuses me more,why can't i transfer the script from init.d to execute??
mapleshadow said:
after testing,when i copy the sh script from init.d to install-recovery,it works.but it confuses me more,why can't i transfer the script from init.d to execute??
Click to expand...
Click to collapse
Its 5am and I haven't slept much, but have you checked the permissions and made sure they are rw-r-r I've noticed files with different configuration not having these have some issues while running.
Easiest way to look and change is RootExplorer
I ran into a similar issue with my phone. Make sure your init.d folder has execute permissions and the scripts inside the same. i got fed up and made the scripts inside init.d executable ... seems to work now

[Q] Revolution HD add init.d script

Hi all,
I have a problem with the rom in the subject, the headphone amplifier level is too high for me and I want to set a lower value to it.
I created this script:
Code:
#!/system/bin/sh
echo 1 > /sys/devices/virtual/misc/scoobydoo_sound/headphone_eq
echo 40 > /sys/devices/virtual/misc/scoobydoo_sound/headphone_amplifier_level
I have saved it in the /system/etc/init.d/ folder, I have set user and group (root:shell) and permissions (755) like the other scripts in that folder but the script simply isn't started at boot time!
at the end of the file /system/etc/init.post_boot.sh there are these lines:
Code:
# Execute /system/etc/init.d scripts on boot
chgrp -R 2000 /system/etc/init.d
chmod -R 777 /system/etc/init.d
/system/xbin/busybox run-parts /system/etc/init.d
log -p i -t ARHD "init.d support activated"
;;
what I need to do to allow the system to start my script?
thank you!
k4po said:
Hi all,
I have a problem with the rom in the subject, the headphone amplifier level is too high for me and I want to set a lower value to it.
I created this script:
Code:
#!/system/bin/sh
echo 1 > /sys/devices/virtual/misc/scoobydoo_sound/headphone_eq
echo 40 > /sys/devices/virtual/misc/scoobydoo_sound/headphone_amplifier_level
I have saved it in the /system/etc/init.d/ folder, I have set user and group (root:shell) and permissions (755) like the other scripts in that folder but the script simply isn't started at boot time!
at the end of the file /system/etc/init.post_boot.sh there are these lines:
Code:
# Execute /system/etc/init.d scripts on boot
chgrp -R 2000 /system/etc/init.d
chmod -R 777 /system/etc/init.d
/system/xbin/busybox run-parts /system/etc/init.d
log -p i -t ARHD "init.d support activated"
;;
what I need to do to allow the system to start my script?
thank you!
Click to expand...
Click to collapse
actually it seems that no one file inside that directory is started on boot! also the file that already were into the directory!
Ok a developer told me that init.d support will be available from next release!
I'll try something different
Sent from my GT-I9300 using xda app-developers app

Using shell before mounting system partition

Hi, I'd like to ask a general question about device boot. I've made some changes in init.rc and I packed again boot.img. In particular, I've added a .sh script to ramdisk root directory.
The script is named mount_partitions.sh and it does just this task. However, boot.img needs a shell to execute it, but /system is not mounted yet, at that point. So, I need to add a shell to to ramdisk root directory so that init executable can run the .sh script.
Exactly, how I could add shell support in boot.img without mounting the system partition? Any ideas?
Solved
I've found a way to use a shell before mounting system partition. Essentially, it's possible to place a busybox binary (i.e. taken from /system/xbin directory located in another android phone with installed busybox) into ramdisk root directory of boot.img, giving it execute permission in init.rc by chmod command, after remounted ramdisk root directory in read-write mode (by mount command put always in init.rc). It could be also be needed to give execute permission to the shell script (always by chmod command).
Then, it's needed run the shell script by busybox ash command, putting it into init.rc. The line looks like as following:
Code:
exec /busybox ash /myscript.sh
Don't forget to put also a line for remounting ramdisk root directory in read-only mode, after ash shell finished to execute the script (always using mount command in init.rc).
Remember to use the following shebang at the beginning of the shell script:
Code:
#!/busybox sh
shouldn't the shebang end with "ash" instead of just "sh"?
it's just a sh script but it could be true.

Debugging busybox

Hi, I'd like to ask a general question about busybox. I've added busybox binary into ramdisk root directory of boot.img. I've set busybox binary permissions to 0777 in init.rc, in order to be sure not getting any denied permissions issues.
I've put an exec command into init.rc for using busybox cp and it worked because it really made a copy of default.prop in ramdisk root directory. I've also put a start service line into init.rc That service is essentially a busybox sh call for launching a shell script. Unfortunately, it seems shell script is not executed because some cp and echo commands which I put inside it have not effects.
Looking for around the www, it looked like redirection ('>', '>>', ...) is not prohibited by busybox. So, i've also tried to redirect
command output to a file, but file was not created.
So, how could I debug busybox? Any ideas?

Chmod weirdness. Not logical.

So I'm trying to test a script, test.sh which I saved in /cache. Chmod + x test.sh returns bad mode, Chmod 777 and others, 700, 666, etc. does nothing to change the file's permissions and no errors are given. Just for giggles ./test.sh returns not found. Rooted with Magisk, issued su beforehand, terminal app has root (Terminal Emulator). What gives?
Even more interesting....
ls -la shows no changes, however Power File Browser shows the script is 770 and is able to change permissions and shows the permissions changing. It also shows that the script now simply named test is also getting it's permissions changed with chmod, so perhaps there is an issue with ls -la in Stricson's Busybox? But why can't I ./ ?
Ok. Doing a which ls and which chmod shows /bin, but busybox is in /xbin, however calling busybox directly busybox ls -la and gives the same result doesn't show the +x but busybox chmod +x does work, so the chmod in the stock ROM doesn't support using +.
Busybox ./test does nothing either.
Found the issue with the file not running ./ and not found had #!/bin/sh and it requires #!/system/bin/sh at the top of the script.
In conclusion the ls -la command does not work correctly.

Categories

Resources