LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 05-27-2011, 02:35 PM   #1
Keith Hedger
Member
 
Registered: Jun 2010
Location: Devon,UK
Distribution: Linux From Scratch, Slackware64,
Posts: 836

Rep: Reputation: 167Reputation: 167
Boot script query ( /etc/rc.d/rc.S/M/0)


Got a query on some odd scripting in the boot up/ shutdown scripts, these scripts in turn call other scripts in /etc/rc.d but do so in an odd way and I want to know why this is, if you look in /etc/rc.d/rc.M the way the scripts are called is different
hal is called by
Code:
sh /etc/rc.d/rc.hald start
acpid is called by
Code:
. /etc/rc.d/rc.acpid start
cups is called by
Code:
/etc/rc.d/rc.cups start
The . in the acpid call tells the interpreter to include the file rather than run as a separate script, and there are other examples, from line 56 of /etc/rc.d/rc.0
Code:
# Run any local shutdown scripts:
if [ -x /etc/rc.d/rc.local_shutdown ]; then
  /etc/rc.d/rc.local_shutdown stop
fi

# Stop the Apache web server:
if [ -x /etc/rc.d/rc.httpd ]; then
  /etc/rc.d/rc.httpd stop
fi

# Stop the MySQL database:
if [ -r /var/run/mysql/mysql.pid ]; then
  . /etc/rc.d/rc.mysqld stop
fi

# Stop the Samba server:
if [ -x /etc/rc.d/rc.samba ]; then
  . /etc/rc.d/rc.samba stop
fi

# Shut down the NFS server:
if [ -x /etc/rc.d/rc.nfsd ]; then
  /etc/rc.d/rc.nfsd stop
fi
Is there any reason for these different ways of calling the scripts?
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 05-27-2011, 04:32 PM   #2
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 5,259

Rep: Reputation: Disabled
Including other rc scripts through the use of the "source" command (which is the dot command's actual name) saves creating a sub-shell. Forking a subshell adds a little bit of overhead to your boot time.

However, if the script which gets sourced contains an "exit" statement it becomes a different story. Look at the rc.hald script which checks for the existence of dbus and aborts with "exit 1" if dbus is not found.
Now, if rc.hald would have been sourced it would be effectively part of rc.M. The "exit 1" statement would then abort rc.M as well, the result would be a broken system because most of rc.M would not be executed. Therefore, rc.hald is started in a subshell so that in case of that error exit, rc.M can just continue with the other bits and pieces.

Eric
 
2 members found this post helpful.
Old 05-28-2011, 05:05 AM   #3
Keith Hedger
Member
 
Registered: Jun 2010
Location: Devon,UK
Distribution: Linux From Scratch, Slackware64,
Posts: 836

Original Poster
Rep: Reputation: 167Reputation: 167
Thanks! didn't think to check for an exit statement in the scripts, but it still seems odd to mix the two different ways of running the rc scripts just to save a small bit of boot time.
 
  


Reply

Tags
boot, script


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
oracle query script investmentbnker75 Programming 1 11-15-2008 09:41 PM
DNS query script Braynid Linux - Newbie 17 07-05-2006 05:45 AM
msyql query from shell script hamish Linux - Software 5 06-02-2006 09:06 AM
Simple shell script query sachinh Programming 5 09-07-2005 04:02 AM
Query about script variable phantomdude Linux - Newbie 1 03-18-2004 11:21 AM


All times are GMT -5. The time now is 02:07 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration