virtual.chain (214306) | virtual.chain (222179) |
---|---|
1#!/bin/sh 2# | 1#!/bin/sh 2# |
3# Copyright (c) 2010, Yavuz Gokirmak | 3# Copyright (c) 2010, Yavuz Gokirmak |
4# 5# All rights reserved. 6# 7# This source code may be used, modified, copied, distributed, and 8# sold, in both source and binary form provided that the above 9# copyright and these terms are retained, verbatim, as the first 10# lines of this file. Under no circumstances is the author 11# responsible for the proper functioning of the software nor does 12# the author assume any responsibility for damages incurred with 13# its use. 14# | 4# 5# All rights reserved. 6# 7# This source code may be used, modified, copied, distributed, and 8# sold, in both source and binary form provided that the above 9# copyright and these terms are retained, verbatim, as the first 10# lines of this file. Under no circumstances is the author 11# responsible for the proper functioning of the software nor does 12# the author assume any responsibility for damages incurred with 13# its use. 14# |
15# $FreeBSD: head/share/examples/netgraph/virtual.chain 214306 2010-10-24 22:59:38Z julian $ | 15# $FreeBSD: head/share/examples/netgraph/virtual.chain 222179 2011-05-22 14:23:48Z uqs $ |
16# | 16# |
17# | |
18# This script creates and connects n router like nodes. Complex wide 19# area topologies can be created with the help of script. 20# 21# Virtual nodes are generated via jails and network connections are 22# established using ng_eiface(4) node types. 23# 24# To use this script: 25# 26# 0. Make your own copy of this example script. 27# | 17# This script creates and connects n router like nodes. Complex wide 18# area topologies can be created with the help of script. 19# 20# Virtual nodes are generated via jails and network connections are 21# established using ng_eiface(4) node types. 22# 23# To use this script: 24# 25# 0. Make your own copy of this example script. 26# |
28# 1. Edit the definition of ${TARGET_TOPOLOGY} to define your virtual | 27# 1. Edit the definition of ${TARGET_TOPOLOGY} to define your virtual |
29# nodes. Virtual topology definition includes node names and their | 28# nodes. Virtual topology definition includes node names and their |
30# IP address. Target top. sytax: ( name|ip<->name|ip ... ) | 29# IP address. Target top. syntax: ( name|ip<->name|ip ... ) |
31# Example 1: ( n1|10.0.2.1/30<->n2|10.0.2.2/30 ...) 32# Example 2: ( n1|2001:b90::14a/125<->n1|2001:b90::14b/125 ...) 33# 34# 2. Run this script with "start" as the command line argument. 35# 36# 3. Add necessary static route commands for each virtual node. For 37# example assume you have three virtual nodes connected each other | 30# Example 1: ( n1|10.0.2.1/30<->n2|10.0.2.2/30 ...) 31# Example 2: ( n1|2001:b90::14a/125<->n1|2001:b90::14b/125 ...) 32# 33# 2. Run this script with "start" as the command line argument. 34# 35# 3. Add necessary static route commands for each virtual node. For 36# example assume you have three virtual nodes connected each other |
38# llike a chain ( n1 is connected to n2, n2 is connecte to n3 ). 39# In order to estabklish connectivity among these virtual nodes, | 37# like a chain (n1 is connected to n2, n2 is connected to n3). 38# In order to establish connectivity among these virtual nodes, |
40# you have to add default routes to node n1 and node n3. Example 41# static route command is: | 39# you have to add default routes to node n1 and node n3. Example 40# static route command is: |
42# STATIC_ROUTE0="jexec n1 route add -inet default 10.0.2.2" 43# STATIC_ROUTE1="jexec n3 route add -inet default 10.0.2.5" 44# After defining default routes with above format you have to set | 41# STATIC_ROUTE0="jexec n1 route add -inet default 10.0.2.2" 42# STATIC_ROUTE1="jexec n3 route add -inet default 10.0.2.5" 43# After defining default routes with above format you have to set |
45# the total number of static route commands as: 46# STATIC_ROUTE_CNT=2 47# 48# 4. Stop bridging by running this script with "stop" as the 49# command line argument. | 44# the total number of static route commands as: 45# STATIC_ROUTE_CNT=2 46# 47# 4. Stop bridging by running this script with "stop" as the 48# command line argument. |
50# 51# 5. This cript uses a template file in order to carry information 52# between start and stop calls. | 49# 50# 5. This script uses a template file in order to carry information 51# between start and stop calls. |
53# In the start call, the netgraph interfaces and jails are created. 54# At the stop phase, all created objects should be removed. 55# DO NOT delete the temporary file between the start and stop phases. 56# 57# Target Topology: 58# 59# +---------------+ +---------------------------------------------+ 60# | n1 (vimage) | | n2 (vimage) | --- 18 unchanged lines hidden (view full) --- 79# | +-----------+ | | +-----------+ | 80# | | | | 81# | n3 (vimage) | | n4 (vimage) | 82# +---------------+ +---------------+ 83# 84# 85# 86 | 52# In the start call, the netgraph interfaces and jails are created. 53# At the stop phase, all created objects should be removed. 54# DO NOT delete the temporary file between the start and stop phases. 55# 56# Target Topology: 57# 58# +---------------+ +---------------------------------------------+ 59# | n1 (vimage) | | n2 (vimage) | --- 18 unchanged lines hidden (view full) --- 78# | +-----------+ | | +-----------+ | 79# | | | | 80# | n3 (vimage) | | n4 (vimage) | 81# +---------------+ +---------------+ 82# 83# 84# 85 |
87# List the names of virtual nodes and their IP addresses. Use ':' 88# character to seperate node name from node IP address and netmask. | 86# List the names of virtual nodes and their IP addresses. Use ':' 87# character to separate node name from node IP address and netmask. |
89 90TARGET_TOPOLOGY="n1|10.0.2.1/30<->n2|10.0.2.2/30 n2|10.0.2.5/30<->n3|10.0.2.6/30 n2|10.0.2.9/30<->n4|10.0.2.10/30" 91STATIC_ROUTE0="jexec n1 route add -inet default 10.0.2.2" 92STATIC_ROUTE1="jexec n3 route add -inet default 10.0.2.5" 93STATIC_ROUTE2="jexec n4 route add -inet default 10.0.2.9" 94STATIC_ROUTE_CNT=3 95 | 88 89TARGET_TOPOLOGY="n1|10.0.2.1/30<->n2|10.0.2.2/30 n2|10.0.2.5/30<->n3|10.0.2.6/30 n2|10.0.2.9/30<->n4|10.0.2.10/30" 90STATIC_ROUTE0="jexec n1 route add -inet default 10.0.2.2" 91STATIC_ROUTE1="jexec n3 route add -inet default 10.0.2.5" 92STATIC_ROUTE2="jexec n4 route add -inet default 10.0.2.9" 93STATIC_ROUTE_CNT=3 94 |
96# MAC manifacturer prefix. This can be modified according to needs. 97MAC_PREFIX="00:1d:92" | 95# MAC manufacturer prefix. This can be modified according to needs. 96MAC_PREFIX="00:1d:92" |
98 | 97 |
99# Temporary file is important for proper execution of script. | 98# Temporary file is important for proper execution of script. |
100TEMP_FILE="/var/tmp/.virtual.chain.tmp" 101 102# Set root directory for jails to be created. 103JAIL_PATH="/usr/jails/router" 104 105 106#################################################################### 107#### Nothing below this point should need to be modified. #### 108#################################################################### 109 110 111# Start/restart routine. 112virtual_chain_start() { 113 114 # Load netgraph KLD's as necessary. | 99TEMP_FILE="/var/tmp/.virtual.chain.tmp" 100 101# Set root directory for jails to be created. 102JAIL_PATH="/usr/jails/router" 103 104 105#################################################################### 106#### Nothing below this point should need to be modified. #### 107#################################################################### 108 109 110# Start/restart routine. 111virtual_chain_start() { 112 113 # Load netgraph KLD's as necessary. |
115 | 114 |
116 for KLD in ng_ether ng_bridge ng_eiface; do 117 if ! kldstat -v | grep -qw ${KLD}; then 118 echo -n "Loading ${KLD}.ko... " 119 kldload ${KLD} || exit 1 120 echo "done" 121 fi 122 done 123 124 # Reset all interfaces and jails. If temporary file can not be found | 115 for KLD in ng_ether ng_bridge ng_eiface; do 116 if ! kldstat -v | grep -qw ${KLD}; then 117 echo -n "Loading ${KLD}.ko... " 118 kldload ${KLD} || exit 1 119 echo "done" 120 fi 121 done 122 123 # Reset all interfaces and jails. If temporary file can not be found |
125 # script assumes that there is no previous configuration. 126 | 124 # script assumes that there is no previous configuration. 125 |
127 if [ ! -e ${TEMP_FILE} ]; then 128 echo "No previous configuration(${TEMP_FILE}) found to clean-up." 129 else 130 echo -n "Cleaning previous configuration..." 131 virtual_chain_stop 132 echo "done" | 126 if [ ! -e ${TEMP_FILE} ]; then 127 echo "No previous configuration(${TEMP_FILE}) found to clean-up." 128 else 129 echo -n "Cleaning previous configuration..." 130 virtual_chain_stop 131 echo "done" |
133 fi | 132 fi |
134 | 133 |
135 # Create temporary file for usage. This file includes generated | 134 # Create temporary file for usage. This file includes generated |
136 # interface names and jail names. All bridges, interfaces and jails | 135 # interface names and jail names. All bridges, interfaces and jails |
137 # are written to file while created. In clean-up process written 138 # objects are cleaned (i.e removed) from system. 139 | 136 # are written to file while created. In clean-up process written 137 # objects are cleaned (i.e. removed) from system. 138 |
140 if [ -e ${TEMP_FILE} ]; then 141 touch ${TEMP_FILE} 142 fi 143 144 145 # Attach other interfaces as well. 146 for CONNECTION in ${TARGET_TOPOLOGY}; do | 139 if [ -e ${TEMP_FILE} ]; then 140 touch ${TEMP_FILE} 141 fi 142 143 144 # Attach other interfaces as well. 145 for CONNECTION in ${TARGET_TOPOLOGY}; do |
147 | 146 |
148 # Virtual connections are defined in TARGET_TOPOLOGY variable. 149 # They have the form of 'nodeName|IPaddr'. Below two lines split | 147 # Virtual connections are defined in TARGET_TOPOLOGY variable. 148 # They have the form of 'nodeName|IPaddr'. Below two lines split |
150 | 149 |
151 PEER1=`echo ${CONNECTION} | awk -F"<->" '{print $1}'` 152 PEER1_NAME=`echo ${PEER1} | awk -F"|" '{print $1}'` 153 PEER1_IP=`echo ${PEER1} | awk -F"|" '{print $2}'` | 150 PEER1=`echo ${CONNECTION} | awk -F"<->" '{print $1}'` 151 PEER1_NAME=`echo ${PEER1} | awk -F"|" '{print $1}'` 152 PEER1_IP=`echo ${PEER1} | awk -F"|" '{print $2}'` |
154 | 153 |
155 PEER2=`echo ${CONNECTION} | awk -F"<->" '{print $2}'` 156 PEER2_NAME=`echo ${PEER2} | awk -F"|" '{print $1}'` 157 PEER2_IP=`echo ${PEER2} | awk -F"|" '{print $2}'` 158 159 # !!! if not created already.. | 154 PEER2=`echo ${CONNECTION} | awk -F"<->" '{print $2}'` 155 PEER2_NAME=`echo ${PEER2} | awk -F"|" '{print $1}'` 156 PEER2_IP=`echo ${PEER2} | awk -F"|" '{print $2}'` 157 158 # !!! if not created already.. |
160 # Create virtual node (jail) with given name and using | 159 # Create virtual node (jail) with given name and using |
161 # JAIL_PATH as root directory for jail. 162 163 virtual_chain_create_peer_if_necessary ${PEER1_NAME} 164 virtual_chain_create_peer_if_necessary ${PEER2_NAME} 165 166 # create an interface for peer with the given peer IP. Get interface | 160 # JAIL_PATH as root directory for jail. 161 162 virtual_chain_create_peer_if_necessary ${PEER1_NAME} 163 virtual_chain_create_peer_if_necessary ${PEER2_NAME} 164 165 # create an interface for peer with the given peer IP. Get interface |
167 # for future use; you will connect this interface to the other | 166 # for future use; you will connect this interface to the other |
168 # peers' (PEER2) interface. 169 virtual_chain_create_interface_with_ip ${PEER1_NAME} ${PEER1_IP} 170 PEER1_INTERFACE=${RET_INTERFACE} | 167 # peers' (PEER2) interface. 168 virtual_chain_create_interface_with_ip ${PEER1_NAME} ${PEER1_IP} 169 PEER1_INTERFACE=${RET_INTERFACE} |
171 | 170 |
172 # create an interface for peer with the given peer IP. Get interface | 171 # create an interface for peer with the given peer IP. Get interface |
173 # for future use; you will connect this interface to the other | 172 # for future use; you will connect this interface to the other |
174 # peers' (PEER2) interface. 175 virtual_chain_create_interface_with_ip ${PEER2_NAME} ${PEER2_IP} 176 PEER2_INTERFACE=${RET_INTERFACE} 177 178 # Connect virtual interface to other interface. Syntax is : 179 # ngctl connect INTERFACE1: INTERFACE2: ether ether. | 173 # peers' (PEER2) interface. 174 virtual_chain_create_interface_with_ip ${PEER2_NAME} ${PEER2_IP} 175 PEER2_INTERFACE=${RET_INTERFACE} 176 177 # Connect virtual interface to other interface. Syntax is : 178 # ngctl connect INTERFACE1: INTERFACE2: ether ether. |
180 | 179 |
181 echo -n "Connecting ${PEER1_INTERFACE}:ether to ${PEER2_INTERFACE}:ether..." 182 ngctl connect ${PEER1_INTERFACE}: ${PEER2_INTERFACE}: ether ether \ 183 || exit 1 184 echo "done" 185 186 done 187 188 # Executes static route add commands. 189 i=0 190 while [ $i != $STATIC_ROUTE_CNT ]; do 191 eval ROUTE=\${STATIC_ROUTE${i}} 192 ret=`${ROUTE}` 193 i=`expr $i + 1` 194 done 195 | 180 echo -n "Connecting ${PEER1_INTERFACE}:ether to ${PEER2_INTERFACE}:ether..." 181 ngctl connect ${PEER1_INTERFACE}: ${PEER2_INTERFACE}: ether ether \ 182 || exit 1 183 echo "done" 184 185 done 186 187 # Executes static route add commands. 188 i=0 189 while [ $i != $STATIC_ROUTE_CNT ]; do 190 eval ROUTE=\${STATIC_ROUTE${i}} 191 ret=`${ROUTE}` 192 i=`expr $i + 1` 193 done 194 |
196 echo "Virtual WAN established succesfully!" | 195 echo "Virtual WAN established successfully!" |
197} 198 199virtual_chain_create_interface_with_ip() { 200 201 NODE_NAME=$1 202 NODE_IP=$2 203 | 196} 197 198virtual_chain_create_interface_with_ip() { 199 200 NODE_NAME=$1 201 NODE_IP=$2 202 |
204 # Create a ng_eiface object for virtual node. ng_eiface | 203 # Create a ng_eiface object for virtual node. ng_eiface |
205 # object has a hook that can be connected to one of bridge | 204 # object has a hook that can be connected to one of bridge |
206 # links. After creating interface get its automatically 207 # generated name for further usage. | 205 # links. After creating interface get its automatically 206 # generated name for further usage. |
208 209 echo "Creating eiface interface for virtual node ${NODE_NAME}." 210 ngctl mkpeer eiface ether ether 211 EIFACE=`ngctl l | grep ngeth | tail -n 1| awk '{print $2}'` | 207 208 echo "Creating eiface interface for virtual node ${NODE_NAME}." 209 ngctl mkpeer eiface ether ether 210 EIFACE=`ngctl l | grep ngeth | tail -n 1| awk '{print $2}'` |
212 echo "Interface ${EIFACE} is created." 213 | 211 echo "Interface ${EIFACE} is created." 212 |
214 # Write name of the interface to temp file. Clean-up procedure 215 # will use this name to shutdown interface. | 213 # Write name of the interface to temp file. Clean-up procedure 214 # will use this name to shutdown interface. |
216 | 215 |
217 echo "interface ${EIFACE}" >> ${TEMP_FILE} 218 | 216 echo "interface ${EIFACE}" >> ${TEMP_FILE} 217 |
219 # Move virtual interface to virtual node. Note that Interface | 218 # Move virtual interface to virtual node. Note that Interface |
220 # name will not be changed at the end of this movement. Moved 221 # interface can be seen at the output of ifconfig command in 222 # jail: 'jexec jailname ifconfig' 223 | 219 # name will not be changed at the end of this movement. Moved 220 # interface can be seen at the output of ifconfig command in 221 # jail: 'jexec jailname ifconfig' 222 |
224 echo "Moving ${EIFACE} to ${NODE_NAME}" | 223 echo "Moving ${EIFACE} to ${NODE_NAME}" |
225 ifconfig ${EIFACE} vnet ${NODE_NAME} | 224 ifconfig ${EIFACE} vnet ${NODE_NAME} |
226 | 225 |
227 # Make lo0 interface localhost. 228 jexec ${NODE_NAME} ifconfig lo0 localhost 229 230 # Generate a random mac address for virtual interface. First 231 # three octets can be changed by user. Last three octets are | 226 # Make lo0 interface localhost. 227 jexec ${NODE_NAME} ifconfig lo0 localhost 228 229 # Generate a random mac address for virtual interface. First 230 # three octets can be changed by user. Last three octets are |
232 # generated randomly. | 231 # generated randomly. |
233 M4=`od -An -N2 -i /dev/random | sed -e 's/ //g' | \ 234 awk '{ print $1 % 256 }'` 235 M5=`od -An -N2 -i /dev/random | sed -e 's/ //g' | \ 236 awk '{ print $1 % 256 }'` 237 M6=`od -An -N2 -i /dev/random | sed -e 's/ //g' | \ 238 awk '{ print $1 % 256 }'` 239 240 MAC=`printf ${MAC_PREFIX}:%02x:%02x:%02x ${M4} ${M5} ${M6}` 241 242 # Set the link address (mac address) of virtual interface in 243 # virtual node to randomly generated MAC. 244 echo "Setting MAC address of ${EIFACE} to '${MAC}'" 245 jexec ${NODE_NAME} ifconfig ${EIFACE} link $MAC 246 | 232 M4=`od -An -N2 -i /dev/random | sed -e 's/ //g' | \ 233 awk '{ print $1 % 256 }'` 234 M5=`od -An -N2 -i /dev/random | sed -e 's/ //g' | \ 235 awk '{ print $1 % 256 }'` 236 M6=`od -An -N2 -i /dev/random | sed -e 's/ //g' | \ 237 awk '{ print $1 % 256 }'` 238 239 MAC=`printf ${MAC_PREFIX}:%02x:%02x:%02x ${M4} ${M5} ${M6}` 240 241 # Set the link address (mac address) of virtual interface in 242 # virtual node to randomly generated MAC. 243 echo "Setting MAC address of ${EIFACE} to '${MAC}'" 244 jexec ${NODE_NAME} ifconfig ${EIFACE} link $MAC 245 |
247 # Either IPv4 or IPv6 can be used in this script. Ifconfig | 246 # Either IPv4 or IPv6 can be used in this script. Ifconfig |
248 # IP setting syntax differs slightly for two IP versions. 249 # For version 4 'inet' keyword is used whereas for version 6 250 # 'inet6' is used. Below line tries to decide which IP version | 247 # IP setting syntax differs slightly for two IP versions. 248 # For version 4 'inet' keyword is used whereas for version 6 249 # 'inet6' is used. Below line tries to decide which IP version |
251 # is given and sets IPVER to 'inet' or 'inet6'. | 250 # is given and sets IPVER to 'inet' or 'inet6'. |
252 253 IPVER=`echo ${NODE_IP} | awk -F"." '{ split($4,last,"/"); \ 254 if( NF==4 && $1>0 && $1<256 && $2<256 && $3<256 && \ 255 last[1]<256) print "inet"; else print "inet6"}'` | 251 252 IPVER=`echo ${NODE_IP} | awk -F"." '{ split($4,last,"/"); \ 253 if( NF==4 && $1>0 && $1<256 && $2<256 && $3<256 && \ 254 last[1]<256) print "inet"; else print "inet6"}'` |
256 | 255 |
257 # Set IP address of virtual interface in virtual node. 258 echo "Setting IP address of ${EIFACE} to '${NODE_IP}'" 259 jexec ${NODE_NAME} ifconfig ${EIFACE} ${IPVER} ${NODE_IP} 260 261 RET_INTERFACE=${EIFACE} 262} 263 264virtual_chain_create_peer_if_necessary() { 265 266 if ! grep -q $1 ${TEMP_FILE} ; then | 256 # Set IP address of virtual interface in virtual node. 257 echo "Setting IP address of ${EIFACE} to '${NODE_IP}'" 258 jexec ${NODE_NAME} ifconfig ${EIFACE} ${IPVER} ${NODE_IP} 259 260 RET_INTERFACE=${EIFACE} 261} 262 263virtual_chain_create_peer_if_necessary() { 264 265 if ! grep -q $1 ${TEMP_FILE} ; then |
267 268 echo -n "Creating virtual node (jail) ${1}..." | 266 267 echo -n "Creating virtual node (jail) ${1}..." |
269 jail -c vnet name=${1} host.hostname=${1} \ | 268 jail -c vnet name=${1} host.hostname=${1} \ |
270 path=${JAIL_PATH} persist | 269 path=${JAIL_PATH} persist |
271 jexec ${1} sysctl -w net.inet.ip.forwarding=1 272 jexec ${1} sysctl -w net.inet6.ip6.forwarding=1 273 echo "done" | 270 jexec ${1} sysctl -w net.inet.ip.forwarding=1 271 jexec ${1} sysctl -w net.inet6.ip6.forwarding=1 272 echo "done" |
274 275 # Write name of the jail to temp file. Clean-up | 273 274 # Write name of the jail to temp file. Clean-up |
276 # procedure will use this name to remove jail. | 275 # procedure will use this name to remove jail. |
277 | 276 |
278 echo "node ${1}" >> ${TEMP_FILE} 279 fi 280 281} 282 | 277 echo "node ${1}" >> ${TEMP_FILE} 278 fi 279 280} 281 |
283 | |
284# Stop routine. 285virtual_chain_stop() { 286 287 if [ ! -e ${TEMP_FILE} ]; then 288 echo "Nothing to stop! ${TEMP_FILE}: temp file not found" 289 else 290 | 282# Stop routine. 283virtual_chain_stop() { 284 285 if [ ! -e ${TEMP_FILE} ]; then 286 echo "Nothing to stop! ${TEMP_FILE}: temp file not found" 287 else 288 |
291 echo -n "Shutdown bridge interface.." | 289 echo -n "Shutdown bridge interface.." |
292 OBJECTS=`cat ${TEMP_FILE} | grep bridge | awk '{print $2}'` 293 for BRIDGE in ${OBJECTS}; do 294 ngctl shutdown ${BRIDGE}: >/dev/null 2>&1 295 done 296 echo "done" | 290 OBJECTS=`cat ${TEMP_FILE} | grep bridge | awk '{print $2}'` 291 for BRIDGE in ${OBJECTS}; do 292 ngctl shutdown ${BRIDGE}: >/dev/null 2>&1 293 done 294 echo "done" |
297 298 echo -n "Shutdown all eiface interfaces..." | 295 296 echo -n "Shutdown all eiface interfaces..." |
299 OBJECTS=`cat ${TEMP_FILE} | grep interface | awk '{print $2}'` 300 for INTERFACE in ${OBJECTS}; do 301 ngctl shutdown ${INTERFACE}: >/dev/null 2>&1 302 done 303 echo "done" | 297 OBJECTS=`cat ${TEMP_FILE} | grep interface | awk '{print $2}'` 298 for INTERFACE in ${OBJECTS}; do 299 ngctl shutdown ${INTERFACE}: >/dev/null 2>&1 300 done 301 echo "done" |
304 305 echo -n "Removing all jails..." | 302 303 echo -n "Removing all jails..." |
306 OBJECTS=`cat ${TEMP_FILE} | grep node | awk '{print $2}'` 307 for NODE in ${OBJECTS}; do 308 jail -r ${NODE} 309 done 310 echo "done" | 304 OBJECTS=`cat ${TEMP_FILE} | grep node | awk '{print $2}'` 305 for NODE in ${OBJECTS}; do 306 jail -r ${NODE} 307 done 308 echo "done" |
311 312 echo "Removing tempfile ${TEMP_FILE}" | 309 310 echo "Removing tempfile ${TEMP_FILE}" |
313 rm ${TEMP_FILE} 314 fi | 311 rm ${TEMP_FILE} 312 fi |
315 echo "Virtual LAN objects removed succesfully!" | 313 echo "Virtual LAN objects removed successfully!" |
316 317} 318 319virtual_chain_usage() { 320 echo "usage: $0 start [target_topology]" 321 echo " : $0 [ stop | help ]" 322} 323 324 325# Main entry point. 326 | 314 315} 316 317virtual_chain_usage() { 318 echo "usage: $0 start [target_topology]" 319 echo " : $0 [ stop | help ]" 320} 321 322 323# Main entry point. 324 |
327 | |
328case $# in 329 1) 330 case $1 in 331 start) 332 echo -n "Creating default target topology:" 333 echo " ${TARGET_TOPOLOGY}" 334 virtual_chain_start 335 ;; 336 stop) 337 338 if [ ! -e ${TEMP_FILE} ]; then 339 echo -n "Noting to stop! ${TEMP_FILE}:" 340 echo " temp file not found" 341 else 342 virtual_chain_stop | 325case $# in 326 1) 327 case $1 in 328 start) 329 echo -n "Creating default target topology:" 330 echo " ${TARGET_TOPOLOGY}" 331 virtual_chain_start 332 ;; 333 stop) 334 335 if [ ! -e ${TEMP_FILE} ]; then 336 echo -n "Noting to stop! ${TEMP_FILE}:" 337 echo " temp file not found" 338 else 339 virtual_chain_stop |
343 fi | 340 fi |
344 ;; 345 help) 346 virtual_chain_usage 347 exit 1 348 ;; 349 *) 350 virtual_chain_usage 351 exit 1 --- 22 unchanged lines hidden --- | 341 ;; 342 help) 343 virtual_chain_usage 344 exit 1 345 ;; 346 *) 347 virtual_chain_usage 348 exit 1 --- 22 unchanged lines hidden --- |