From 61f1340da3cae5159d2e3bc14fc47c6d4bf9453e Mon Sep 17 00:00:00 2001 From: Eduardo Ramos Testillano Date: Sun, 23 Oct 2016 14:46:28 +0200 Subject: [PATCH] Dynamic lib selection and deployment --- example/diameter/launcher/DEPLOY.sh | 55 +++++++++++++++---- example/diameter/launcher/DEPLOY_setups.sh | 16 +++--- .../launcher/deployments/basic/configure.sh | 2 +- .../deployments/st-client/configure.sh | 1 + .../resources/scripts/select_dynlib.sh | 31 +++++++++++ 5 files changed, 85 insertions(+), 20 deletions(-) create mode 100755 example/diameter/launcher/resources/scripts/select_dynlib.sh diff --git a/example/diameter/launcher/DEPLOY.sh b/example/diameter/launcher/DEPLOY.sh index 906a0b2..a314a30 100755 --- a/example/diameter/launcher/DEPLOY.sh +++ b/example/diameter/launcher/DEPLOY.sh @@ -19,8 +19,8 @@ STACKMGMT_EXEC_installed=/opt/bin/anna/example_diameter_stackManagement STACKMGMT_EXECS=( $STACKMGMT_EXEC_installed ../stackManagement/release/example_diameter_stackManagement ../stackManagement/debug/example_diameter_stackManagement ) # Dynamic library: -DYNLIB_installed=/usr/local/lib/libanna_dynamicLauncherProcedure.so -DYNLIBS=( $DYNLIB_installed ../../../dynamic/launcher/default/release/libanna_dynamicLauncherProcedure.so ../../../dynamic/launcher/default/debug/libanna_dynamicLauncherProcedure.so ) +#DYNLIB_installed=/usr/local/lib/libanna_dynamicLauncherProcedure.so +#DYNLIBS=( $DYNLIB_installed ../../../dynamic/launcher/default/release/libanna_dynamicLauncherProcedure.so ../../../dynamic/launcher/default/debug/libanna_dynamicLauncherProcedure.so ) ############# # FUNCTIONS # @@ -74,7 +74,7 @@ STARTED=\`pgrep \$EXE$ 2>/dev/null\` 0> launcher.trace rm -f counters/* test-reports/* # Execution line: -export LD_LIBRARY_PATH=\$PWD +export LD_LIBRARY_PATH=\$PWD/dynlibs ./\$EXE --services services.xml --cntDir counters --tmDir test-reports $other & echo \$! > .pid EOF @@ -104,6 +104,12 @@ for EXEC in ${EXECS[@]}; do done [ -z "$available" ] && _exit "Anna Diameter Launcher (ADML) is not installed neither linked. See README.md (Install section)." +# Dynamic library variant: +dynlib_variant= +[ -f ./release/example_diameter_launcher ] && dynlib_variant=release +[ -f ./debug/example_diameter_launcher ] && dynlib_variant=debug +[ -z "$dynlib_variant" ] && _exit "Unknown dynamic library variant" + # Dictionary creation: available= for STACKMGMT_EXEC in ${STACKMGMT_EXECS[@]}; do @@ -115,13 +121,13 @@ done STACKMGMT_EXEC=`readlink -f $STACKMGMT_EXEC` # Dynamic library: -available= -for DYNLIB in ${DYNLIBS[@]}; do - echo -n "Looking dynamic library at '$DYNLIB' ... " - [ -x $DYNLIB ] && { available=yes ; echo "available !" ; break ; } - echo "not found" -done -[ -z "$available" ] && _exit "Anna Diameter Launcher Dynamic Procedure Library (ADML) is not installed neither linked. See README.md (Install section)." +#available= +#for DYNLIB in ${DYNLIBS[@]}; do +# echo -n "Looking dynamic library at '$DYNLIB' ... " +# [ -x $DYNLIB ] && { available=yes ; echo "available !" ; break ; } +# echo "not found" +#done +#[ -z "$available" ] && _exit "Anna Diameter Launcher Dynamic Procedure Library (ADML) is not installed neither linked. See README.md (Install section)." [ ! -d $SETUPS_DIR ] && _exit "Diameter stacks not found ($SETUPS_DIR)." @@ -192,7 +198,22 @@ mkdir -p $DPATH/stacks mkdir -p $DPATH/DTDs mkdir -p $DPATH/counters mkdir -p $DPATH/test-reports -cp $DYNLIB $DPATH + +# Dynamic libs: +mkdir -p $DPATH/dynlibs +cd ../../../dynamic/launcher +DYNLIBS=( $(find . -name "*.so") ) +for dl in ${DYNLIBS[@]} +do + dir=$(dirname $dl | xargs dirname) + mkdir -p $DPATH/dynlibs/$dir + cp $dir/$dynlib_variant/*.so $DPATH/dynlibs/$dir +done +cd - >/dev/null +cp ./resources/scripts/select_dynlib.sh $DPATH/dynlibs/select.sh +cd $DPATH/dynlibs +ln -s default/libanna_dynamicLauncherProcedure.so +cd - >/dev/null [ "$option" = "b" ] && mkdir -p $DPATH/services @@ -230,6 +251,18 @@ stacks/makeAutonomous.sh commands_qosControl.xml stacks/stack-mgmt >/dev/null ln -s stacks/autonomous.commands_qosControl.xml dictionary.xml cd - >/dev/null +if [ "$option" = "s" ] +then + cd $DPATH + ln -s services_example services + mv run.sh .run-one.sh + mv run_all.sh run.sh + mv operation.sh .operation-one.sh + mv operation_all.sh operation.sh + rm dictionary.xml + cd - >/dev/null +fi + # Help: echo echo "Go to '$DPATH' and see README file" diff --git a/example/diameter/launcher/DEPLOY_setups.sh b/example/diameter/launcher/DEPLOY_setups.sh index 42332a6..dab557d 100755 --- a/example/diameter/launcher/DEPLOY_setups.sh +++ b/example/diameter/launcher/DEPLOY_setups.sh @@ -99,14 +99,14 @@ case $type in $DEPLOY_SCR b $target/ADML-serverGx $DEPLOY_SCR b $target/ADML-serverRx echo "Configuring ..." - cd $target/ADML-st-client - ln -s services_example services - mv run.sh .run-one.sh - mv run_all.sh run.sh - mv operation.sh .operation-one.sh - mv operation_all.sh operation.sh - rm dictionary.xml - cd - >/dev/null +# cd $target/ADML-st-client +# ln -s services_example services +# mv run.sh .run-one.sh +# mv run_all.sh run.sh +# mv operation.sh .operation-one.sh +# mv operation_all.sh operation.sh +# rm dictionary.xml +# cd - >/dev/null cd $target/ADML-serverGx echo s | ./configure.sh >/dev/null sed -i 's/3868/3869/' services.xml diff --git a/example/diameter/launcher/deployments/basic/configure.sh b/example/diameter/launcher/deployments/basic/configure.sh index cc4fa74..f03eca7 100755 --- a/example/diameter/launcher/deployments/basic/configure.sh +++ b/example/diameter/launcher/deployments/basic/configure.sh @@ -29,7 +29,7 @@ STARTED=\`pgrep $1$ 2>/dev/null\` 0> launcher.trace rm -f counters/* test-reports/* # Execution line: -export LD_LIBRARY_PATH=\$PWD +export LD_LIBRARY_PATH=\$PWD/dynlibs ./$@ --services services.xml & echo \$! > .pid EOF diff --git a/example/diameter/launcher/deployments/st-client/configure.sh b/example/diameter/launcher/deployments/st-client/configure.sh index 5c4e8aa..b818a78 100755 --- a/example/diameter/launcher/deployments/st-client/configure.sh +++ b/example/diameter/launcher/deployments/st-client/configure.sh @@ -241,6 +241,7 @@ do cd ADMLS/ADML-$instance mkdir counters mkdir test-reports + ln -s ../../dynlibs # Create resources: ln -s ../../.operation-one.sh operation.sh ln -s ../../pre-start.sh diff --git a/example/diameter/launcher/resources/scripts/select_dynlib.sh b/example/diameter/launcher/resources/scripts/select_dynlib.sh new file mode 100755 index 0000000..40a0072 --- /dev/null +++ b/example/diameter/launcher/resources/scripts/select_dynlib.sh @@ -0,0 +1,31 @@ +#!/bin/bash +echo +echo "------------------------------------------------" +echo "Dynamic library selection for launcher procedure" +echo "------------------------------------------------" +cd $(dirname $0) +option=$1 +rm -f libanna_dynamicLauncherProcedure.so +if [ -z "$option" ] +then + echo " (you could provide directly the path to the .so file)" + echo + echo "Available options:" + tmpfile=$(mktemp) + find . -name "*.so" > $tmpfile + echo + for line in $(cat $tmpfile); do echo " $line" ; done + dflt=$(grep "^./default/" $tmpfile) + echo + echo -n "Paste your selection [$dflt]: " + read option + [ -z "$option" ] && option=$dflt + rm $tmpfile +fi + +[ ! -f $option ] && { echo -e "\nInvalid file !\n" ; exit 1 ; } +ln -sf $option libanna_dynamicLauncherProcedure.so +echo +echo "Library enabled" +echo + -- 2.20.1