Post Reply

[Guide][init.d]How to run init.d scripts on boot + Best Battery Life

OP kobridge

22nd April 2012, 10:01 PM   |  #31  
gershee's Avatar
Senior Member
Flag Miami, Florida
Thanks Meter: 584
 
1,531 posts
Join Date:Joined: Oct 2006
More
Quote:
Originally Posted by sfhub

The main issue is usually Windows uses CR-LF (Carriage Return + Line Feed) special characters to terminate a line.

Unix/Linux uses LF (Line Feed) to terminate lines.

Mac uses CR (Carriage Return) to terminalte lines.

These special characters cause issues with scripts being interpreted properly. There is also a problem with certain versions where the native text is unicode, which is a multi-byte character set. These characters will look pretty messed up on a single-byte system.

I'm sure you've also taken unix log files and viewed them on windows and just seen a jumbled mess of characters. That is because the LF by itself is not seen as a signal for a newline in windows and basically the whole log file is one big line.

If you want to write your scripts on windows, I suggest you use a text editor which knows how to convert the CR-LF and LF or you use utilities that can convert. Personally I use emacs but I am very old school.

You can find the DOS2UNIX and UNIX2DOS utilities on this page:
http://www.bastet.com/

They will convert the CR-LF and LF so the files can be read properly.

Use DOS2UNIX if you write your script in notepad, then want to move it to Linux/Android. Use UNIX2DOS if you have a file generated on Linux/Android and you want to view it in Notepad.

i've kind of used both mac - text edit and root explorer, so there could be some truth to this. i'll try using the above posted zip.. thanks guys.. appreciate the help.. just frustrating..
22nd April 2012, 10:07 PM   |  #32  
Recognized Contributor
Thanks Meter: 6,845
 
4,757 posts
Join Date:Joined: Oct 2008
Quote:
Originally Posted by gershee

so i showed both my scripts. and the permissions.
and if you see the result of the test script, it does create a file, but 0kb with nothing in it.

Can you use the 0test file kobridge attached to his post above? I verified that it has the proper LF for unix (and I ran it on my phone and received output)

One symptom of CR-LF and LF problems is when the first command runs but nothing after it will run because the shell interpreter thinks there is an error with the run-on line and the unexpected carriage return.

That might be what is happening in your case, because when you "touch" a file, you create a 0 length file if the file isn't present and if it is, it updates the time stamp. That seems to fit your symptoms.
22nd April 2012, 10:09 PM   |  #33  
gershee's Avatar
Senior Member
Flag Miami, Florida
Thanks Meter: 584
 
1,531 posts
Join Date:Joined: Oct 2006
More
Quote:
Originally Posted by kobridge

OK. I ran the test script as in my op section against init.d script and it ran ok.
(To make sure, I deleted previous output file). Just like I said in OP, you need to really careful when you create a file or edit. If you use the file editor from PC or use ES File explorer, there would be some special characters in the script file (hidden). This hidden characters are forgiven in SManager but not in shell script.
So, use some file editor something like root explorer text editor to create a shell script file.

For your convenience, I attached test script file that I just tested. Hope this help.

OK. used your zip. extracted file. put in /system/etc/init.d and changed permissions to 755. rebooted. same thing..:what:
think I'm gonna wipe and start fresh. I dunna. I'm in codename with fd19 kernel.
here's screenies..



its weird. even when I delete the file in root explorer, if I refresh the directory it pops up with 0kb immedietly.. wth is going on..

---------- Post added at 05:09 PM ---------- Previous post was at 05:07 PM ----------

Quote:
Originally Posted by sfhub

Can you use the 0test file kobridge attached to his post above? I verified that it has the proper LF for unix (and I ran it on my phone and received output)

One symptom of CR-LF and LF problems is when the first command runs but nothing after it will run because the shell interpreter thinks there is an error with the run-on line and the unexpected carriage return.

That might be what is happening in your case, because when you "touch" a file, you create a 0 length file if the file isn't present and if it is, it updates the time stamp. That seems to fit your symptoms.

ahhhhh!
just looked in /etc/init.d (not /system) and i found the file also!!
i must have tried doing this last night before bed!!
deleted the file and rebooting now..

EDIT:
nope same thing. guess the system/etc/init.d files are copied to /etc/init.d on boot..
Last edited by gershee; 22nd April 2012 at 10:12 PM.
22nd April 2012, 10:16 PM   |  #34  
Recognized Contributor
Thanks Meter: 6,845
 
4,757 posts
Join Date:Joined: Oct 2008
Quote:
Originally Posted by gershee

its weird. even when I delete the file in root explorer, if I refresh the directory it pops up with 0kb immedietly.. wth is going on..

Well either there is something recreating the file or the file is being prevented from being deleted. When the new file comes up, does it have the same timestamp or is it a newer timestamp?

If the former, then it is being prevented from being deleted. If the latter, then it could be recreated or there is some process that keeps touching the file.

---------- Post added at 09:12 PM ---------- Previous post was at 09:11 PM ----------

Quote:
Originally Posted by gershee

ahhhhh!
just looked in /etc/init.d (not /system) and i found the file also!!
i must have tried doing this last night before bed!!
deleted the file and rebooting now..

/etc is usually a symbolic link to /system/etc

so basically /etc/init.d is the same directory as /system/etc/init.d (I don't mean same as in a copy, I mean they are physically the same directory)

---------- Post added at 09:16 PM ---------- Previous post was at 09:12 PM ----------

BTW I think it is worth looking into why the file keeps reappearing. It could give some clues what is going on.

Is it possible both SManager and init.d are trying to run the same script and they are stomping on each other?
The Following User Says Thank You to sfhub For This Useful Post: [ View ]
22nd April 2012, 10:18 PM   |  #35  
gershee's Avatar
Senior Member
Flag Miami, Florida
Thanks Meter: 584
 
1,531 posts
Join Date:Joined: Oct 2006
More
Quote:
Originally Posted by sfhub

Well either there is something recreating the file or the file is being prevented from being deleted. When the new file comes up, does it have the same timestamp or is it a newer timestamp?

If the former, then it is being prevented from being deleted. If the latter, then it could be recreated or there is some process that keeps touching the file.

---------- Post added at 09:12 PM ---------- Previous post was at 09:11 PM ----------


/etc is usually a symbolic link to /system/etc

so basically /etc/init.d is the same directory as /system/etc/init.d (I don't mean same as in a copy, I mean they are physically the same directory)

1st, yes same timestamp. 22 apr 12 14:59:00
2nd, yes this makes sense.. i though it was something like this, i was just hoping i found the mistake i must have made..
3rd, at first i tried using the new script in the OP to run startup scripts, didn't work so i moved on to sfhub tool.. i'm on aosp rom, does that matter?
must have mucked something up.. everything was running so smoothly too just i'm too OCD to not get this working.. might have to wipe..
22nd April 2012, 10:22 PM   |  #36  
kobridge's Avatar
OP Senior Member
Flag Jacksonville, FL
Thanks Meter: 3,458
 
1,704 posts
Join Date:Joined: Jan 2012
Donate to Me
More
Quote:
Originally Posted by gershee

OK. used your zip. extracted file. put in /system/etc/init.d and changed permissions to 755. rebooted. same thing..:what:
think I'm gonna wipe and start fresh. I dunna. I'm in codename with fd19 kernel.
here's screenies..



its weird. even when I delete the file in root explorer, if I refresh the directory it pops up with 0kb immedietly.. wth is going on..

---------- Post added at 05:09 PM ---------- Previous post was at 05:07 PM ----------



ahhhhh!
just looked in /etc/init.d (not /system) and i found the file also!!
i must have tried doing this last night before bed!!
deleted the file and rebooting now..

EDIT:
nope same thing. guess the system/etc/init.d files are copied to /etc/init.d on boot..

OK. Let me give you the last tweak on your 0test file. Open this file using root explorer text editor.
Pleace the cursor on every end of line. If there is a space between the last character of the line and cursor, remove the space between the last character and cursor (using backspace key). Move forward until last line and do the same thing. I believe this is simply the CR code inserted into your script.
Save the script and you will see the file size 108 Byte. Be sure that you remove the 0test.bak file from /system/etc/init.d directory.
22nd April 2012, 10:23 PM   |  #37  
Recognized Contributor
Thanks Meter: 6,845
 
4,757 posts
Join Date:Joined: Oct 2008
Quote:
Originally Posted by gershee

1st, yes same timestamp. 22 apr 12 14:59:00
2nd, yes this makes sense.. i though it was something like this, i was just hoping i found the mistake i must have made..
3rd, at first i tried using the new script in the OP to run startup scripts, didn't work so i moved on to sfhub tool.. i'm on aosp rom, does that matter?
must have mucked something up.. everything was running so smoothly too just i'm too OCD to not get this working.. might have to wipe..

Is your AOSP using a repacked kernel or the stock kernel?

If the former, or you don't know, could you post the /init.rc file?
22nd April 2012, 10:30 PM   |  #38  
gershee's Avatar
Senior Member
Flag Miami, Florida
Thanks Meter: 584
 
1,531 posts
Join Date:Joined: Oct 2006
More
Quote:
Originally Posted by sfhub

---------- Post added at 09:16 PM ---------- Previous post was at 09:12 PM ----------

[/COLOR]BTW I think it is worth looking into why the file keeps reappearing. It could give some clues what is going on.

Is it possible both SManager and init.d are trying to run the same script and they are stomping on each other?

i looked through smanager and tried to check make sure everything was disabled.. and i uninstallled it.. still nothing..
so weird.. something is fubar..
weird time stamp. constantly being created..
i dunna.. maybe have to wipe..
some small little mistake is screwing this up.. like stuck in a loop halfway through the script.. but where.. wtf!!
guess it doesn't matter.. ill just wipe when my gf leaves and i have some time.. frustrating when i can't stomp out this little biznatch problem...

---------- Post added at 05:26 PM ---------- Previous post was at 05:24 PM ----------

Quote:
Originally Posted by kobridge

OK. Let me give you the last tweak on your 0test file. Open this file using root explorer text editor.
Pleace the cursor on every end of line. If there is a space between the last character of the line and cursor, remove the space between the last character and cursor (using backspace key). Move forward until last line and do the same thing. I believe this is simply the CR code inserted into your script.
Save the script and you will see the file size 108 Byte. Be sure that you remove the 0test.bak file from /system/etc/init.d directory.

i checked, it's 108Bytes, directly from your zip. just moved and changed permissions..

Quote:
Originally Posted by sfhub

Is your AOSP using a repacked kernel or the stock kernel?

If the former, or you don't know, could you post the /init.rc file?

stock kernel. fd19, modified for aosp of course.. the one that came baked in..

it seems like somewhere early early on i messed up and something is looping recreating the same 0byte file. something is screwed..

---------- Post added at 05:30 PM ---------- Previous post was at 05:26 PM ----------

think i've wasted enough of both of you kind sirs time.
obviously it's a bug on my end and something small and clearly overlookable..
i'll just wipe this bad boy when i get a chance and start over i guess.. :/
22nd April 2012, 10:32 PM   |  #39  
kobridge's Avatar
OP Senior Member
Flag Jacksonville, FL
Thanks Meter: 3,458
 
1,704 posts
Join Date:Joined: Jan 2012
Donate to Me
More
What's the permission of your init.d directory? Is it same 755?
22nd April 2012, 10:52 PM   |  #40  
gershee's Avatar
Senior Member
Flag Miami, Florida
Thanks Meter: 584
 
1,531 posts
Join Date:Joined: Oct 2006
More
Quote:
Originally Posted by kobridge

What's the permission of your init.d directory? Is it same 755?

755
rwxr-xr-x

Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes