LinuxQuestions.org
Help answer threads with 0 replies.
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 04-22-2018, 02:13 PM   #1
upnort
Senior Member
 
Registered: Oct 2014
Distribution: Slackware
Posts: 1,893

Rep: Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161
rc.local_shutdown stop


In rc.K and rc.6 is the command rc.local_shutdown stop. The rc.local_shutdown script is user-created rather than a tradtional rc.d script. What purpose does the stop parameter serve? Should the command just be rc.local_shutdown?
 
Old 04-22-2018, 02:21 PM   #2
SpacePlod
Member
 
Registered: Jan 2014
Distribution: Slackware
Posts: 104

Rep: Reputation: Disabled
Quote:
Originally Posted by upnort View Post
In rc.K and rc.6 is the command rc.local_shutdown stop. The rc.local_shutdown script is user-created rather than a tradtional rc.d script. What purpose does the stop parameter serve? Should the command just be rc.local_shutdown?
I had the same question awhile ago and found this. Pretty succinct answer in there.
 
2 members found this post helpful.
Old 04-25-2018, 01:43 AM   #3
chrisretusn
Senior Member
 
Registered: Dec 2005
Location: Philippines
Distribution: Slackware64-current
Posts: 2,949

Rep: Reputation: 1531Reputation: 1531Reputation: 1531Reputation: 1531Reputation: 1531Reputation: 1531Reputation: 1531Reputation: 1531Reputation: 1531Reputation: 1531Reputation: 1531
I modified that part of rc.6 as follows:

Code:
# Run any local shutdown scripts:
if [ -x /etc/rc.d/rc.local_shutdown ]; then
  /etc/rc.d/rc.local_shutdown stop $shutdown_command
fi
Reason? I need to check how r.6 was called in rc.local_shutdown.
 
Old 04-25-2018, 02:54 AM   #4
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 8,559

Rep: Reputation: 8105Reputation: 8105Reputation: 8105Reputation: 8105Reputation: 8105Reputation: 8105Reputation: 8105Reputation: 8105Reputation: 8105Reputation: 8105Reputation: 8105
Quote:
Originally Posted by chrisretusn View Post
I modified that part of rc.6 as follows:

Code:
# Run any local shutdown scripts:
if [ -x /etc/rc.d/rc.local_shutdown ]; then
  /etc/rc.d/rc.local_shutdown stop $shutdown_command
fi
Reason? I need to check how r.6 was called in rc.local_shutdown.
That does not make sense to me. The rc.6 script calls rc.local_shutdown, not the other way round. The "stop" parameter to rc.local_shutdown script can be used to inform any script you call inside rc.local_shutdown, that the computer is shutting down. I see no point in adding $shutdown_command if "stop" is already provided.
 
Old 04-25-2018, 09:59 AM   #5
upnort
Senior Member
 
Registered: Oct 2014
Distribution: Slackware
Posts: 1,893

Original Poster
Rep: Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161
I asked the original question because I test which way the rc.local_shutdown script is called. Yes, that is my own local customization. Yes, that means I am "on my own" to deal with my local customization.

In the past with rc.K and rc.6 I deleted the 'stop' parameter. I had forgotten I had deleted the parameter long ago. I was testing Current and "rediscovered" the parameter. As my rc.local_shutdown does not test for the 'stop' parameter, I saw an unusual stdout when tinkering with Current. Hardly a show stopper or breath gasper, just that I noticed.

After posting I modified my rc.local_shutdown to test for the 'stop' parameter.

As referenced in the other thread, I apppreciate that having the 'stop' parameter in rc.K and rc.6 is a clever hack, but the parameter is inconsistent with expectations of the rc scripts. The observation is not worth jumping up and down about like Yosemite Sam though.
 
Old 04-26-2018, 11:58 AM   #6
chrisretusn
Senior Member
 
Registered: Dec 2005
Location: Philippines
Distribution: Slackware64-current
Posts: 2,949

Rep: Reputation: 1531Reputation: 1531Reputation: 1531Reputation: 1531Reputation: 1531Reputation: 1531Reputation: 1531Reputation: 1531Reputation: 1531Reputation: 1531Reputation: 1531
Quote:
Originally Posted by Alien Bob View Post
That does not make sense to me. The rc.6 script calls rc.local_shutdown, not the other way round. The "stop" parameter to rc.local_shutdown script can be used to inform any script you call inside rc.local_shutdown, that the computer is shutting down. I see no point in adding $shutdown_command if "stop" is already provided.
I guess I could have said it better. Yes rc.6 calls rc.local_shutdown. The value of shutdown_command is set to either "halt" or "reboot" in rc.6. I need to determine if the system is shutting down or rebooting and pass it to rc.local_shutdown.

Last edited by chrisretusn; 04-26-2018 at 12:03 PM.
 
Old 04-26-2018, 02:25 PM   #7
upnort
Senior Member
 
Registered: Oct 2014
Distribution: Slackware
Posts: 1,893

Original Poster
Rep: Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161
Quote:
I need to determine if the system is shutting down or rebooting and pass it to rc.local_shutdown
In my rc.local_shutdown I run the following:

Code:
RL="$(/sbin/runlevel | awk '{print $2}')"
The run level will be set by how rc.6 is called.

Then this:

Code:
if [ "$RL" = "0" ]; then
  SHUTDOWN_TYPE="halt"
elif [ "$RL" = "6" ]; then
  SHUTDOWN_TYPE="reboot"
fi
$SHUTDOWN_TYPE determines which actions to perform in rc.local_shutdown.

I hope that helps.
 
2 members found this post helpful.
Old 04-26-2018, 02:45 PM   #8
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 8,559

Rep: Reputation: 8105Reputation: 8105Reputation: 8105Reputation: 8105Reputation: 8105Reputation: 8105Reputation: 8105Reputation: 8105Reputation: 8105Reputation: 8105Reputation: 8105
What would you execute differently when rebooting compared to shutting down?
 
Old 04-26-2018, 06:55 PM   #9
upnort
Senior Member
 
Registered: Oct 2014
Distribution: Slackware
Posts: 1,893

Original Poster
Rep: Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161
If you are asking me, only a few things. I did not post previously but I check if the system is suspending or hibernating. I run some synchronizing scripts. When I power down a system on the home LAN I run the scripts but not when rebooting. I check if the system is connected to the home LAN, such as the laptop. If not then don't bother running the scripts. I have some systems on the LAN send a remote notification when powering down. On client systems I run a remote-shutdown script that connects by SSH to the server and creates an at scheduler job to power down -- when no other systems remain online the server powers down too. I run certain tasks when not in run level 1, such as running non-stock rc.d scripts to stop processes.

Possibly overkill, but keeps me entertained and seems to keep me off the streets.
 
Old 04-27-2018, 10:55 AM   #10
chrisretusn
Senior Member
 
Registered: Dec 2005
Location: Philippines
Distribution: Slackware64-current
Posts: 2,949

Rep: Reputation: 1531Reputation: 1531Reputation: 1531Reputation: 1531Reputation: 1531Reputation: 1531Reputation: 1531Reputation: 1531Reputation: 1531Reputation: 1531Reputation: 1531
Quote:
Originally Posted by Alien Bob View Post
What would you execute differently when rebooting compared to shutting down?
I have a problem with my motherboard clock. Here is the rc.local_shutdown part for that.

Code:
# Time is not being set correctly after long shutdowns
# Add a shutdown flag to /etc so it can be tested for on boot up.
# Added a second parameter to rc.6 to pass $command to rc.local_shutdown
if [ "$2" = "halt" ]; then
   touch /etc/shutdown
fi
In rc.local I have:
Code:
# Motherboard is not keeping the time.
# Set the time from a NTP server if system was last shutdown.
# Note: Added code to rc.6 to add file checked for.
if [ -f /etc/shutdown ]; then
   echo "System was shutdown. Getting time from NTP pool server"
   # Remove the shutdown file
   /bin/rm /etc/shutdown
   # Stop the NTP deamon
   /etc/rc.d/rc.ntpd stop
   # Get the time
   echo "Setting the time: /usr/sbin/ntpdate asia.pool.ntp.org"
   /usr/sbin/ntpdate asia.pool.ntp.org
   # Restart the NTP deamon
   /etc/rc.d/rc.ntpd start
fi
Always looking for better ways to do things.

Last edited by chrisretusn; 04-27-2018 at 10:57 AM.
 
Old 04-27-2018, 03:13 PM   #11
upnort
Senior Member
 
Registered: Oct 2014
Distribution: Slackware
Posts: 1,893

Original Poster
Rep: Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161Reputation: 1161
Quote:
Always looking for better ways to do things.
I love seeing how other people fix breakage. Always refreshing.
 
1 members found this post helpful.
Old 04-27-2018, 07:54 PM   #12
chrisretusn
Senior Member
 
Registered: Dec 2005
Location: Philippines
Distribution: Slackware64-current
Posts: 2,949

Rep: Reputation: 1531Reputation: 1531Reputation: 1531Reputation: 1531Reputation: 1531Reputation: 1531Reputation: 1531Reputation: 1531Reputation: 1531Reputation: 1531Reputation: 1531
Quote:
Originally Posted by upnort View Post
In my rc.local_shutdown I run the following:

Code:
RL="$(/sbin/runlevel | awk '{print $2}')"
The run level will be set by how rc.6 is called.
I like, this way I don't have to mess with rc.6

Last edited by chrisretusn; 04-27-2018 at 07:56 PM.
 
  


Reply


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
Syntax/invocation of rc.local vs. rc.local_shutdown moosejaw Slackware 3 01-30-2016 08:42 PM
[SOLVED] rc.local_shutdown not working! Ne36u12Y Slackware 17 02-04-2015 04:08 PM
rc.local and rc.local_shutdown handling Richard Cranium Slackware 9 11-10-2014 02:37 PM
rc.6 and rc.local_shutdown markush Slackware 6 03-29-2013 06:12 PM
'Housekeeping' with /etc/rc.d/rc.local_shutdown? andrew.46 Slackware 3 08-05-2008 07:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 09:10 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration