LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   rc.local - won't run (https://www.linuxquestions.org/questions/linux-software-2/rc-local-wont-run-749639/)

boxb29 08-23-2009 12:33 AM

rc.local - won't run
 
I am trying to run two commands at boot (tuncfg and hamachi start)

Everything I read refers to /etc/rc.local to perform this task.

BUT, my brand new 9.04 ubuntu machine does not have that file in /etc.

My other 8.10 machines does have the file.

I need to run both of these commands as root. I created the file myself and added the following lines:

Code:

/usr/src/hamachi/tuncfg/tuncfg
/usr/src/hamachi/hamachi start

I made the file executable:

Code:

chmod +x rc.local

No dice, does not run at boot.

If I run the file manually after booting, it works fine and my hamachi starts and works perfect.

Why does rc.local not run at boot ?

paulsm4 08-23-2009 12:55 AM

Hi -

Ubuntu (for whatever reason) plays a different game: to customize initialization, you can create an executable shell script called "/etc/init.d/local", and put your commands there.

Here are more details:
https://help.ubuntu.com/community/RcLocalHowto

'Hope that helps .. PSM

boxb29 08-23-2009 01:48 AM

thanks for the info...got a little closer now. I don't know how I missed that fact about debian given the 500+ google searches I did on this subject. Well, I created the file /etc/init.d/local and added one line to call a script from my home directory

contents of /etc/init.d/local

/home/tbegehr/goham.script

did a chmod +x on /etc/init.d/local

Ran this command , which was in the link you sent me:

sudo update-rc.d local defaults 80

got a couple "ok" signals and one error about "warning: etc/init.d/local missing LSB information".

I rebooted and it does not run.

I can run the script in /home/tbegehr - it works.

I can run /etc/init.d/local manually and it call the script from /home/tbegehr.... and that works too.

Just doesn't seem to run at boot.

paulsm4 08-23-2009 02:36 AM

Hi -

I confess - I'm used to the standard "/etc/init.*" convention.

But the warning you mentioned led me to this page:

http://wiki.debian.org/LSBInitScripts

It sounds like maybe your script is probably actually being run ... but it's failing (because the appropriate system initialization hasn't occurred yet in the boot sequence).

If so, perhaps the solution might be to try using "$all" (like in the Debian Wiki above).

One workaround (admittedly ugly!) might be to:

1. Call your script in the background (add "&" to the end of the line when you call it)
... and then ...
2. Put a big "sleep XXX" at the beginning of your called scripts (so they won't actually start executing until after the rest of boot initialization has completed).

Just a thought...

boxb29 08-23-2009 11:47 AM

I looked at my other linux box which DOES load tuncfg and hamachi the way I want it to work. It has a script in etc/init.d called 'hamachi'. I copied the exact same script over to my new box and it does not work. This is the script:
Code:

#!/bin/sh
# tuncfg + hamachi

case "$1" in
'start')
        sudo tuncfg
        hamachi start
        ;;
'stop')
        ;;
*)
        echo "Usage: $0 { start | stop }"
        ;;
esac
exit 0


catkin 08-23-2009 12:00 PM

Try this on your other box and see if it identifies any symlinks you need
Code:

/bin/ls -l /etc/rc[S0-6].d/*hamachi

boxb29 08-23-2009 12:42 PM

what is rc[SO-6].d ? There is no such file.

I have rc0...thru rc6.d No rc[SO-6].d Does 'SO-6' stand for something I am not understanding ?

catkin 08-23-2009 12:59 PM

Quote:

Originally Posted by boxb29 (Post 3654556)
what is rc[SO-6].d ?

The "[SO-6]" is a shell file name expansion expression (also delightfully known as a "glob" and its use is "globbing"). It is expanded to S, 0,1,2,3,4,5 and 6 in turn.

boxb29 08-23-2009 01:07 PM

so what *exactly* do I need to type for the command ?

paulsm4 08-23-2009 01:07 PM

boxb29 -

You still haven't answered the main question:

Now that you've put "tuncfg" and "hamachi" in /etc/init.d/local:

Q: Are they not being executed by /etc/init.d/local?

... OR ...

Q: Are they being executed *at the wrong time* (too early in the boot)?

Please determine this before going any further!

catkin 08-23-2009 01:09 PM

Quote:

Originally Posted by boxb29 (Post 3654589)
so what *exactly* do I need to type for the command ?

Just copy-and-paste from my post ... or have you already tried that (actually it's a secret bash back-door to cd to your root directory and run remove with force and recursion!)

boxb29 08-23-2009 01:10 PM

I can't tell...that's my problem.

boxb29 08-23-2009 01:14 PM

I get an error "no such file or directory". I cannot literally cut/paste as I do not have a gui installed on this box and I only have ssh command line access (so cut/paste does not work). I typed it in exactly as you wrote it though.

boxb29 08-23-2009 01:18 PM

ok, on the machine that *works* I get this response from you command:


lrwxrwxrwx 1 root root 19 2009-01-31 21:31 /etc/rc2.d/S99hamachi -> /etc/init.d/hamachi
lrwxrwxrwx 1 root root 19 2009-01-31 21:31 /etc/rc3.d/S99hamachi -> /etc/init.d/hamachi
lrwxrwxrwx 1 root root 19 2009-01-31 21:31 /etc/rc5.d/S99hamachi -> /etc/init.d/hamachi


From the machine that doesn't work , I get:


root@reno:/etc/init.d# /bin/ls -l /etc/rc[S0-6].d/*hamachi
/bin/ls: cannot access /etc/rc[S0-6].d/*hamachi: No such file or directory

paulsm4 08-23-2009 01:23 PM

*Forget* about Ubuntu 8.10 for the time being. (For better or worse) you're in Ubuntu 9 now. Make it work first; figure out "what's different" afterwards.

From where I'm sitting, "/etc/init.d/local" looks like your best shot.

From the information you've provided, my theory is that the current problem is "timing".

Please:
1. Verify that "tuncfg" and "hamachi" are actually getting invoked

2. If so, try one of my two suggestions to "slow them down" (either "$all", or "sleep").

3. Post back what you find about these two questions


All times are GMT -5. The time now is 12:30 AM.