LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   To make scripts running at boot (https://www.linuxquestions.org/questions/slackware-14/to-make-scripts-running-at-boot-4175492536/)

moisespedro 01-25-2014 11:21 AM

To make scripts running at boot
 
What is the difference between using:
chmod +x /etc/rc.d/rc.local
Or:
/etc/rc.d/rc.local enable

?

ponce 01-25-2014 11:53 AM

Quote:

Originally Posted by moisespedro (Post 5105044)
What is the difference between using:
chmod +x /etc/rc.d/rc.local
Or:
/etc/rc.d/rc.local enable

?

the first command doesn't do anything because /etc/rc.d/rc.local (the last script to be executed at boot) is already executable.

the second just executes rc.local: it doesn't know about an "enable" parameter because by default it's empty, it doesn't contain something (commands, function, etc.) to execute when passed that string.

if you want to execute an executable /etc/rc.d/rc.whatever at boot you have to add an if..then like this inside /etc/rc.d/rc.local
Code:

# Starting the whatever daemon
if [ -x /etc/rc.d/rc.whatever ]; then
  /etc/rc.d/rc.whatever start
fi

(obviously the rc.whatever must be an init script - for an example you can see rc.clamav)
ad if you want the "whatever" daemon to stop at shutdown, you have to add something similar to /etc/rc.d/rc.local_shutdown
Code:

# Stopping the whatever daemon
if [ -x /etc/rc.d/rc.whatever ]; then
  /etc/rc.d/rc.whatever stop
fi


moisespedro 01-25-2014 12:05 PM

I am still confused, a tutorial "said" to "chmod +x" to make it executable and to run at boot. Then, I've put "unicode_start" on it. I've run "/etc/rc.d/rc.local enable" and it looks like it worked.

ponce 01-25-2014 12:54 PM

Quote:

Originally Posted by moisespedro (Post 5105063)
I am still confused, a tutorial "said" to "chmod +x" to make it executable and to run at boot.

which tutorial?
the only /etc/rc.d/rc.* scripts that are executed at boot just if you make them executable are the ones which are called from the ones that bring up the system (with an if..then condition like the one above), see /etc/rc.d/rc.M and /etc/rc.d/rc.inet2 for examples.
Quote:

Then, I've put "unicode_start" on it. I've run "/etc/rc.d/rc.local enable" and it looks like it worked.
sorry, I cannot understand what you're talking about.

titopoquito 01-25-2014 01:15 PM

Quote:

Originally Posted by moisespedro (Post 5105063)
I am still confused, a tutorial "said" to "chmod +x" to make it executable and to run at boot. Then, I've put "unicode_start" on it. I've run "/etc/rc.d/rc.local enable" and it looks like it worked.

Since /etc/rc.d/rc.local is executable, of course it will get executed if you call it. You should be able to give it any parameter (supposed you have no lines in it that take the parameter as command). So even calling it "/etc/rc.d/rc.local disable" or "/etc/rc.d/rc.local monkey" should work. "disable", "enable" or "monkey" will have no effect here.

moisespedro 01-25-2014 01:47 PM

Oh, I see. Now I've got it. "unicode_start" was just a command to set UTF properly, according to the tutorial.
Thanks guys.


All times are GMT -5. The time now is 11:51 AM.