8a7f8b734b578e6f759c65bfcd6a97f02edb411e
[anna.git] / example / diameter / launcher / deploy-aots.sh
1 #!/bin/bash
2
3 #############
4 # VARIABLES #
5 #############
6 SCR_DIR=`readlink -f $0 | xargs dirname`
7 PROJECT_ROOT=$(readlink -f $SCR_DIR/../../..)
8
9 #############
10 # FUNCTIONS #
11 #############
12 _exit () {
13   local msg="$1"
14   local rc=$2
15   [ -z "$rc" ] && rc=1
16
17   # Exit message:
18   [ -n "$msg" ] && echo -e "\n${msg}\n"
19
20   exit $rc
21 }
22
23 #############
24 # EXECUTION #
25 #############
26
27 echo
28 echo "------------------------------------------------------"
29 echo "      AGENTS-ORIENTED TESTING SETUP installation      "
30 echo "------------------------------------------------------"
31 echo
32 [ -d $PROJECT_ROOT/build/Release ] && VARIANT=Release
33 [ -d $PROJECT_ROOT/build/Debug ] && VARIANT=Debug
34 [ -z "$VARIANT" ] && _exit "Cannot locate neither 'Release' nor 'Debug' variant !"
35 build_type_letter=$(echo $VARIANT | cut -c1 | tr '[:upper:]' '[:lower:]')
36
37 version__dflt=v"`date +'%y'`.`date +'%m'`.`date +'%d'`$build_type_letter"
38 INSTALL_AOTS__dflt=$HOME/3rdParty/anna-aots-builds/v"`date +'%y'`.`date +'%m'`.`date +'%d'`$build_type_letter"
39
40 echo "Choose the target path for installation [$INSTALL_AOTS__dflt]:"
41 echo " (enter a non-existent directory)"
42 read INSTALL_AOTS
43 [ -z "$INSTALL_AOTS" ] && INSTALL_AOTS=$INSTALL_AOTS__dflt
44 INSTALL_AOTS=`readlink -m $INSTALL_AOTS`
45 [ -d $INSTALL_AOTS ] && _exit "The target installation directory ($INSTALL_AOTS) already exists ! (if you want to reinstall, remove it first)"
46
47 echo
48 echo "Stage 1: Deploying resources ......................"
49 echo
50 mkdir -p $INSTALL_AOTS
51 cp -r $SCR_DIR/deployments/aots/* $INSTALL_AOTS
52
53 # VARIABLES ######################################
54 # Sources:
55 LDIR=${PROJECT_ROOT}/example/diameter/launcher
56 BIN_DIR=${PROJECT_ROOT}/build/$VARIANT/bin
57 LIB_DIR=${PROJECT_ROOT}/build/$VARIANT/lib
58
59 # Targets:
60 ADML=${INSTALL_AOTS}/agents/ADML
61 DTDs=${ADML}/DTDs
62 DYNLIBS=${ADML}/dynlibs
63 ##################################################
64
65 echo
66 echo "Variant: $VARIANT"
67 echo
68
69 # Empty directories:
70 mkdir -p ${ADML}/counters
71 mkdir -p ${ADML}/test-reports
72
73 # Scripts:
74 cp ${PROJECT_ROOT}/example/diameter/launcher/resources/scripts/operation_signal.sh ${ADML}/operation.sh
75
76 # Templates:
77 mkdir $DTDs
78 cp ${PROJECT_ROOT}/include/anna/diameter/codec/message.dtd ${DTDs}
79 cp ${PROJECT_ROOT}/include/anna/diameter/stack/dictionary.dtd ${DTDs}
80 cp ${PROJECT_ROOT}/example/diameter/launcher/resources/services_examples/services.dtd ${DTDs}
81
82 # Main Launcher and dynamic libraries:
83 cp ${BIN_DIR}/anna_diameter_launcher ${ADML}/ADML
84 cp -r $LIB_DIR/dynamic/launcher ${DYNLIBS}
85 cp $LIB_DIR/libanna_testing_shared.so ${DYNLIBS}
86
87 # Get stuff from leaf directories:
88 cd $LIB_DIR/dynamic/launcher
89 leafs=( $(find . -type d -links 2) )
90 cd - >/dev/null
91
92 cd ${PROJECT_ROOT}/dynamic/launcher
93 for dir in ${leafs[@]}
94 do
95     cp $dir/*.xml ${DYNLIBS}/$dir 2>/dev/null
96     cp $dir/dynamic.suffix ${DYNLIBS}/$dir 2>/dev/null
97     cp -r $dir/services ${DYNLIBS}/$dir 2>/dev/null
98 done
99 cd - >/dev/null
100
101 # ADML dynamic libs selection script:
102 cp ${LDIR}/resources/scripts/select_dynlib.sh ${DYNLIBS}/select.sh
103
104 # Default dynamic library:
105 cd ${DYNLIBS}
106 ln -sf default/libanna_launcher_procedure_default_shared.so
107 cd - >/dev/null
108
109 _exit "Done!" 0
110