1

I have created a simple script file "exampleser.sh" in system/core/rootdir/bin/ and added few lines in system/core/rootdir/init.rc file:

on property:sys.boot_complete=1 start example

service example /system/bin/sh /system/bin/exampleser.sh class core user root oneshot

And did make at the root directory of android source code, make is successfully done, but after flashing the service is not running. It is not shown in the adb shell, and the file is not added to /system/bin/ path of the device.

Can anyone please help me what to do? Or the process on how to add the service to the source code?

1 Answer 1

1

Maybe you should add below command in your device.mk to copy your shell file in your system directory when building:

PRODUCT_COPY_FILES += \
    your_shell_file_path:system/bin/your_shell_file_name

At least, you can find your shell file in your device system/bin directory.

Sign up to request clarification or add additional context in comments.

11 Comments

Hi, I added this line, and the file is copying to the directory, but the service is not starting. Any other changes I need to do?
@PrasannaT Maybe your service has started, and finished its work. Maybe you can write a file in a specific directory of device or print some logs to check whether your service has started. If yes, maybe you should add codes in your shell scripts to make sure your service doesn't exit normally, such as while statement. If not, maybe you should check whether your shell scripts has the correct SELinux permission to do your work , and init.rc is correct.
I added while in my script file, it is copied to the device and I'm able to run it in the device, and also added sepolicy and also tried to disable SELinux enforcement, but the script is not running itself just after the boot. I'm not able to understand what else is needed.
@PrasannaT Maybe you should change on property:sys.boot_complete=1 start example to on property:sys.boot_completed=1 (I am split line) start example
Not working. Do I need to create a seperate init.example.rc file and add the service to it?
|

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.