quaggaadm revision 417
417N/A#!/bin/ksh
417N/A#
417N/A# CDDL HEADER START
417N/A#
417N/A# The contents of this file are subject to the terms of the
417N/A# Common Development and Distribution License (the "License").
417N/A# You may not use this file except in compliance with the License.
417N/A#
417N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
417N/A# or http://www.opensolaris.org/os/licensing.
417N/A# See the License for the specific language governing permissions
417N/A# and limitations under the License.
417N/A#
417N/A# When distributing Covered Code, include this CDDL HEADER in each
417N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
417N/A# If applicable, add the following below this CDDL HEADER, with the
417N/A# fields enclosed by brackets "[]" replaced with your own identifying
417N/A# information: Portions Copyright [yyyy] [name of copyright owner]
417N/A#
417N/A# CDDL HEADER END
417N/A#
417N/A# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
417N/A#
417N/A# ident "@(#)quaggaadm 1.3 08/10/02 SMI"
417N/Adaemons="zebra ripd ripngd ospfd ospf6d bgpd isisd"
417N/A
417N/Afunction quaggaadm_usage
417N/A{
417N/A print - "Usage:\n" >&2
417N/A for H in ${daemons} ; do
417N/A print - "\t${1} [-e] ${H}\t\tConnect to ${H} daemon" >&2
417N/A done
417N/A print - "\nThe -e flag enables the named daemon to accept ${1} connections and" >&2
417N/A print - "must be used on the first use of ${1} to connect to a particular daemon." >&2
417N/A}
417N/A
417N/Aif [ ${#} -gt 2 ]
417N/Athen
417N/A quaggaadm_usage ${0}
417N/A exit 1
417N/Afi
417N/A
417N/Afunction vty_enable
417N/A{
417N/A restart=0;
417N/A
417N/A /usr/bin/svcprop -p routing/vty_address ${1} \
417N/A | grep -- '[0-9a-zA-Z]' > /dev/null || \
417N/A /usr/sbin/routeadm -m ${1} vty_address="127.0.0.1" && \
417N/A restart=1
417N/A /usr/bin/svcprop -p routing/vty_port ${1}| grep 0 > /dev/null && \
417N/A /usr/sbin/routeadm -m ${1} vty_port=${2}
417N/A if [ $restart = "1" ]; then
417N/A /usr/sbin/svcadm restart ${1}
417N/A fi
417N/A}
417N/A
417N/AENABLE="no"
417N/A
417N/Aif [ ${#} -eq 2 ] ; then
417N/A DAEMON=${2}
417N/A if [ ${1} != "-e" ]; then
417N/A quaggaadm_usage ${0}
417N/A exit 1;
417N/A fi
417N/A ENABLE="yes"
417N/Aelif [ ${#} -eq 1 ] ; then
417N/A DAEMON=${1}
417N/Afi
417N/A
417N/Acase ${DAEMON} in
417N/A zebra) # telnet to zebra daemon
417N/A PORT=2601
417N/A SVC="zebra:quagga"
417N/A ;;
417N/A rip|ripd) # telnet to ripd daemon
417N/A PORT=2602
417N/A SVC="rip:quagga"
417N/A ;;
417N/A ripng|ripngd) # telnet to ripngd daemon
417N/A PORT=2603
417N/A SVC="ripng:quagga"
417N/A ;;
417N/A ospfd|ospf) # telnet to ospfd daemon
417N/A PORT=2604
417N/A SVC="ospf:quagga"
417N/A ;;
417N/A bgp|bgpd) # telnet to bgpd daemon
417N/A PORT=2605
417N/A SVC="bgp:quagga"
417N/A ;;
417N/A ospf6|ospf6d) # telnet to ospf6d daemon
417N/A PORT=2606
417N/A SVC="ospf6:quagga"
417N/A ;;
417N/A isis|isisd) # telnet to isisd daemon
417N/A PORT=2608
417N/A SVC="isis:quagga"
417N/A ;;
417N/A *)
417N/A # unknown daemon
417N/A print - "Unrecognized command: ${1}..." >&2
417N/A quaggaadm_usage ${0}
417N/A exit 1
417N/A ;;
417N/Aesac
417N/A
417N/Aif [ ${ENABLE} = "yes" ] ; then
417N/A vty_enable ${SVC} ${PORT} || exit 1
417N/Afi
417N/A
417N/Aexec telnet 127.0.0.1 ${PORT}
417N/A
417N/Aexit 0