Re: start daemons according to current runlevel upon upgrade
On Wed, 06 Oct 1999, Ingo Saitz wrote:
> > > if test -e /etc/rc`runlevel | cut -d\ -f2`.d/S??$DAEMON; then
> > > /etc/init.d/$DAEMON start
> > > fi
> > This doesn't work for people using file-rc (which uses files to
> > describe runlevels instead of directories and symlinks).
> I have created two scripts named start-rc.d. One for runlevel links
> and one for file-rc. I think, they should be included in the
> corresponding packages which contain the update-rc.d skript (dpkg
> and file-rc).
For file-rc this isn't a problem. I will include it in the next
release as /usr/sbin/start-rc.d diverting the file with the same name
from dpkg.
> I have attached these two files to this email. Please have a look if
> you like them and feel free to include them.
As far as I see, there may be some ugly side effects in your
start-rc.d-file-rc, so I rewrote it reusing some code from the other
file-rc scripts. As far as I see, it should now behave in the same
way as your start-rc.d-dpkg. I'll attach my version to this mail.
> I think that every package that would start a daemon in its postinst
> should use these files to start it.
I also think so.
Please propose this as a policy change!
Ciao
Roland
--
* roland@spinnaker.de * http://www.spinnaker.de/ *
PGP: 1024/DD08DD6D 2D E7 CC DE D5 8D 78 BE 3C A0 A4 F1 4B 09 CE AF
#! /bin/sh
#
# $Id: start-rc.d,v 1.2 1999/10/06 18:29:37 roland Exp $
#
# Usage: start-rc.d <daemon>
#
# Starts <daemon> if this daemon is active in the actual runlevel
# according to runlevel.conf.
#
# This script was written by Roland Rosenfeld <roland@spinnaker.de>,
# it is based on an idea of Ingo Saitz <ingo@stud.uni-hannover.de> and
# some code from the other file-rc scripts (update-rc.d, rc, rcS).
#
##########################################################################
#
# Copyright (C) 1999 Roland Rosenfeld <roland@spinnaker.de>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
##########################################################################
basename=$1
# Get the actual runlevel using runlevel(8). This command outputs the
# previous runlevel and the actual runlevel. We only use the latter.
runlevel=`runlevel`
runlevel=${runlevel##* }
CFGFILE=/etc/runlevel.conf
element() {
local element list IFS
element="$1"
[ "$2" = "in" ] && shift
list="$2"
[ "$list" = "-" ] && return 1
[ "$list" = "*" ] && return 0
IFS=","
set -- $list
case $element in
"$1" | "$2" | "$3" | "$4" | "$5" | "$6" | "$7" | "$8" | "$9")
return 0
esac
return 1
}
while read LINE
do
case $LINE in
\#*|"") continue
esac
set -- $LINE
SORT_NO="$1"; STOP="$2"; START="$3"; CMD="$4"
[ "$CMD" = "/etc/init.d/$basename" ] || continue
if element "$runlevel" in "$START"
then
/etc/init.d/$basename start
exit 0
fi
done < $CFGFILE
Reply to: