components/quagga/Solaris/quaggaadm
branchs11u3-sru
changeset 7932 c25424a2c03c
parent 417 7c10b5cba79b
equal deleted inserted replaced
7931:29de53a8751a 7932:c25424a2c03c
    17 # fields enclosed by brackets "[]" replaced with your own identifying
    17 # fields enclosed by brackets "[]" replaced with your own identifying
    18 # information: Portions Copyright [yyyy] [name of copyright owner]
    18 # information: Portions Copyright [yyyy] [name of copyright owner]
    19 #
    19 #
    20 # CDDL HEADER END
    20 # CDDL HEADER END
    21 #
    21 #
    22 # Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
    22 # Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
    23 #
    23 #
    24 # ident	"@(#)quaggaadm	1.3	08/10/02 SMI"
    24 # ident	"@(#)quaggaadm	1.3	08/10/02 SMI"
    25 daemons="zebra ripd ripngd ospfd ospf6d bgpd isisd"
    25 daemons="zebra ripd ripngd ospfd ospf6d bgpd isisd"
    26 
    26 
    27 function quaggaadm_usage
    27 function quaggaadm_usage
    28 {
    28 {
    29 	print - "Usage:\n" >&2
    29 	print - "Usage:\n" >&2
    30 	for H in ${daemons} ; do
    30 	for H in ${daemons} ; do
    31 		print - "\t${1} [-e] ${H}\t\tConnect to ${H} daemon" >&2
    31 		print - "\t${1} [-e|-d] ${H}\t\tConnect to ${H} daemon" >&2
    32 	done
    32 	done
    33 	print - "\nThe -e flag enables the named daemon to accept ${1} connections and" >&2
    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
    34 	print - "must be used on the first use of ${1} to connect to a particular daemon." >&2
       
    35 	print - "\nThe -d flag disables access to the named daemon." >&2
    35 }
    36 }
    36 
    37 
    37 if [ ${#} -gt 2 ]
    38 if [ ${#} -gt 2 ]
    38 then
    39 then
    39 	quaggaadm_usage ${0}
    40 	quaggaadm_usage ${0}
    41 fi
    42 fi
    42 
    43 
    43 function vty_enable
    44 function vty_enable
    44 {
    45 {
    45 	restart=0;
    46 	restart=0;
    46 	
    47 
    47 	/usr/bin/svcprop -p routing/vty_address ${1} \
    48 	/usr/bin/svcprop -p routing/vty_address ${1} \
    48 		| grep -- '[0-9a-zA-Z]' > /dev/null || \
    49 		| grep -- '[0-9a-zA-Z]' > /dev/null || \
    49 		/usr/sbin/routeadm -m ${1} vty_address="127.0.0.1" && \
    50 		/usr/sbin/routeadm -m ${1} vty_address="127.0.0.1" && \
    50 			restart=1
    51 			restart=1
    51 	/usr/bin/svcprop -p routing/vty_port ${1}| grep 0 > /dev/null && \
    52 	/usr/bin/svcprop -p routing/vty_port ${1}| grep 0 > /dev/null && \
    52 		/usr/sbin/routeadm -m ${1} vty_port=${2}
    53 		/usr/sbin/routeadm -m ${1} vty_port=${2}
    53 	if [ $restart = "1" ]; then
    54 	if [ $restart = "1" ]; then
       
    55 		/usr/sbin/svcadm restart -T 5 -s ${1}
       
    56 	fi
       
    57 }
       
    58 
       
    59 function vty_disable
       
    60 {
       
    61 	restart=0;
       
    62 
       
    63 	/usr/bin/svcprop -p routing/vty_address ${1} \
       
    64 		| grep -- '[0-9a-zA-Z]' > /dev/null && \
       
    65 		/usr/sbin/routeadm -m ${1} vty_address="" && \
       
    66 			restart=1
       
    67 	/usr/bin/svcprop -p routing/vty_port ${1}| grep '^0$' > /dev/null || \
       
    68 		/usr/sbin/routeadm -m ${1} vty_port=0
       
    69 	if [ $restart = "1" ]; then
    54 		/usr/sbin/svcadm restart ${1}
    70 		/usr/sbin/svcadm restart ${1}
    55 	fi			
    71 	fi
    56 }			
    72 	print Service access is now disabled.
       
    73 }
    57 
    74 
    58 ENABLE="no"
    75 ENABLE="no"
       
    76 DISABLE="no"
    59 
    77 
       
    78 if [ ${#} -gt 2 ] ; then
       
    79 	quaggaadm_usage ${0}
       
    80 	exit 1;
       
    81 fi
    60 if [ ${#} -eq 2 ] ; then
    82 if [ ${#} -eq 2 ] ; then
    61 	DAEMON=${2}
    83 	DAEMON=${2}
    62 	if [ ${1} != "-e" ]; then
    84 	case ${1} in
    63 		quaggaadm_usage ${0}
    85 		-e)	#enable
    64 		exit 1;
    86 			ENABLE="yes"
    65 	fi
    87 		;;
    66 	ENABLE="yes"
    88 		-d)	#disable
       
    89 			DISABLE="yes"
       
    90 		;;
       
    91 		*)
       
    92 			quaggaadm_usage ${0}
       
    93 			exit 1
       
    94 		;;
       
    95 	esac
    67 elif [ ${#} -eq 1 ] ; then
    96 elif [ ${#} -eq 1 ] ; then
    68 	DAEMON=${1}
    97 	DAEMON=${1}
    69 fi
    98 fi
    70 
    99 
    71 case ${DAEMON} in
   100 case ${DAEMON} in
   103 		quaggaadm_usage ${0}
   132 		quaggaadm_usage ${0}
   104 		exit 1
   133 		exit 1
   105 	;;
   134 	;;
   106 esac
   135 esac
   107 
   136 
       
   137 if [ ${DISABLE} = "yes" ] ; then
       
   138 	vty_disable ${SVC} || exit 1
       
   139 	exit 0
       
   140 fi
       
   141 
   108 if [ ${ENABLE} = "yes" ] ; then
   142 if [ ${ENABLE} = "yes" ] ; then
   109 	vty_enable ${SVC} ${PORT} || exit 1
   143 	vty_enable ${SVC} ${PORT} || exit 1
   110 fi
   144 fi
       
   145 # Need to give the daemon time to initialize.
       
   146 sleep 3
   111 
   147 
   112 exec telnet 127.0.0.1 ${PORT}
   148 exec telnet 127.0.0.1 ${PORT}
   113 
   149 
   114 exit 0
   150 exit 0