Run sh-script on boot - Android Q&A, Help & Troubleshooting

I have rooted smartphone Lenovo A Plus (A1010A20) with Android 5.1. I want to schedule some script to be execute on boot. I did not find any "init.d" directory, so I added the script call to "/system/etc/mkshrc" file. But in this case the script executes only after I enter the terminal as a super user. So I installed Busybox and tried to use cron. But I can not make crond service run automatically. I even create folder "/system/etc/init.d/" and put file with script to run crond. But it does not working.
How to make crond service run automatically on Android?

yurybx said:
I have rooted smartphone Lenovo A Plus (A1010A20) with Android 5.1. I want to schedule some script to be execute on boot. I did not find any "init.d" directory, so I added the script call to "/system/etc/mkshrc" file. But in this case the script executes only after I enter the terminal as a super user. So I installed Busybox and tried to use cron. But I can not make crond service run automatically. I even create folder "/system/etc/init.d/" and put file with script to run crond. But it does not working.
How to make crond service run automatically on Android?
Click to expand...
Click to collapse
Try this
https://forum.xda-developers.com/an...ript-zip-init-d-enabler-stock-kernel-t3347724

Related

[TOOL] System apps update.zip auto creator

Hi all
I have created for my first java program a update.zip creator for the nexus one.
This will create a flashable update.zip for updating the system apps on your choice.
I created it for my self to save me time making them every time I wanted to save memory on my phone by moving apps from /data to /system partition (could just of written a script), so thought I would share it.
This is a console tool written in java and only for linux, it will only work on a rooted nexus one running clockwork mod recovery (have not tried any other recovery).
Tested on: nexus one, clockwork mod, CM 7
Programs you can choose to add to the update.zip:
Amazon mp3
Maps
Facebook
Gmail
Rom manager
Android market
Twitter
Youtube
Voice search
Super user
Read the README on how to use it.
Don't forget to run the adb server as root!
Download: http://www.mediafire.com/?pekm9ehswe49x
Any questions,problems,suggestions let me know.
README
Code:
This is a tool I have created for my self to speed up making update.zips for my nexus one and am now sharing.
It is my first java program so it's not perfect but it will improve over time as I learn.
This program will create and sign an update.zip file that will move apps you choose from the /data/app patition to the /system/app partition
It has only been designed to work with the nexus one using Cyanogen mod.
How it works
First it pulls all apps from the /data/app partition on your phone into a created directory with in the PWD
it then scans all the apps for key names of the apps
then if it finds certain apps, it will then ask you if you would like to add it to the update.zip
it then creates the update-script with the commands to delete the apps from the /data/app and copy them to the /system/partition
then it zips the contents and finaly uses the testsign.jar to sign the package.
In the PWD the following programs are needed to run updater-creator:
adb
testsign.jar
update-binary
**** RUNNING THE PROGRAM *****
You must download the apps from the market that you want to update
Leave updater-creator.jar in the directory with ADB and other programs, moving it will prevent the program from finding the programs it needs to run.
You must enable USB debugging on your phone as this program uses ADB.
To run updater creator:
*unzip the file and contents into a directory .
*cd to the dir you unzipped the files to.
*Plug phone in
*Run 'sudo ./adb kill-server' then 'sudo ./adb start-server'
*run the updater-creator.jar file using the following command: java -jar updater-creator.jar
This will create folders and files needed with in the PWD.
Each time you run updater-creator it will over write all previously created files.
I'll give it a try, thank you for sharing your hard work any chance of adding the "read me instructions" to your first post?
Thanks again
Gr8 work,definitely will try it once I get back home
Sent from my Nexus One using XDA App
tina333 said:
I'll give it a try, thank you for sharing your hard work any chance of adding the "read me instructions" to your first post?
Thanks again
Click to expand...
Click to collapse
README now added. Let me know if it works ok or if there are any problems with it, I have tested it my self and had a friend test it with out any problems
If there are any more common apps or features you would like me to add let me know and I will see what I can do.
thank you!! I think this would be pretty useful for myself

How to insmod a module on every boot?

Hello,
I have Pershoot's kernel installed in my HC 3.2. I use my tab to connect to my company VPN using Cisco Anyconnect. In order to stablish the VPN connection y need the tun.ko module loaded, so everytime I need to start the connection I must manually load that module (using a terminal emulator and running insmod /data/local/modules/tun.ko). This works fine but I am wondering if I can modify some system file to load that module everytime y boot the tab.
I did that on my old Xperia X8 modifying init.rc, I tried adding the insmod command in the init.rc file but it didn't worked.
Any advise about how can I load tun.ko on every boot?
Regards,
Patricio
patriciocs said:
Hello,
I have Pershoot's kernel installed in my HC 3.2. I use my tab to connect to my company VPN using Cisco Anyconnect. In order to stablish the VPN connection y need the tun.ko module loaded, so everytime I need to start the connection I must manually load that module (using a terminal emulator and running insmod /data/local/modules/tun.ko). This works fine but I am wondering if I can modify some system file to load that module everytime y boot the tab.
I did that on my old Xperia X8 modifying init.rc, I tried adding the insmod command in the init.rc file but it didn't worked.
Any advise about how can I load tun.ko on every boot?
Regards,
Patricio
Click to expand...
Click to collapse
Inatall script manager. Then create a script and make script manager run it at boot.
Sent from my MB860 using xda premium
d3athsd00r said:
Inatall script manager. Then create a script and make script manager run it at boot.
Sent from my MB860 using xda premium
Click to expand...
Click to collapse
Thanks for your answer but I was looking for something more straightforward, I mean something that doesn't involve installing another app. Isn't that possible in the GT 10.1?
In CM9, you can create a script in /data/local called userinit.sh, add execution permission (chmod +x) and it will run at boot. A simple userinit.sh could be like this:
Code:
#!/system/bin/sh
insmod /data/local/modules/tun.ko
But I don't think you can do the same in your ROM. In your case (this can be done in CM9 too), add a script in /system/etc/init.d , it can be something like 91modules . Add execution permission and it can contain the same code as before. Reboot and it should load your module at boot (be sure that the path to your module is right).
Also, you can do that in one line as root in a terminal. First, be sure that your /system is mounted as rw, not ro. If you don't know how to do that, as root, in a terminal, execute:
Code:
mount -o remount,rw /system
Then:
Code:
echo -e \#\!/system/bin/sh'\n'insmod /data/local/modules/tun.ko > /system/etc/init.d/91modules | chmod +x /system/etc/init.d/91modules
Thanks MapleSyrup for your reply,
First I tried with this in the Terminal:
Code:
mount -o remount,rw /system
echo -e \#\!/system/bin/sh'\n'insmod /data/local/modules/tun.ko > /system/etc/init.d/91modules | chmod +x /system/etc/init.d/91modules
But I received a "No such file or directory Bad mode" error. So I tried creating the module in the init.d directory, but I found that directory doesn't exist in my tablet file system. If I go to /system/etc there is no init.d directory (don't even a file with that name). I am using the stock ROM, could this be the reason why I don't have the init.d directory?
patriciocs said:
I am using the stock ROM, could this be the reason why I don't have the init.d directory?
Click to expand...
Click to collapse
Yes, that's the reason. The easiest way (without using ScriptManager) is using a custom ROM. The other way is modifying the boot image. I'm not really sure how to do this, but maybe this is a start.
My recommendation, if you want to keep the stock ROM without further modification (just rooting), use ScriptManager, is simple, practical and once installed, is out of your way if you only use it to load the module at boot.
Pershoots hc3.2 has init.d support I believe, just need to make the dir for it. Ask in the kernel thread.
Sent from my SPH-D700 using XDA

[Q] Custom Firmware - Running SH scripts on boot

Hey there,
I am around 85% complete on a custom firmware I am developing on the amlogic platform for a new device I am working on.
The base firmware I have used runs sh scripts during boot - and upon shell launch. I have added what sh I want to run into the same directory with the same permissions as existing but mine won't run.
The sh files I need to run either during boot or as soon as boot has completed - simply unpack an tar archive files to a specific location.
Can anyone assist?
Thanks in advance
DA

[Q] Additional Command on Booting

Hi guys. I couldn't install cwm and I want to insert a command to /system/etc/init.goldfish.sh to execute additional script to change files on device booting.
Script file /mnt/external_sd/rv.sh. When it exists it will be executed. I just wanna add "sh /mnt/external_sd/rv.sh". Will this code be a problem when it is just like that.
I hope I could tell everything readable
Thanks.

[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!

Categories

Resources