improve -of13 switching in distributions/base (BUG 802)
[integration/distribution.git] / distributions / base / src / assemble / resources / run.sh
1 #!/bin/bash
2
3 # Use same path for run.internal.sh
4 RUNSH_DIR=$(dirname $0)
5 CONTROLLER_RUNSH=${RUNSH_DIR}/run.internal.sh
6
7 OF_FILTER=
8
9 # Be extra careful to pass on usage from run.internal.sh, but add our 
10 # usage as well in the standard way
11 function usage {
12     $CONTROLLER_RUNSH -help | sed 's/\[-help\]/\[-help\] \[-of13\] \[-bundlefilter \<bundlefilter\> \]/' | sed "s;$CONTROLLER_RUNSH;$0;"
13     exit 1
14 }
15
16 OF13=0
17 BUNDLEFILTER=
18 while true ; do
19     (( i += 1 ))
20     case "${@:$i:1}" in
21         -of13) OF13=1 ;;
22         -bundlefilter) (( i += 1 )); BUNDLEFILTER="|${@:$i:1}";;
23         -help) usage ;;
24         "") break ;;
25     esac
26 done
27
28 # clean available optional configurations (links)
29 find configuration/initial -type l -exec rm {} \;
30
31 # OF Filter selection
32 OF_FILTER="org.opendaylight.(openflowplugin|openflowjava)"
33 if (( $OF13 != 0 )); then
34     OF_FILTER="org.opendaylight.controller.(thirdparty.org.openflow|protocol_plugins.openflow)"
35     while read ofConfig; do
36         ln -s ../initial.available/$(basename ${ofConfig}) configuration/initial/
37     done < <(find configuration/initial.available -name '*openflowplugin.xml')
38 fi
39
40 # Make sure we suck out our additional args so as to not confuse
41 # run.internal.sh
42 NEWARGS=`echo $@|sed 's/-of13//'|sed 's/-bundlefilter[ ]*[^ ]*//'`
43
44 # Build the filter string
45 FILTERBEGINING='^(?!'
46 FILTERENDING=').*'
47 FILTER=${FILTERBEGINING}${OF_FILTER}${BUNDLEFILTER}${FILTERENDING}
48
49 # Run the command
50 $CONTROLLER_RUNSH -Dfelix.fileinstall.filter="$FILTER" $NEWARGS