Re: problems with starting a shell script at boot time from init.<target>.rc

618 views
Skip to first unread message

Pieter

unread,
Aug 2, 2012, 3:47:17 AM8/2/12
to android...@googlegroups.com
Hi all,

I solved it. It seems you have to specify the class, otherwise it is in the class "default". In your init.rc, there are only statements for class_start core and class_start main. So you have to specifiy the class and add (if needed) an appropriate class_start statement.



On Wednesday, August 1, 2012 9:12:13 AM UTC+2, Pieter wrote:
Hi all,

I am trying to call a script at boot time.  The script is available inside /system/sbin, but it seems it is not executed.

Here are the details.
In my init.<target>.rc:

service sampleservice /system/bin/sh /system/sbin/samplescript.sh
     user root
     oneshot

The script itself:
#!/system/bin/sh
echo The sample script works!
echo "The sample script works!" > /data/misc/samplescript

The permissions of /system/sbin/samplescript.sh are as follows: -rw-r--r--    

Doing from command line "sh /system/sbin/samplescript.sh" works perfectly, but it seems the script is not executed at boot time. There are no entries in /data/misc/samplescript

* How can I resolve this issue? Where should I see the output of the "echo" command? Is there another/better way to have it printed in logcat or dmesg?
* The script itself is not executable. Does this matter and if yes, how do I have to make it executable? In my original directory it is executable, but somehow during the copy process (with PRODUCT_LOCAL_COPY) the executable rights disappear.
* Another option I see is that I did not "register" a service as such (e.b. by specifiying "LOCAL_MODULE" in your Android.mk and mention it in core.mk) and perhaps this is just not the right way to call a sh script at boot time?

Any help is more than welcome!
Best regards,
Pieter

Gary

unread,
Aug 2, 2012, 1:44:59 PM8/2/12
to android...@googlegroups.com

The class is the IP adduced or Mac of device's

> --
> unsubscribe: android-kerne...@googlegroups.com
> website: http://groups.google.com/group/android-kernel

William Roberts

unread,
Aug 2, 2012, 10:24:03 PM8/2/12
to android...@googlegroups.com
Shouldn't be executable?

We have something in SE Android that uses something similair in out init.rc we have:

service netlabels /system/bin/selinux-network.sh
    class core
    oneshot

And our Android.mk for the project has this:
include $(CLEAR_VARS)

LOCAL_MODULE := selinux-network.sh
LOCAL_SRC_FILES := $(LOCAL_MODULE)
LOCAL_MODULE_CLASS := EXECUTABLES
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_PATH := $(TARGET_OUT_EXECUTABLES)

include $(BUILD_PREBUILT)

It is important to note that the shell file is executable in the project directory, this way when it gets added to the image it is executable as well.

Hope this helps...
Reply all
Reply to author
Forward
0 new messages