PDA

View Full Version : Help with debug code inside rc.sysinit.


Astrosteve
11-12-2006, 07:48 PM
I wanted to put some scripting in the rc.sysinit to backout changes by simply rebooting.
That way I don't have to pull out the drive if something goes wrong.
The idea came from someone elses entry on this forum.

The idea is something like this.

if [ -e /var/hack/foo ]; then
# put the original code here if applicable
rm -f /var/hack/foo
else
touch /var/hack/foo
# put your test code here

fi

I ran a test case where I just wanted to make sure I could create the file and delete the file by placing it inside the rc.sysinit and I found I could do neither.

I placed this section of scripting near the bottom of the rc.sysinit just after a loop that appear to be doing a lot of startup
initialization.

Does anyone have a suggestion.

Thanks

Narf54321
11-13-2006, 01:09 AM
Take out the semi-colon ( ; ) in your if statement.

Also, the touch tool (which updates timestamp on a file, or creates the file if it doesn't exist) is not a part of the standard tivo software base. I believe it is included with Alphawolf's All-in-One S2 utilities (tivotools) so make sure touch actually works on your box.

Astrosteve
11-14-2006, 03:25 AM
The touch command does appear to be supported because I was able to use it from the command line and the syntax of having the ; before the then in the if statement is used elsewhere in the rc.sysinit so I don't think that is causing me problems.

I appreciate the help but it appears that I'm still stuck. Just to make things simpler, I took out the if statement and just put a touch command in the rc.sysinit and I moved it above the loop where all the real stuff happens and still I was not able to create a file.

The /etc/inittab show that it should run the rc.sysinit so I just don't know what is going wrong.

justdoit
11-14-2006, 08:54 AM
if touch is available on command line but not in sysinit file then it looks to be PATH related problem. Find the path of the touch executable (type which touch at shell prompt) and use that path.

assuming path is /bin/touch
if [ -e /var/hack/foo ] ; then
# put the original code here if applicable
rm -f /var/hack/foo
else
/bin/touch /var/hack/foo
# put your test code here
fi

NOTE: During every bootup since the file is deleted if exists and created otherwise above script will alternate between your test code and original code.

ocntscha
11-14-2006, 09:45 AM
Another thing to be aware of is that depending on where you have your touch command in rc.sysinit, /var may not be mounted yet.