From: Charlie Brady <charlieb-smarden-supervision@budge.apana.org.au>
Cc: supervision@list.skarnet.org
Subject: Re: runit and lsb init script actions
Date: Sun, 10 Apr 2005 13:00:18 -0400 (EDT) [thread overview]
Message-ID: <Pine.LNX.4.61.0504101257590.31619@e-smith.charlieb.ott.istop.com> (raw)
In-Reply-To: <20050410151610.26722.qmail@c94466ef4374af.315fe32.mid.smarden.org>
On Sun, 10 Apr 2005, Gerrit Pape wrote:
> Hi, one thing that has been requested for runit multiple times is lsb
> compliance concerning 'init script' actions, see
>
> http://refspecs.freestandards.org/LSB_2.1.0/LSB-Core-generic/LSB-Core-generic.html#INISCRPTACT
>
> It seems to be quite possible to implement an lsb compliant interface
> through a separate program that runs runsvctrl up, down, term, hup, ...,
> depending on the command line arguments. For service daemons that don't
> do the right thing on up, down, term, hup, ..., it's possible to
> override the actions through the customized control scripts in
> <service>/control/. This separate program may be symlinked to
> /etc/init.d/<service>, or used as a wrapper, and maybe fall back to an
> original /etc/init.d/<service> script in case the service doesn't run
> under runit's supervision.
>
> What do you think?
Here's a runit specific version I use under a RedHat based system:
#!/bin/sh
###########################################################################
#
# System V style init script.
# Relies on runit utilities to do the real work.
# It is assumed that init scripts will be linked to this script.
#
###########################################################################
# Determine the service name and its service directory from $0
SERVICE=$(/bin/basename $0 | sed -e 's/^[SK][0-9][0-9]*//')
SERVICE_DIR=/service/$SERVICE
###########################################################################
# Source in the RedHat initscripts functions
. /etc/rc.d/init.d/functions
# The maximum amount of time to wait for a process to shut down, in
seconds.
WAITMAX=60
start()
{
/bin/echo -n "Starting $SERVICE:"
dirs=$1
if [ -d $1/log ]; then
dirs="$1/log $1"
fi
/usr/bin/runsvctrl u $dirs
if [ $? -ne 0 ]; then
failure "Starting $SERVICE"
else
success "Starting $SERVICE"
fi
/bin/echo
}
status()
{
/usr/bin/runsvstat $1
}
stop()
{
/bin/echo -n "Stopping $SERVICE:"
/usr/bin/svwaitdown -t $WAITMAX $1
if [ $? -ne 0 ]; then
failure "Stopping $SERVICE"
else
success "Stopping $SERVICE"
fi
/bin/echo
}
# This function not only shuts the service down, but removes the /service
# symlink and shuts down the logger. This should only be used during an
# uninstall of the service in question.
svdisable()
{
/bin/echo -n "Disabling $SERVICE:"
stop $1
cd $1 && rm -f $1
dirs=.
if [ -e log ]; then
dirs="$dirs ./log"
fi
/usr/bin/runsvctrl d $dirs
/usr/bin/runsvctrl x $dirs
if [ $? -ne 0 ]; then
failure "Disabling $SERVICE"
else
success "Disabling $SERVICE"
fi
/bin/echo
}
case $1 in
restart)
/usr/bin/runsvctrl t $SERVICE_DIR
/usr/bin/runsvctrl u $SERVICE_DIR
;;
sigalrm)
/usr/bin/runsvctrl a $SERVICE_DIR
;;
sigcont)
/usr/bin/runsvctrl c $SERVICE_DIR
;;
sighup)
/usr/bin/runsvctrl h $SERVICE_DIR
;;
sigusr1)
/usr/bin/runsvctrl 1 $SERVICE_DIR
;;
sigusr2)
/usr/bin/runsvctrl 2 $SERVICE_DIR
;;
sigint)
/usr/bin/runsvctrl i $SERVICE_DIR
;;
sigkill)
/usr/bin/runsvctrl k $SERVICE_DIR
;;
sigstop)
/usr/bin/runsvctrl p $SERVICE_DIR
;;
sigterm)
/usr/bin/runsvctrl t $SERVICE_DIR
;;
status)
/usr/bin/runsvstat $SERVICE_DIR
;;
start)
start $SERVICE_DIR
;;
stop)
stop $SERVICE_DIR
;;
svdisable)
svdisable $SERVICE_DIR
;;
*)
echo "usage: $0 {start|stop|restart|status|sigalrm|sigcont|sighup|sigint|sigkill|sigstop|sigterm|sigusr1|sigusr2|svdisable}"
;;
esac
next prev parent reply other threads:[~2005-04-10 17:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-10 15:15 Gerrit Pape
2005-04-10 17:00 ` Charlie Brady [this message]
2005-04-18 19:17 ` Gerrit Pape
2005-04-19 22:05 ` Csillag Tamás
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.61.0504101257590.31619@e-smith.charlieb.ott.istop.com \
--to=charlieb-smarden-supervision@budge.apana.org.au \
--cc=supervision@list.skarnet.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).