Improvements & fixes
[anna.git] / example / diameter / launcher / deployments / basic / configure.sh
diff --git a/example/diameter/launcher/deployments/basic/configure.sh b/example/diameter/launcher/deployments/basic/configure.sh
new file mode 100755 (executable)
index 0000000..a5d1515
--- /dev/null
@@ -0,0 +1,109 @@
+#!/bin/bash
+
+#############
+# VARIABLES #
+#############
+
+# Diameter dictionary:
+STD_DICTIONARY=stacks/avps_etsi.xml,stacks/avps_ietf.xml,stacks/avps_tgpp.xml,stacks/commands_baseProtocol.xml
+APP_DICTIONARY=stacks/commands_qosControl.xml
+DICTIONARY=$STD_DICTIONARY,$APP_DICTIONARY
+# Perhaps the stack is not fully defined:
+#KINDNESS=-ignoreErrors
+# But we prefer stack to generate Failed-AVP automatically:
+KINDNESS=
+
+# Communication endpoints:
+LOCAL_STANDARD_ENDPOINT=localhost:3868
+EXAMPLE_ENTITY_4_BALANCER=192.168.12.11:3868,192.168.12.21:3868
+CONNS=10
+
+# General
+EXE_BN=ADL-launcher
+
+# Tracing:
+TRACING="-cntDir counters"
+# need detailed traces ?:
+#TRACING="$TRACING -trace debug"
+
+#############
+# FUNCTIONS #
+#############
+
+_exit () {
+  echo
+  echo $1
+  echo
+  exit 1
+}
+
+# $1: process name
+createRunScript () {
+
+  cat << EOF > run.sh
+#!/bin/bash
+cd \`dirname \$0\`
+STARTED=\`pgrep $1 2>/dev/null\`
+[ \$? -eq 0 ] && { echo "Already started!"; echo "\$STARTED" ; exit 1 ; }
+0> launcher.traces
+rm -f counters/*
+# Execution line:
+./$@ &
+echo \$! > .pid
+EOF
+
+  chmod a+x run.sh
+}
+
+# $1: input option (c, s, b, d)
+# Retuns the type of launcher logical name for the input option
+get_tol () {
+  [ "$1" = "c" ] && echo client
+  [ "$1" = "s" ] && echo server
+  [ "$1" = "b" ] && echo balancer
+  [ "$1" = "d" ] && echo dummy
+}
+
+#############
+# EXECUTION #
+#############
+cd `dirname $0`
+SCR_DIR=`pwd`
+echo
+echo
+echo "Configure a (c)lient, (s)erver, (b)alancer or (d)ummy [c]:"
+read option
+[ "$option" = "" ] && option=c
+tol=$(get_tol $option)
+[ "$tol" = "" ] && _exit "Option '$option' not implemented !!"
+
+# Run script:
+EXE_LINK=ADL-$tol
+ln -sf $EXE_BN $EXE_LINK
+
+case $tol in
+
+  client)
+    ENTITY=$LOCAL_STANDARD_ENDPOINT
+    createRunScript $EXE_LINK -dictionary $DICTIONARY -entity $ENTITY -entityServerSessions $CONNS -diameterServerSessions 0 $KINDNESS $TRACING &
+    ;;
+
+  server)
+    SERVER=$LOCAL_STANDARD_ENDPOINT
+    createRunScript $EXE_LINK -dictionary $DICTIONARY -diameterServer $SERVER -diameterServerSessions $CONNS -entityServerSessions 0 $KINDNESS $TRACING &
+    ;;
+
+  balancer)
+    SERVER=$LOCAL_STANDARD_ENDPOINT
+    ENTITY=$EXAMPLE_ENTITY_4_BALANCER
+    createRunScript $EXE_LINK -dictionary $DICTIONARY -entity $ENTITY -entityServerSessions $CONNS -diameterServer $SERVER -diameterServerSessions $CONNS -balance $KINDNESS $TRACING &
+    ;;
+
+  dummy)
+    createRunScript $EXE_LINK -dictionary $DICTIONARY -entityServerSessions 0 -diameterServerSessions 0 $KINDNESS $TRACING &
+    ;;
+
+esac
+
+echo "Created 'run.sh' script !"
+echo