Jump to content

Welcome to CyanogenMod

Welcome to our forum. Like most online communities you must register to post, but don't worry this is a simple free process that requires minimal information for you to signup. Be a part of the CyanogenMod Forum by signing in or creating an account. You can even sign in with your Facebook or Twitter account.
  • Start new topics and reply to others
  • Subscribe to topics and forums to get automatic updates
  • Get your own profile and make new friends
  • Download files attached to the forum.
  • Customize your experience here
  • Share your CyanogenMod experience!
Guest Message by DevFuse
 

Run Shell Script at Boot

script boot init.d init.rc

  • Please log in to reply
4 replies to this topic

#1 bluegodzilla

bluegodzilla
  • Members
  • 3 posts
  • Device Model:Samsung Galaxy S I9000
  • MOD Version:CM9 Build15
  • Recovery Image:ClockworkMod

Posted 05 February 2012 - 11:40 AM

Hi everyone.

I need to change the permission of the /data/gps folder to rwx-rwx-rwx and I can obviously do this using ES File Explorer or Terminal Emulator but whatever changes I make will be reverted upon reboot.

So I made a shell script to have the folder permission changed at boot (I have no idea if the script is correct though).

Quote

#!/system/bin/sh
chmod 777 /data/gps

I've seen people saying that whatever scripts placed within the init.d folder will be executed automatically upon boot. I have tried putting my script in the init.d folder but it didn't work.

On a separate occasion, I have also tried putting the script in /system/etc and adding the following lines into init.rc file to start the service on boot.

Quote

#testscript
service myscript /system/etc/testscript.sh
oneshot

Obviously, that didn't work as well because whatever lines I add into the init.rc file will be reverted upon reboot. This should be a simple task but I don't have any knowledge on Linux or Android system and I don't know what else to try. If I did anything wrong, could somebody please help me with it. I'm a retard sigh.

Edited by bluegodzilla, 05 February 2012 - 11:53 AM.


#2 Spitemare

Spitemare
  • Members
  • 62 posts
  • Country:us
  • Device Model:Droid 2
  • MOD Version:CM7
  • Recovery Image:ClockworkMod

Posted 06 February 2012 - 01:27 PM

Make a folder on your /data partition:
mkdir -p /data/local/userinit.d

Put your script in that directory and make sure it is executable.

cp <script> /data/local/userinit.d
chmod 755 /data/local/userinit.d/<script>


#3 bluegodzilla

bluegodzilla
  • Members
  • 3 posts
  • Device Model:Samsung Galaxy S I9000
  • MOD Version:CM9 Build15
  • Recovery Image:ClockworkMod

Posted 07 February 2012 - 07:58 AM

View PostSpitemare, on 06 February 2012 - 01:27 PM, said:

Make a folder on your /data partition:
mkdir -p /data/local/userinit.d

Put your script in that directory and make sure it is executable.

cp <script> /data/local/userinit.d
chmod 755 /data/local/userinit.d/<script>

Hi Spitemare,

Thanks for the reply. I just tried doing what you suggested but it doesn't seem to work. Do the scripts placed in /data/local/userinit.d get executed at boot as well? I need to make the script run at boot but I can't figure out why it's not working.

#4 Spitemare

Spitemare
  • Members
  • 62 posts
  • Country:us
  • Device Model:Droid 2
  • MOD Version:CM7
  • Recovery Image:ClockworkMod

Posted 07 February 2012 - 12:46 PM

What's your script look like?

#5 bluegodzilla

bluegodzilla
  • Members
  • 3 posts
  • Device Model:Samsung Galaxy S I9000
  • MOD Version:CM9 Build15
  • Recovery Image:ClockworkMod

Posted 08 February 2012 - 12:39 PM

View PostSpitemare, on 07 February 2012 - 12:46 PM, said:

What's your script look like?
My script is as in my first post.

Anyway, turns out that there's nothing wrong with the script after all. I tested the script with a different ROM and it seems to have worked fine. It doesn't work while I'm on CM9, doesn't CM9 support init.d? Just wondering.