Improve deployments and installation procedures
[anna.git] / example / diameter / launcher / DEPLOY.sh
index 76ccd8b..7f53a99 100755 (executable)
@@ -7,7 +7,10 @@ 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
+
+# Executables in priority order:
+EXEC_installed=/opt/bin/anna/example_diameter_launcher
+EXECS=( $EXEC_installed ./release/example_diameter_launcher ./debug/example_diameter_launcher )
 
 #############
 # FUNCTIONS #
@@ -78,7 +81,13 @@ echo "Anna Diameter Launcher (ADL) deployment"
 echo "---------------------------------------"
 echo
 echo "Basic checkings ..."
-[ ! -f $EXEC ] && _exit "Anna Diameter Launcher (ADL) is not linked. Execute 'scons' for 'anna' suite."
+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
@@ -124,7 +133,12 @@ mkdir -p $DPATH/stacks
 mkdir -p $DPATH/DTDs
 mkdir -p $DPATH/counters
 mkdir -p $DPATH/resources
-cp $EXEC $DPATH/ADL-launcher
+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