#!/bin/bash
-# Functions & variables
+#############
+# VARIABLES #
+#############
SETUPS_DIR=../../../source/diameter/stack/setups
MSGDTD=../../../include/anna/diameter/codec/message.dtd
DCTDTD=../../../include/anna/diameter/stack/dictionary.dtd
BASE_PROT=commands_baseProtocol.xml
-EXEC=./debug/example_diameter_launcher
-DPATH_dflt=$HOME/ADL
-RESOURCES_DIR=resources
+# Executables in priority order:
+EXEC_installed=/opt/bin/anna/example_diameter_launcher
+EXECS=( $EXEC_installed ./release/example_diameter_launcher ./debug/example_diameter_launcher )
+
+#############
+# FUNCTIONS #
+#############
_exit () {
echo
echo $1
exit
}
+# $1: deployment type
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 "./pre-start.sh" >> run.sh
- echo "> launcher.traces" >> run.sh
- echo "EXE=\"./ADL-launcher\"" >> run.sh
- echo "echo \$EXE > .exe" >> run.sh
- echo >> run.sh
- echo -n "\$EXE " >> run.sh
- for i in `cat args.txt | grep -v "^#"`
- do
- echo -n "$i " >> run.sh
- done
- echo "&" >> run.sh
+ # Basic launcher 'run.sh' will be created at deployment configuration:
+ [ "$1" = "b" ] && return
+ [ "$1" = "a" ] && exe=ADL-launcher
+ [ "$1" = "f" ] && { exe=ADL-ftclient ; ln -s ADL-launcher $exe ; }
+
+ cat << EOF > run.sh
+#!/bin/bash
+cd \`dirname \$0\`
+EXE=$exe
+STARTED=\`pgrep \$EXE 2>/dev/null\`
+[ \$? -eq 0 ] && { echo "Already started!"; echo "\$STARTED" ; exit 1 ; }
+./pre-start.sh
+0> launcher.traces
+rm -f counters/*
+# Execution line:
+./\$EXE -cntDir counters $(for i in `cat args.txt | grep -v "^#"`; do echo -n "$i "; done)&
+echo \$! > .pid
+EOF
+
chmod a+x run.sh
rm args.txt
}
createDictionaryPaths () {
-
for i in stacks/*commands*xml
do
stacks/dependence.sh $i >/dev/null
#############
# EXECUTION #
#############
+cd `dirname $0`
echo
echo "---------------------------------------"
echo "Anna Diameter Launcher (ADL) deployment"
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..."
-
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."
+available=
+for EXEC in ${EXECS[@]}; do
+ echo -n "Looking executable at '$EXEC' ... "
+ [ -x $EXEC ] && { available=yes ; echo "available !" ; break ; }
+ echo "not found"
+done
+[ -z "$available" ] && _exit "Anna Diameter Launcher (ADL) is not installed neither linked. See README.md (Install section)."
+[ ! -d $SETUPS_DIR ] && _exit "Diameter stacks not found ($SETUPS_DIR)."
+
+echo
+echo "Deploy one of these versions:"
+echo
+echo " (a)dvanced version: includes burst management script and templates for different scenarios. Automatic configuration during start."
+echo " (b)asic version: 4 types of launcher (client, server, balancer, dummy), lightly configured and managed through SIGURS2 method."
+echo " (f)unction test client: special client with regexp scheduler script based on splitted traffic logs."
+echo
+echo "Input option [b]:"
+read option
+[ "$option" = "" ] && option=b
+case $option in
+ a)
+ DEPLOYMENTS_DIR=deployments/advanced
+ DPATH_dflt=$HOME/ADL-advanced
+ ;;
+
+ b)
+ DEPLOYMENTS_DIR=deployments/basic
+ DPATH_dflt=$HOME/ADL-basic
+ ;;
+
+ f)
+ DEPLOYMENTS_DIR=deployments/ft-client
+ DPATH_dflt=$HOME/ADL-ft-client
+ ;;
+
+ *)
+ _exit "Unknown option !!"
+ ;;
+esac
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
+echo "Input deployment path [$DPATH_dflt]:"
+read DPATH
+[ "$DPATH" = "" ] && DPATH=$DPATH_dflt
+[ -d $DPATH ] && _exit "The path '$DPATH' already exists. Remove it before continue..."
echo "Copying ..."
mkdir -p $DPATH
mkdir -p $DPATH/stacks
mkdir -p $DPATH/DTDs
-cp $EXEC $DPATH/ADL-launcher
-cp -r $RESOURCES_DIR/* $DPATH
+mkdir -p $DPATH/counters
+mkdir -p $DPATH/resources
+if [ "$EXEC" = "$EXEC_installed" ]
+then
+ ln -s $EXEC_installed $DPATH/ADL-launcher
+else
+ cp $EXEC $DPATH/ADL-launcher
+fi
+cp -rL $DEPLOYMENTS_DIR/* $DPATH
+cp resources/* $DPATH/resources
cp $SETUPS_DIR/*xml $DPATH/stacks
cp $SETUPS_DIR/*sh $DPATH/stacks
cp $SETUPS_DIR/readme.txt $DPATH/stacks
echo "Preparing ..."
cd $DPATH
-[[ "$deploy_type" != "l" ]] && createRunScript
+createRunScript $option
createDictionaryPaths
cd - >/dev/null