| 1 |
drobbins |
2 |
#!/bin/bash
|
| 2 |
azarah |
85 |
# Copyright 1999-2002 Gentoo Technologies, Inc.
|
| 3 |
|
|
# Distributed under the terms of the GNU General Public License, v2 or later
|
| 4 |
|
|
# $Header$
|
| 5 |
drobbins |
2 |
|
| 6 |
azarah |
85 |
|
| 7 |
drobbins |
65 |
#needed for $SYSLOGGER (/etc/rc.conf overrides /etc/conf.d/basic).
|
| 8 |
|
|
[ -e /etc/conf.d/basic ] && source /etc/conf.d/basic
|
| 9 |
|
|
[ -e /etc/rc.conf ] && source /etc/rc.conf
|
| 10 |
|
|
|
| 11 |
|
|
#set default if it is not set
|
| 12 |
|
|
[ "$SYSLOGGER" = "" ] && SYSLOGGER="sysklogd metalog syslog-ng"
|
| 13 |
|
|
|
| 14 |
drobbins |
2 |
source /etc/init.d/functions.sh
|
| 15 |
|
|
svcdir=/dev/shm/.init.d
|
| 16 |
|
|
|
| 17 |
|
|
if [ ! -d $svcdir ]
|
| 18 |
|
|
then
|
| 19 |
|
|
install -d -m0755 $svcdir
|
| 20 |
|
|
fi
|
| 21 |
drobbins |
51 |
for x in softscripts snapshot started need use
|
| 22 |
drobbins |
2 |
do
|
| 23 |
|
|
if [ ! -d ${svcdir}/${x} ]
|
| 24 |
|
|
then
|
| 25 |
|
|
install -d -m0755 ${svcdir}/${x}
|
| 26 |
|
|
fi
|
| 27 |
|
|
done
|
| 28 |
|
|
|
| 29 |
drobbins |
51 |
#call: depend_dbadd dep_type service deps....
|
| 30 |
|
|
depend_dbadd() {
|
| 31 |
|
|
local mytype
|
| 32 |
drobbins |
2 |
local myservice
|
| 33 |
|
|
local x
|
| 34 |
drobbins |
51 |
mytype=$1
|
| 35 |
|
|
myservice=$2
|
| 36 |
|
|
shift 2
|
| 37 |
drobbins |
2 |
for x in $*
|
| 38 |
|
|
do
|
| 39 |
drobbins |
51 |
if [ ! -e /etc/init.d/${x} ]
|
| 40 |
|
|
then
|
| 41 |
|
|
#nice thing about use's, is that they do not have to exist
|
| 42 |
|
|
if [ "$x" != "net" ] && [ "$mytype" != "use" ]
|
| 43 |
drobbins |
2 |
then
|
| 44 |
drobbins |
51 |
#bogus dependency
|
| 45 |
|
|
einfo "need: can't find service \"${x}\" needed by \"${myservice}\"; continuing..."
|
| 46 |
|
|
continue
|
| 47 |
drobbins |
2 |
fi
|
| 48 |
drobbins |
51 |
fi
|
| 49 |
drobbins |
65 |
|
| 50 |
|
|
#ugly bug ... if a service depends on itself, it creates
|
| 51 |
|
|
#a 'mini fork bomb' effect, and breaks things...
|
| 52 |
|
|
if [ "$x" = "$myservice" ]
|
| 53 |
|
|
then
|
| 54 |
|
|
einfo "depend: service \"${x}\" can't depend on itself; continuing..."
|
| 55 |
|
|
continue
|
| 56 |
|
|
fi
|
| 57 |
drobbins |
51 |
if [ ! -d ${svcdir}/${mytype}/${x} ]
|
| 58 |
|
|
then
|
| 59 |
|
|
install -d -m0755 ${svcdir}/${mytype}/${x}
|
| 60 |
|
|
fi
|
| 61 |
|
|
if [ ! -L ${svcdir}/${mytype}/${x}/${myservice} ]
|
| 62 |
|
|
then
|
| 63 |
|
|
ln -sf /etc/init.d/${myservice} ${svcdir}/${mytype}/${x}/${myservice}
|
| 64 |
|
|
fi
|
| 65 |
drobbins |
2 |
done
|
| 66 |
|
|
}
|
| 67 |
|
|
|
| 68 |
|
|
need() {
|
| 69 |
|
|
NEED="$*"
|
| 70 |
|
|
}
|
| 71 |
|
|
|
| 72 |
drobbins |
51 |
use() {
|
| 73 |
|
|
USE="$*"
|
| 74 |
|
|
}
|
| 75 |
|
|
|
| 76 |
drobbins |
2 |
ebegin "Caching service dependencies"
|
| 77 |
|
|
rm -rf ${svcdir}/need/*
|
| 78 |
drobbins |
51 |
rm -rf ${svcdir}/use/*
|
| 79 |
drobbins |
65 |
for x in /etc/init.d/*
|
| 80 |
drobbins |
2 |
do
|
| 81 |
drobbins |
67 |
[ "${x##*.}" = "sh" ] && continue
|
| 82 |
|
|
[ "${x##*.}" = "c" ] && continue
|
| 83 |
drobbins |
51 |
#set to "" else we get problems
|
| 84 |
|
|
NEED=""
|
| 85 |
|
|
USE=""
|
| 86 |
jerrya |
64 |
|
| 87 |
drobbins |
2 |
myservice=${x##*/}
|
| 88 |
|
|
depend() {
|
| 89 |
|
|
NEED=""
|
| 90 |
drobbins |
51 |
USE=""
|
| 91 |
jerrya |
64 |
return
|
| 92 |
drobbins |
2 |
}
|
| 93 |
|
|
source ${x}
|
| 94 |
|
|
depend
|
| 95 |
drobbins |
51 |
if [ "$NEED" = "" ] && [ "$USE" = "" ]
|
| 96 |
drobbins |
2 |
then
|
| 97 |
|
|
continue
|
| 98 |
|
|
fi
|
| 99 |
drobbins |
51 |
if [ "$NEED" != "" ]
|
| 100 |
|
|
then
|
| 101 |
|
|
depend_dbadd need $myservice $NEED
|
| 102 |
|
|
fi
|
| 103 |
|
|
if [ "$USE" != "" ]
|
| 104 |
|
|
then
|
| 105 |
drobbins |
65 |
USE=${USE/logger/${SYSLOGGER}}
|
| 106 |
drobbins |
51 |
depend_dbadd use $myservice $USE
|
| 107 |
|
|
fi
|
| 108 |
drobbins |
2 |
done
|
| 109 |
|
|
eend
|