6

I need to run a script that sets cpu_freq .In order to retain the settings after reboot i need to run script which takes care of this issue.I tried to write service in init.rc but the edited part in init.rc disappears on reboot .is there some other way to start script on reboot.thanks

1

4 Answers 4

5

I've found success with magisk. When installed, it adds a directory for boot scripts under /data/adb/service.d, in which you can throw your shell scripts and have them executed by Magisk on boot.

For example, I have the following script:

#!/bin/sh

sleep 15  # to make sure we aren't running in an early stage of the boot process
crond -b -c /data/crontab/

Once created as /data/adb/service.d/start-crond.sh and made executable, it automatically launches crond at boot (provided by Magisk's internal busybox instance).

1
  • 3
    It worked! Had to put sleep 30 instead of 15 in my case. Thank you. Oct 17, 2020 at 23:52
1

Use Script Manager.

2
  • I wrote an init script which changes the governor and maintains the settings.runs on every reboot
    – RanjitRock
    Oct 25, 2011 at 5:37
  • 1
    A link to a potential solution is always welcome, but please add context around the link so your fellow users will have some idea what it is and why it’s there. Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline. Take into account that being barely more than a link to an external site is a possible reason as to Why and how are some answers deleted?.
    – Blue
    Jan 17, 2018 at 21:19
0

This link may be helpful:

[ADDON][Xperia S] Generic startup/init.d scripts support for Stock ROM/Kernel http://forum.xda-developers.com/showthread.php?t=1547238

Although it is for Xperia S, it also works for my ideos. I think the theory behind is quite generic. And if you have installed busybox, you can unzip the downloaded package, read the batch and make some change to the phone by yourself.

If you really want to run your script manually after boot, I prefer scriptme in play market. It's simple and small.

1
  • The linked add-on is no longer available. Can you edit your answer to include the relevant information about what changes it makes to the system to make this work?
    – interfect
    Aug 1, 2021 at 20:12
-1

I had tried to put a script with a simple echo "It runs" > /some_path/some_file.txt command.

It is redirected to a read/write (-rw--rw--rw-) file onto a read/write (drwxrwxrwx) folder.

I also had tested with the script having (-rwx-rwx-rwx) as well as (-rwx-rwx-r-x), etc., no luck at all.

I tested with and without having the file /some_path/some_file.txt, i test with /some_path be every where i could try (also sd-card folders, also internal memory, also where script is and also not putting full path at all).

The file is not modified if exists and is not created if it does not exist, so i can assume the script is not run.

What user/group must have the script? i had tested also with root/root but no luck.

The code:

#!/bin/sh
echo "It runs" > /some_path/some_file.txt

I had test saving it as test.sh, no matter if i put it onto /data/adb/service.d/ and/or onto /data/adb/post-fs-data.d/ folder/s, it get never run.

I had done more than two hundred tests, no luck at all... looks like Magisk is not running the script.

1
  • This more looks like a question and added to comment to the answer detailing magisk
    – rohitanand
    Sep 11, 2023 at 7:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.