|
1 #!/bin/ksh |
|
2 # |
|
3 # CDDL HEADER START |
|
4 # |
|
5 # The contents of this file are subject to the terms of the |
|
6 # Common Development and Distribution License (the "License"). |
|
7 # You may not use this file except in compliance with the License. |
|
8 # |
|
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
10 # or http://www.opensolaris.org/os/licensing. |
|
11 # See the License for the specific language governing permissions |
|
12 # and limitations under the License. |
|
13 # |
|
14 # When distributing Covered Code, include this CDDL HEADER in each |
|
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
16 # If applicable, add the following below this CDDL HEADER, with the |
|
17 # fields enclosed by brackets "[]" replaced with your own identifying |
|
18 # information: Portions Copyright [yyyy] [name of copyright owner] |
|
19 # |
|
20 # CDDL HEADER END |
|
21 # |
|
22 # Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. |
|
23 # |
|
24 # ident "@(#)quaggaadm 1.3 08/10/02 SMI" |
|
25 daemons="zebra ripd ripngd ospfd ospf6d bgpd isisd" |
|
26 |
|
27 function quaggaadm_usage |
|
28 { |
|
29 print - "Usage:\n" >&2 |
|
30 for H in ${daemons} ; do |
|
31 print - "\t${1} [-e] ${H}\t\tConnect to ${H} daemon" >&2 |
|
32 done |
|
33 print - "\nThe -e flag enables the named daemon to accept ${1} connections and" >&2 |
|
34 print - "must be used on the first use of ${1} to connect to a particular daemon." >&2 |
|
35 } |
|
36 |
|
37 if [ ${#} -gt 2 ] |
|
38 then |
|
39 quaggaadm_usage ${0} |
|
40 exit 1 |
|
41 fi |
|
42 |
|
43 function vty_enable |
|
44 { |
|
45 restart=0; |
|
46 |
|
47 /usr/bin/svcprop -p routing/vty_address ${1} \ |
|
48 | grep -- '[0-9a-zA-Z]' > /dev/null || \ |
|
49 /usr/sbin/routeadm -m ${1} vty_address="127.0.0.1" && \ |
|
50 restart=1 |
|
51 /usr/bin/svcprop -p routing/vty_port ${1}| grep 0 > /dev/null && \ |
|
52 /usr/sbin/routeadm -m ${1} vty_port=${2} |
|
53 if [ $restart = "1" ]; then |
|
54 /usr/sbin/svcadm restart ${1} |
|
55 fi |
|
56 } |
|
57 |
|
58 ENABLE="no" |
|
59 |
|
60 if [ ${#} -eq 2 ] ; then |
|
61 DAEMON=${2} |
|
62 if [ ${1} != "-e" ]; then |
|
63 quaggaadm_usage ${0} |
|
64 exit 1; |
|
65 fi |
|
66 ENABLE="yes" |
|
67 elif [ ${#} -eq 1 ] ; then |
|
68 DAEMON=${1} |
|
69 fi |
|
70 |
|
71 case ${DAEMON} in |
|
72 zebra) # telnet to zebra daemon |
|
73 PORT=2601 |
|
74 SVC="zebra:quagga" |
|
75 ;; |
|
76 rip|ripd) # telnet to ripd daemon |
|
77 PORT=2602 |
|
78 SVC="rip:quagga" |
|
79 ;; |
|
80 ripng|ripngd) # telnet to ripngd daemon |
|
81 PORT=2603 |
|
82 SVC="ripng:quagga" |
|
83 ;; |
|
84 ospfd|ospf) # telnet to ospfd daemon |
|
85 PORT=2604 |
|
86 SVC="ospf:quagga" |
|
87 ;; |
|
88 bgp|bgpd) # telnet to bgpd daemon |
|
89 PORT=2605 |
|
90 SVC="bgp:quagga" |
|
91 ;; |
|
92 ospf6|ospf6d) # telnet to ospf6d daemon |
|
93 PORT=2606 |
|
94 SVC="ospf6:quagga" |
|
95 ;; |
|
96 isis|isisd) # telnet to isisd daemon |
|
97 PORT=2608 |
|
98 SVC="isis:quagga" |
|
99 ;; |
|
100 *) |
|
101 # unknown daemon |
|
102 print - "Unrecognized command: ${1}..." >&2 |
|
103 quaggaadm_usage ${0} |
|
104 exit 1 |
|
105 ;; |
|
106 esac |
|
107 |
|
108 if [ ${ENABLE} = "yes" ] ; then |
|
109 vty_enable ${SVC} ${PORT} || exit 1 |
|
110 fi |
|
111 |
|
112 exec telnet 127.0.0.1 ${PORT} |
|
113 |
|
114 exit 0 |