| # ----------------------------------------------------------------------------- |
| # Starts or interacts with mininet in a remote screen session. |
| # ----------------------------------------------------------------------------- |
| [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 |
| . $ONOS_ROOT/tools/build/envDefaults |
| mininet="ssh -t -t $remote screen -L -S mininet" |
| $mininet -X "stuff \"$@\\n\"" 2>/dev/null |
| for a in $*; do shift; if [ "$a" = "--expect" ]; then break; fi; cmd="$cmd $a"; done |
| $mininet -X "stuff \"$cmd\\n\"" 2>/dev/null |
| sleep 1 && while test ! -f $log; do if test \$count -ge $MAX_WAIT; then exit 1; fi; sleep 1; let count=count+1; done |
| while ! (tail -n1 $log | egrep -q '^mininet>'); do if [ \$count -ge $MAX_WAIT ]; then exit 1; fi; sleep 1; done |
| if [ ! -f $log ]; then exit 1; fi; |
| while ! (tail -n1 $log | egrep -q '^mininet>'); do if test \$count -ge $MAX_WAIT; then exit 1; fi; sleep 1; let count=count+1; done |
| tac $log | awk '{ print \$0; } /^mininet>/ { if (on) { exit 0; } on=1; }' | tac > $aux |
| ssh $remote "rm -f $log; echo logfile flush 1 > ~/.screenrc" |
| scp $remote:$log /tmp/mininet.log |
| $mininet -X "stuff \"^C\\n\"" 2>/dev/null && \ |
| $mininet -X "stuff \"^C\\n\"" 2>/dev/null && \ |
| $mininet -X "stuff \"exit\\n\"" 2>/dev/null |