Merge pull request #103 from gsomlo/quagga_startup

daemon: streamline Quagga startup
This commit is contained in:
Jeff Ahrenholz 2017-01-26 09:18:05 -08:00 committed by GitHub
commit b4c8be9e23

View file

@ -170,21 +170,6 @@ confcheck()
fi
}
waitforvtyfiles()
{
for f in "$@"; do
count=1
until [ -e $QUAGGA_STATE_DIR/$f ]; do
if [ $count -eq 10 ]; then
echo "ERROR: vty file not found: $QUAGGA_STATE_DIR/$f" >&2
return 1
fi
sleep 0.1
count=$(($count + 1))
done
done
}
bootdaemon()
{
QUAGGA_SBIN_DIR=$(searchforprog $1 $QUAGGA_SBIN_SEARCH)
@ -196,53 +181,47 @@ bootdaemon()
flags=""
if [ "$1" != "zebra" ]; then
waitforvtyfiles zebra.vty
fi
if [ "$1" = "xpimd" ] && \\
grep -E -q '^[[:space:]]*router[[:space:]]+pim6[[:space:]]*$' $QUAGGA_CONF; then
flags="$flags -6"
fi
$QUAGGA_SBIN_DIR/$1 $flags -u $QUAGGA_USER -g $QUAGGA_GROUP -d
if [ "$?" != "0" ]; then
echo "ERROR: Quagga's '$1' daemon failed to start!:"
return 1
fi
}
bootvtysh()
bootquagga()
{
QUAGGA_BIN_DIR=$(searchforprog $1 $QUAGGA_BIN_SEARCH)
QUAGGA_BIN_DIR=$(searchforprog 'vtysh' $QUAGGA_BIN_SEARCH)
if [ "z$QUAGGA_BIN_DIR" = "z" ]; then
echo "ERROR: Quagga's '$1' daemon not found in search path:"
echo " $QUAGGA_SBIN_SEARCH"
echo "ERROR: Quagga's 'vtysh' program not found in search path:"
echo " $QUAGGA_BIN_SEARCH"
return 1
fi
vtyfiles="zebra.vty"
bootdaemon "zebra"
for r in rip ripng ospf6 ospf bgp babel; do
if grep -q "^router \<${r}\>" $QUAGGA_CONF; then
vtyfiles="$vtyfiles ${r}d.vty"
bootdaemon "${r}d"
fi
done
if grep -E -q '^[[:space:]]*router[[:space:]]+pim6?[[:space:]]*$' $QUAGGA_CONF; then
vtyfiles="$vtyfiles xpimd.vty"
bootdaemon "xpimd"
fi
# wait for Quagga daemon vty files to appear before invoking vtysh
waitforvtyfiles $vtyfiles
$QUAGGA_BIN_DIR/vtysh -b
}
confcheck
if [ "x$1" = "x" ]; then
echo "ERROR: missing the name of the Quagga daemon to boot"
if [ "$1" != "zebra" ]; then
echo "WARNING: '$1': all Quagga daemons are launched by the 'zebra' service!"
exit 1
elif [ "$1" = "vtysh" ]; then
bootvtysh $1
else
bootdaemon $1
fi
confcheck
bootquagga
""" % (cls._configs[0], quagga_sbin_search, quagga_bin_search, \
QUAGGA_STATE_DIR, QUAGGA_USER, QUAGGA_GROUP)
@ -311,7 +290,7 @@ class Ospfv2(QuaggaService):
unified Quagga.conf file.
'''
_name = "OSPFv2"
_startup = ("sh quaggaboot.sh ospfd",)
_startup = ()
_shutdown = ("killall ospfd", )
_validate = ("pidof ospfd", )
_ipv4_routing = True
@ -382,7 +361,7 @@ class Ospfv3(QuaggaService):
unified Quagga.conf file.
'''
_name = "OSPFv3"
_startup = ("sh quaggaboot.sh ospf6d",)
_startup = ()
_shutdown = ("killall ospf6d", )
_validate = ("pidof ospf6d", )
_ipv4_routing = True
@ -486,7 +465,7 @@ class Bgp(QuaggaService):
having the same AS number.
'''
_name = "BGP"
_startup = ("sh quaggaboot.sh bgpd",)
_startup = ()
_shutdown = ("killall bgpd", )
_validate = ("pidof bgpd", )
_custom_needed = True
@ -511,7 +490,7 @@ class Rip(QuaggaService):
''' The RIP service provides IPv4 routing for wired networks.
'''
_name = "RIP"
_startup = ("sh quaggaboot.sh ripd",)
_startup = ()
_shutdown = ("killall ripd", )
_validate = ("pidof ripd", )
_ipv4_routing = True
@ -534,7 +513,7 @@ class Ripng(QuaggaService):
''' The RIP NG service provides IPv6 routing for wired networks.
'''
_name = "RIPNG"
_startup = ("sh quaggaboot.sh ripngd",)
_startup = ()
_shutdown = ("killall ripngd", )
_validate = ("pidof ripngd", )
_ipv6_routing = True
@ -558,7 +537,7 @@ class Babel(QuaggaService):
protocol for IPv6 and IPv4 with fast convergence properties.
'''
_name = "Babel"
_startup = ("sh quaggaboot.sh babeld",)
_startup = ()
_shutdown = ("killall babeld", )
_validate = ("pidof babeld", )
_ipv6_routing = True
@ -588,7 +567,7 @@ class Xpimd(QuaggaService):
PIM multicast routing based on XORP.
'''
_name = 'Xpimd'
_startup = ('sh quaggaboot.sh xpimd',)
_startup = ()
_shutdown = ('killall xpimd', )
_validate = ('pidof xpimd', )
_ipv4_routing = True
@ -622,7 +601,7 @@ class Vtysh(CoreService):
_name = "vtysh"
_group = "Quagga"
_startindex = 45
_startup = ("sh quaggaboot.sh vtysh",)
_startup = ()
_shutdown = ()
@classmethod