SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
It always bothered me to have to hand-manage my local startup and shutdown scripts since my needs are rather simple.
What do I mean by simple?
I have additional scripts in /etc/rc.d that I want to run as part of startup and shutdown.
All of these scripts have a "start" option.
All of these scripts have a "stop" option.
I want to run the stop scripts in the reverse order of the start scripts.
I don't want to do anything else unique as part of my local startup.
If you have a setup like that which you would like to easily add and subtract such scripts from your start up, then continue reading. (If you don't, but want to read this anyways, then, umm, go ahead.)
Replace /etc/rc.d/rc.local with...
Code:
#! /bin/sh
# The standard way to start a service
# $1 is the name
# $2 is the log message
std_start() {
if [ -x /etc/rc.d/rc.${1} ]; then
if [ -z "${2}" ]; then
echo "starting ${1} service" | $LOGGER
else
echo ${2} | $LOGGER
fi
/etc/rc.d/rc.${1} start
fi
}
for i in $(/usr/bin/cat /etc/rc.d/local_services); do
std_start $i
done
Add/replace /etc/rc.d/rc.local_shutdown with...
Code:
#! /bin/sh
# The standard way to stop a service
std_stop() {
if [ -x /etc/rc.d/rc.${1} ]; then
/etc/rc.d/rc.${1} stop
fi
}
for i in $(/usr/bin/tac /etc/rc.d/local_services); do
std_stop $i
done
In the file /etc/rc.d/local_services, put the services that you want to start in the order in which you want to start them, such as...
Code:
vde2
libvirt
postgresql
mongodb
There you go. "tac" and "cat" provide the real magic.
If you really do have unique things to run as part of start up and shut down, you could probably just add them at the beginning/end of /etc/rc.d/rc.local and /etc/rc.d/rc.local_shutdown as required.
Of course you realise that you can simply use SysVinit-style scripts to do this?
The only catch is that rc.sysvinit has to be executable, which I think it is by default nowadays.
The best part of it is that it not only meets every requirement in your list, but also enables easy packaging of software which requires something to be run at boot and saves you from reinventing the wheel.
I've said this before (and been routinely panned for it), but it really does make life easier.
Edit: Actually, to enable the functionality, you don't need to change anything. It's already there. You just need to put your custom rc script into /etc/rc.d/init.d/ and put a symlink to it under each runlevel directory at which you want it to run (/etc/rc.d/rc.3 for example). For shutdown, use rc.6 or rc.0, (which are the same thing under Slackware).
It is the neatest solution, IMO, since it's 100% reversible with the removepkg command.
Thanks for sharing. I may not use this right away, but I can see where this could work for me in a few places.
I realize that the rc.sysvinit works just fine, yet I like your approach.
whats about mounting from rc.local, for example?
in that case, we can write, for example, commands with arguments and so on?
also, as i remember, in standart slack there is no file like rc.local_shutdown, as so in instruction not "change" but "create" must use?
Yes, there are many ways to do things in Slackware.
Dropline Gnome used to leverage Slackware's SysVinit compatibility. If you'd like to see how they did it, you can download and examine one of their old HAL or DBUS packages from here: http://sourceforge.net/projects/drop...ckages/2.12.2/. Probably not a good idea to install it since it'll make other irreversible changes, but good to download and look at for the sake of this exercise.
Shame slackware doesn't use a rc.conf. You could have just put it in rc.conf.local with all the other config changes,
rc.conf.local:
Code:
LOCAL_SERVICES="vde2 libvirt postgresql mongodb"
and then have rc/rc.M/rc.local or whatever, do a
Code:
for SERVICE in $LOCAL_SERVICES
do
[ -x "/etc/rc.d/rc.$SERVICE" ] && /etc/rc.d/rc.$SERVICE start
done
Then for shutdown, you could either write a simple function to use on the for loop to reverse the order, or have individual LOCAL_SERVICES_START= and LOCAL_SERVICES_STOP= lists in rc.conf (which would be something additional to maintain, but provides greater control over start/stop order).
I often wish slackware had gone with a bsd style rc.conf/rc.conf.local setup. It makes configuration so tidy.
whats about mounting from rc.local, for example?
in that case, we can write, for example, commands with arguments and so on?
also, as i remember, in standart slack there is no file like rc.local_shutdown, as so in instruction not "change" but "create" must use?
I'm sure that you can expand what I did with little effort; it's pretty much a factor of how complicated you want the launching function to be.
There isn't a rc.local_shutdown by default, but if someone already *had* one and wanted to use this, then they would have to change their version.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.