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 09-06-2018, 09:06 PM   #1
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: Carrollton, Texas
Distribution: Slackware64 14.2
Posts: 3,265

Rep: Reputation: 1626Reputation: 1626Reputation: 1626Reputation: 1626Reputation: 1626Reputation: 1626Reputation: 1626Reputation: 1626Reputation: 1626Reputation: 1626Reputation: 1626
rc.local and rc.local_shutdown implementation


This handles fairly simple cases, assuming that you'd stop extra services in the reverse order from the way you started them.

There are a few cases that would require some rather silly scripts; a case in point is where you might have to shutdown the httpd service, start zoneminder, start nexus, and then start httpd again. You could shoehorn that into this setup, but you might not care to do so.


/etc/rc.d/rc.local
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
/etc/rc.d/rc.local_shutdown
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
On my system, /etc/rc.d/local_services contains...
Code:
docker
vde2
libvirt
postgresql
mongodb
tomcat
Of course, you could just use the SysV method as well.

I'll mark this as solved since I don't really have a problem.
 
Old 09-07-2018, 06:40 AM   #2
lotar
LQ Newbie
 
Registered: Aug 2012
Location: Rome
Distribution: Slackware64 -current, CentOS
Posts: 12

Rep: Reputation: 21
Very nice and useful

I have, created few year ago a similar procedure to start & stop extra Slackware services (https://github.com/LotarProject/slack-services).

Recently i'm working to autodetect all extra services without write any config.
 
  


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
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
C coding: Hacking ssh: dynamic local port forwarding implementation? Web31337 Programming 2 02-03-2010 06:05 AM
'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 05:36 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration