From 6b3c0d5e652726b5034fa595bc020476862c948f Mon Sep 17 00:00:00 2001 From: Eduardo Ramos Testillano Date: Sat, 14 Mar 2015 19:18:28 +0100 Subject: [PATCH] Make easy ADL configuration (lite version) --- example/diameter/launcher/DEPLOY.sh | 18 +-- .../diameter/launcher/resources_lite/README | 32 ++++-- .../launcher/resources_lite/configure.sh | 108 ++++++++++++++++++ .../launcher/resources_lite/operation.sh | 23 ++-- .../diameter/launcher/resources_lite/run.sh | 49 -------- .../resources_lite/xml_examples/ccr.xml | 44 +++++++ 6 files changed, 196 insertions(+), 78 deletions(-) create mode 100755 example/diameter/launcher/resources_lite/configure.sh delete mode 100755 example/diameter/launcher/resources_lite/run.sh create mode 100644 example/diameter/launcher/resources_lite/xml_examples/ccr.xml diff --git a/example/diameter/launcher/DEPLOY.sh b/example/diameter/launcher/DEPLOY.sh index fbb72dc..f1d1538 100755 --- a/example/diameter/launcher/DEPLOY.sh +++ b/example/diameter/launcher/DEPLOY.sh @@ -20,8 +20,8 @@ createRunScript () { echo "#!/bin/bash" > run.sh echo "EXE=\`cat .exe 2>/dev/null\`" >> run.sh - echo "STARTED=\`ps -fea | grep \"\$EXE\" | grep -v grep\`" >> run.sh - echo "[ \"\$EXE\" != \"\" -a \"\$STARTED\" != \"\" ] && { echo \"Already started!\"; echo \"\$STARTED\" ; exit ; }" >> run.sh + echo "STARTED=\`pgrep \$EXE2>/dev/null\`" >> run.sh + echo "[ \$? -eq 0 ] && { echo \"Already started!\"; echo \"\$STARTED\" ; exit 1 ; }" >> run.sh echo "./pre-start.sh" >> run.sh echo "> launcher.traces" >> run.sh echo "EXE=\"./ADL-launcher\"" >> run.sh @@ -72,18 +72,18 @@ echo "---------------------------------------" echo echo "Input deployment path [$DPATH_dflt]:" read DPATH -[[ "$DPATH" = "" ]] && DPATH=$DPATH_dflt -[[ -d $DPATH ]] && _exit "The path '$DPATH' already exists. Remove it before continue..." +[ "$DPATH" = "" ] && DPATH=$DPATH_dflt +[ -d $DPATH ] && _exit "The path '$DPATH' already exists. Remove it before continue..." echo "Basic checkings ..." -[[ ! -f $EXEC ]] && _exit "Anna Diameter Launcher (ADL) is not linked. Execute 'scons' for 'anna' suite." -[[ ! -d $SETUPS_DIR ]] && _exit "Diameter stacks not found ($SETUPS_DIR). Perhaps you executed this script out of its parent path." +[ ! -f $EXEC ] && _exit "Anna Diameter Launcher (ADL) is not linked. Execute 'scons' for 'anna' suite." +[ ! -d $SETUPS_DIR ] && _exit "Diameter stacks not found ($SETUPS_DIR). Perhaps you executed this script out of its parent path." echo echo "Deploy (f)ull version or (l)ite version [l]:" read deploy_type -[[ "$deploy_type" = "" ]] && deploy_type=l -[[ "$deploy_type" = "l" ]] && RESOURCES_DIR=resources_lite +[ "$deploy_type" = "" ] && deploy_type=l +[ "$deploy_type" = "l" ] && RESOURCES_DIR=resources_lite echo "Copying ..." mkdir -p $DPATH @@ -100,7 +100,7 @@ cp $DCTDTD $DPATH/DTDs echo "Preparing ..." cd $DPATH -[[ "$deploy_type" != "l" ]] && createRunScript +[ "$deploy_type" != "l" ] && createRunScript createDictionaryPaths cd - >/dev/null diff --git a/example/diameter/launcher/resources_lite/README b/example/diameter/launcher/resources_lite/README index ffb4633..dc46f77 100644 --- a/example/diameter/launcher/resources_lite/README +++ b/example/diameter/launcher/resources_lite/README @@ -1,21 +1,33 @@ - ABOUT CONTENT ------------- -Stacks available at './stacks'. -The launcher uses the configuration given at './run.sh' variable definition section. Edit it - if you want to adapt your system networking setup. - Template for xml messages (message.dtd) and dictionaries (dictionary.dtd) are informative, not -actually required by process. Located at './DTDs'. +actually required by process. They are located at './DTDs'. Stacks are available at './stacks'. +There are also some stuff (hex/xml examples, etc.) which could be useful. + +Firstly you have to configure this directory in order to choose the type of launcher which will +be preconfigured for your basic needs: client, server, balancer (proxy) and dummy process (this +last is used for code/encode and does not launch any communication interface). + +If you are going to launch different processes, we recommend to clone this whole directory into +another one (call it 'ADL-client', 'ADL-server_2', 'Diameter_proxy', or whatever you want), and +then configure it again. + +Execute './configure.sh' and follow the intructions. You can call this several times, but the +last configuration will be the one which prevails. STARTING THE PROCESS -------------------- -Start with 'run.sh'. You could manually edit such script adding parameters as '-trace debug' to -get complete 'launcher.traces'. Execute 'ADL-launcher' without arguments to see a complete -command-line help. +After configuring the ADL execution context, a new script has been created: 'run.sh'. +You can manually edit such script adding parameters as '-trace debug' to get complete traces, +or adapt the communication endpoints for your environment. + +Launch the executable process without arguments to see a complete command-line help. +Don't be scared. There are plenty of possibilities but the 'run.sh' script has been prepared +for the type of launcher you wanted. OPERATION --------- Management interface for lite version is based on SIGUSR2 signal caugh. Use './operation.sh' -script to send any operation to the process. +script to send any operation to the process. Ask for help with that script to see all the +operations supported. diff --git a/example/diameter/launcher/resources_lite/configure.sh b/example/diameter/launcher/resources_lite/configure.sh new file mode 100755 index 0000000..335e4ff --- /dev/null +++ b/example/diameter/launcher/resources_lite/configure.sh @@ -0,0 +1,108 @@ +#!/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_pccPS_EricssonSAPC_se.xml +DICTIONARY=$STD_DICTIONARY,$APP_DICTIONARY +# Perhaps the stack is not fully defined: +KINDNESS=-ignoreErrors + +# 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\` +EXE=\`cat .exe 2>/dev/null\` +STARTED=\`pgrep $1 2>/dev/null\` +[ \$? -eq 0 ] && { echo "Already started!"; echo "\$STARTED" ; exit 1 ; } +echo $1 > .exe +0> launcher.traces +# 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 diff --git a/example/diameter/launcher/resources_lite/operation.sh b/example/diameter/launcher/resources_lite/operation.sh index 585ca98..5f3afc0 100755 --- a/example/diameter/launcher/resources_lite/operation.sh +++ b/example/diameter/launcher/resources_lite/operation.sh @@ -1,30 +1,33 @@ #!/bin/bash -# General -EXE=./ADL-launcher - +############# +# FUNCTIONS # +############# _exit () { echo - echo $1 + echo -e $1 echo exit 1 } +############# +# EXECUTION # +############# +cd `dirname $0` echo -echo -[[ "$1" = "" ]] && _exit "Use: $0 ; i.e.: $0 help" - -PID=$(pgrep `basename $EXE`) -[[ $? -ne 0 ]] && _exit "Can't found the process '$EXE'. Use './run.sh' to start it." +# Get the PID: +[ ! -f .pid ] && _exit "Can't found '`pwd`/.pid'.\nTry to pgrep your process name and dump pid to that file." +PID=`cat .pid` # Send operation: +[ "$1" = "" ] && _exit "Use: $0 ; i.e.: $0 help" echo $1 > sigusr2.tasks.input kill -s SIGUSR2 $PID sleep 1 echo echo -echo "You could see results on './sigusr2.tasks.output' file." +echo "You could see results on '`pwd`/sigusr2.tasks.output' file." echo echo diff --git a/example/diameter/launcher/resources_lite/run.sh b/example/diameter/launcher/resources_lite/run.sh deleted file mode 100755 index a83de90..0000000 --- a/example/diameter/launcher/resources_lite/run.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash - -# Diameter dictionary and endpoints: -DICTIONARY=stacks/avps_etsi.xml,stacks/avps_ietf.xml,stacks/avps_tgpp.xml,stacks/commands_baseProtocol.xml,stacks/commands_pccPS_EricssonSAPC_se.xml -SERVER=localhost:3868 -ENTITY=192.168.12.11:3868,192.168.12.21:3868 -CONNS=10 - -# Perhaps the stack is not fully defined: -KINDNESS=-ignoreErrors - -# Tracing (comment the second line if you need detailed traces): -TRACING="-trace debug -cntDir counters" -TRACING="-cntDir counters" - -# General -EXE=./ADL-launcher - -echo -echo -PID=$(pgrep `basename $EXE`) -if [ $? -eq 0 ] -then - echo "The process '$EXE' seems to be already started (pid: $PID)." - echo "Press ENTER to continue, CTRL-C to abort ..." - read dummy -fi - -echo "Run as a (c)lient, (s)erver, (b)alancer or (d)ummy [c]:" -read option -[[ "$option" = "" ]] && option=c - -case $option in - c) $EXE -dictionary $DICTIONARY -entity $ENTITY -entityServerSessions $CONNS -diameterServerSessions 0 $KINDNESS $TRACING & - ;; - - s) $EXE -dictionary $DICTIONARY -diameterServer $SERVER -diameterServerSessions $CONNS -entityServerSessions 0 $KINDNESS $TRACING & - ;; - - b) $EXE -dictionary $DICTIONARY -entity $ENTITY -entityServerSessions $CONNS -diameterServer $SERVER -diameterServerSessions $CONNS -balance $KINDNESS $TRACING & - ;; - - d) $EXE -dictionary $DICTIONARY -entityServerSessions 0 -diameterServerSessions 0 $KINDNESS $TRACING & - ;; - - *) echo "Option '$option' not implemented !!" - ;; -esac - diff --git a/example/diameter/launcher/resources_lite/xml_examples/ccr.xml b/example/diameter/launcher/resources_lite/xml_examples/ccr.xml new file mode 100644 index 0000000..46483a2 --- /dev/null +++ b/example/diameter/launcher/resources_lite/xml_examples/ccr.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.20.1