Add deployment for ADML agent with http interface
[anna.git] / example / diameter / launcher / deploy-aots-adml.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 "               AOTS ADML Agent 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__dflt=$HOME/3rdParty/anna-aots-adml-builds/v"`date +'%y'`.`date +'%m'`.`date +'%d'`$build_type_letter"
39
40 echo "Choose the target path for installation [$INSTALL__dflt]:"
41 echo " (enter a non-existent directory)"
42 read INSTALL
43 [ -z "$INSTALL" ] && INSTALL=$INSTALL__dflt
44 INSTALL=`readlink -m $INSTALL`
45 [ -d $INSTALL ] && _exit "The target installation directory ($INSTALL) 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
51 cp -rL $SCR_DIR/deployments/aots-adml/* $INSTALL
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}
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_curl.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 # ADML Agent shall use http server:
110 httpOpt="--httpServer \`grep -v ^# .httpServer\`"
111 echo "${httpOpt}" >> ${ADML}/args.ft
112 echo "${httpOpt}" >> ${ADML}/args.st
113 echo "localhost:8000" > ${ADML}/.httpServer
114
115 _exit "Done!" 0
116