Tunning of ADL configuration
[anna.git] / example / diameter / launcher / DEPLOY.sh
1 #!/bin/bash
2
3 #############
4 # VARIABLES #
5 #############
6 SETUPS_DIR=../../../source/diameter/stack/setups
7 MSGDTD=../../../include/anna/diameter/codec/message.dtd
8 DCTDTD=../../../include/anna/diameter/stack/dictionary.dtd
9 BASE_PROT=commands_baseProtocol.xml
10 EXEC=./debug/example_diameter_launcher
11 DPATH_dflt=$HOME/ADL
12
13 #############
14 # FUNCTIONS #
15 #############
16 _exit () {
17    echo
18    echo $1
19    echo
20    exit
21 }
22
23 # $1: deployment type
24 createRunScript () {
25
26   # Basic launcher 'run.sh' will be created at deployment configuration: 
27   [ "$1" = "b" ] && return
28   [ "$1" = "a" ] && exe=ADL-launcher
29   [ "$1" = "f" ] && { exe=ADL-ftclient ; ln -s ADL-launcher $exe ; }
30
31   cat << EOF > run.sh
32 #!/bin/bash
33 cd \`dirname \$0\`
34 EXE=$exe
35 STARTED=\`pgrep \$EXE 2>/dev/null\`
36 [ \$? -eq 0 ] && { echo "Already started!"; echo "\$STARTED" ; exit 1 ; }
37 ./pre-start.sh
38 0> launcher.traces
39 rm -f counters/*
40 # Execution line:
41 ./\$EXE -cntDir counters $(for i in `cat args.txt | grep -v "^#"`; do echo -n "$i "; done)&
42 echo \$! > .pid
43 EOF
44
45   chmod a+x run.sh
46   rm args.txt
47 }
48
49 createDictionaryPaths () {
50   for i in stacks/*commands*xml
51   do
52     stacks/dependence.sh $i >/dev/null
53     stack=`basename $i`
54     if test "$stack" != "$BASE_PROT"
55     then
56       > .dictionary__${stack}
57       for j in `cat ${i}.dep`
58       do
59         echo -n "${j}," >> .dictionary__${stack}
60       done
61       echo "stacks/$BASE_PROT,stacks/${stack}" >> .dictionary__${stack}
62     fi
63   done
64
65   # Default:
66   ln -s .dictionary__commands_qosControl.xml .dictionary
67
68   # Remove deps:
69   rm -f stacks/*.dep
70 }
71
72 #############
73 # EXECUTION #
74 #############
75 cd `dirname $0`
76 echo
77 echo "---------------------------------------"
78 echo "Anna Diameter Launcher (ADL) deployment"
79 echo "---------------------------------------"
80 echo
81 echo "Input deployment path [$DPATH_dflt]:"
82 read DPATH
83 [ "$DPATH" = "" ] && DPATH=$DPATH_dflt
84 [ -d $DPATH ] && _exit "The path '$DPATH' already exists. Remove it before continue..."
85
86 echo "Basic checkings ..."
87 [ ! -f $EXEC ] && _exit "Anna Diameter Launcher (ADL) is not linked. Execute 'scons' for 'anna' suite."
88 [ ! -d $SETUPS_DIR ] && _exit "Diameter stacks not found ($SETUPS_DIR). Perhaps you executed this script out of its parent path."
89
90 echo
91 echo "Deploy one of these versions:"
92 echo
93 echo " (a)dvanced version:     includes burst management script and templates for different scenarios. Automatic configuration during start."
94 echo " (b)asic version:        4 types of launcher (client, server, balancer, dummy), lightly configured and managed through SIGURS2 method."
95 echo " (f)unction test client: special client with regexp scheduler script based on splitted traffic logs."
96 echo
97 echo "Input option [b]:"
98 read option
99 [ "$option" = "" ] && option=b
100 case $option in
101   a)
102     RESOURCES_DIR=resources/advanced
103   ;;
104
105   b)
106     RESOURCES_DIR=resources/basic
107   ;;
108
109   f)
110     RESOURCES_DIR=resources/ft-client
111   ;;
112
113   *)
114     _exit "Unknown option !!"
115   ;;
116 esac
117
118 echo "Copying ..."
119 mkdir -p $DPATH
120 mkdir -p $DPATH/stacks
121 mkdir -p $DPATH/DTDs
122 mkdir -p $DPATH/counters
123 cp $EXEC $DPATH/ADL-launcher
124 cp -rL $RESOURCES_DIR/* $DPATH
125 cp $SETUPS_DIR/*xml $DPATH/stacks
126 cp $SETUPS_DIR/*sh $DPATH/stacks
127 cp $SETUPS_DIR/readme.txt $DPATH/stacks
128 cp $MSGDTD $DPATH/DTDs
129 cp $DCTDTD $DPATH/DTDs
130
131 echo "Preparing ..."
132 cd $DPATH
133 createRunScript $option
134 createDictionaryPaths
135 cd - >/dev/null
136
137 # Help:
138 echo
139 echo "Go to '$DPATH' and see README file"
140 echo
141 echo "Done!"
142 echo
143 echo
144
145