LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 03-03-2017, 12:42 PM   #1
maxf130
LQ Newbie
 
Registered: Feb 2017
Location: Aberystwyth
Distribution: Slackware
Posts: 12

Rep: Reputation: 0
Is it safe to modify init scripts like rc.0/rc.6 on Slackware?


I need to modify the shutdown behaviour of a Slackware system, specifically I need to instruct a UPS controlled using nut to shutdown the inverter and related.

rc.local_shutdown is called to early for this to work, is it safe to modify rc.0/rc.6 directly, or will they just be overwritten on the next sysvinit update?

Thanks
 
Old 03-03-2017, 12:53 PM   #2
ponce
LQ Guru
 
Registered: Aug 2004
Location: Pisa, Italy
Distribution: Slackware
Posts: 7,096

Rep: Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173
I suppose you haven't installed it via SlackBuilds.org: please see README.SLACKWARE
here

https://slackbuilds.org/repository/14.2/system/nut/
 
1 members found this post helpful.
Old 03-03-2017, 02:23 PM   #3
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
Quote:
Originally Posted by maxf130 View Post
is it safe to modify rc.0/rc.6 directly
"Safe" is a relative word. As long as you don't botch anything, you can make any edits you want to the startup/shutdown files. However, if you do it wrong, it is possible to prevent proper startup/shutdown procedures from occurring.

I don't say that to dissuade you from editing them, just giving you the info

The Slackware startup/shutdown scripts are good defaults and work for most people. However, there will always be cases that some users will need to edit the scripts, so don't worry about that.

Quote:
Originally Posted by maxf130 View Post
or will they just be overwritten on the next sysvinit update?
If you check the SlackBuild for sysvinit-scripts, it states the following:

Code:
# Install Slackware scripts and config files from $CWD/scripts/:
mkdir -p $PKG/etc/rc.d
for file in rc.{4,6,K,M,S} rc.cpufreq rc.local rc.loop rc.sysvinit rc.modules rc.modules.local ; do
  cp -a $CWD/scripts/$file $PKG/etc/rc.d/${file}.new
  chmod 755 $PKG/etc/rc.d/${file}.new
  chown root:root $PKG/etc/rc.d/${file}.new
done
The key thing here is that they're being copied as .new files. That means that when the package is upgraded, it will check the existing files and if they aren't the same, it will keep the new files as .new and your existing files as the original. If you use slackpkg, it will prompt you to deal with these new files.

Although, in general, if you make complex edits to complex files like some of the rc scripts, I'd recommend writing down what you did (or maybe making a diff). That way, if something goes wrong, you're able to easily see what you did (whether it is to restore or revert the changes).
 
2 members found this post helpful.
Old 03-03-2017, 06:05 PM   #4
lazardo
Member
 
Registered: Feb 2010
Location: SD Bay Area
Posts: 270

Rep: Reputation: Disabled
Quote:
rc.local_shutdown is called to early for this to work, is it safe to modify rc.0/rc.6 directly, ...
Had a similar situation where rc.local is called "too soon" so used a sub process that sleeps and/or waits for the correct conditions, eg:

Code:
#!/bin/bash
( sleep 1; logger -st rc.local_shutdown "its a test" ) & disown
Otherwise comment clearly and edit away.

Cheers,
 
1 members found this post helpful.
Old 03-03-2017, 10:56 PM   #5
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
http://www.linuxquestions.org/questi...ml#post5635707

I haven't checked -current to see if anything's been done; I'd expect this to be pretty far down the to-do list.
 
Old 03-06-2017, 03:32 AM   #6
maxf130
LQ Newbie
 
Registered: Feb 2017
Location: Aberystwyth
Distribution: Slackware
Posts: 12

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by ponce View Post
I suppose you haven't installed it via SlackBuilds.org:
I did but I missed the README.SLACKWARE...

Thanks very much for everyones responses, edits are made, the ups works and I know where to check for similar info next time :-D.
 
Old 03-06-2017, 08:01 AM   #7
chemfire
Member
 
Registered: Sep 2012
Posts: 422

Rep: Reputation: Disabled
Post

I would suggest making a 'simple' edit to the script that will be easy to merge with future distro releases of the script, this will show up as a .new file as others have mention when that package is installed.

If you need something to run at the very end of the script consider adding something like:

Code:
if [ -d /etc/rc.d/shutdown_local ]; then
 for I in  /etc/rc.d/shutdown_local/*; do
   if [ -x $I ]; then
     . "$I"
   fi 
 done
fi
then create an /etc/rc.d/shutdown_local directory and put your complex logic in files located there, set to execute obviously. If nothing else it will help manage the variable scope and ensure the 'hard parts' of what you are trying to do never accidentally get overwritten.
 
Old 03-06-2017, 08:46 AM   #8
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
If you're going to do that, I would probably suggest using /etc/rc.d/rc.local_shutdown.d/ as similar directories in /etc/ typically contain a .d after the name (see /etc/X11/xorg.conf.d/, /etc/profile.d/, /etc/cron.d/, /etc/modprobe.d/, etc), and the rc. follows the standard naming convention for Runtime Configuration.

But these are just my opinions. I don't know of any standardized naming conventions for this scenario.

Luckily, I don't have anything that needs this type of complexity
 
1 members found this post helpful.
Old 03-07-2017, 08:07 AM   #9
chemfire
Member
 
Registered: Sep 2012
Posts: 422

Rep: Reputation: Disabled
bassmadrigal is of course right, if you are doing this on a single personal system than it probably does not matter. If it a business system or might ever be maintained by someone else his suggestion is a good one. Even if the naming convention might not apply perfectly here it will at least give someone a general clue as to what you did.
 
  


Reply



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
slackware on SSD, init scripts tweaks keefaz Slackware - Installation 3 08-06-2014 06:09 PM
[SOLVED] Modify rc.M for a faster boot, is this safe. samac Slackware 26 05-03-2014 12:40 PM
[SOLVED] init scripts, variables in INIT INFO section catkin Linux - General 1 08-18-2009 02:02 PM
network bridge / bond - slackware network init scripts Slax-Dude Slackware 1 07-17-2009 06:56 AM
Slackware init scripts. jpweston Slackware 1 04-17-2002 11:52 PM

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

All times are GMT -5. The time now is 11:33 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