Remove operation help.
[anna.git] / example / diameter / launcher / deployments / basic / configure.sh
1 #!/bin/bash
2
3 #############
4 # VARIABLES #
5 #############
6
7 # General
8 EXE_BN=ADML
9
10 #############
11 # FUNCTIONS #
12 #############
13
14 _exit () {
15   echo
16   echo $1
17   echo
18   exit 1
19 }
20
21 # $1: process name
22 createRunScript () {
23
24   cat << EOF > run.sh
25 #!/bin/bash
26 cd \`dirname \$0\`
27 STARTED=\`pgrep $1$ 2>/dev/null\`
28 [ \$? -eq 0 ] && { echo "Already started!"; echo "\$STARTED" ; exit 1 ; }
29 0> launcher.trace
30 rm -f counters/* test-reports/*
31 # Execution line:
32 export LD_LIBRARY_PATH=\$PWD/dynlibs
33 ./$@ --services services.xml &
34 echo \$! > .pid
35 EOF
36
37   chmod a+x run.sh
38 }
39
40 # $1: input option (c, s, b, d)
41 # Retuns the type of launcher logical name for the input option
42 get_tol () {
43   [ "$1" = "c" ] && echo client
44   [ "$1" = "s" ] && echo server
45   [ "$1" = "b" ] && echo balancer
46   [ "$1" = "d" ] && echo dummy
47 }
48
49 #############
50 # EXECUTION #
51 #############
52 cd `dirname $0`
53 SCR_DIR=`pwd`
54 echo
55 echo
56 echo "Configure a (c)lient, (s)erver, (b)alancer or (d)ummy [c]:"
57 read option
58 [ "$option" = "" ] && option=c
59 tol=$(get_tol $option)
60 [ "$tol" = "" ] && _exit "Option '$option' not implemented !!"
61
62 # Services
63 ln -sf services/${tol}.xml services.xml
64
65 # Tracing
66 DEBUG="--cntDir counters --tmDir test-reports"
67 echo
68 echo "Enable debug traces ? (y/n) [n]:"
69 read enable
70 [ "$enable" = "" ] && enable=n
71 [ "$enable" = "y" ] && DEBUG="$DEBUG --trace debug"
72
73 # Kindness
74 KINDNESS=
75 echo
76 echo "Strict xml for decoded messages ? (y/n) [y]:"
77 read strict
78 [ "$strict" = "" ] && strict=y
79 [ "$strict" = "n" ] && KINDNESS="--ignoreFlags"
80 if [ "$option" = "s" ]
81 then
82   echo
83   echo "Ignore errors ? (y/n) [n]:"
84   read i_errors
85   [ "$i_errors" = "" ] && i_errors=n
86   [ "$i_errors" = "y" ] && KINDNESS="$KINDNESS --ignoreErrors"
87 fi
88
89 # Run script:
90 EXE_LINK=`basename $PWD`
91 [ "$EXE_BN" != "$EXE_LINK" ] && ln -sf $EXE_BN $EXE_LINK
92
93 case $tol in
94
95   client)
96     ENTITY=$LOCAL_STANDARD_ENDPOINT
97     createRunScript $EXE_LINK $KINDNESS $DEBUG &
98     ;;
99
100   server)
101     SERVER=$LOCAL_STANDARD_ENDPOINT
102     createRunScript $EXE_LINK $KINDNESS $DEBUG &
103     ;;
104
105   balancer)
106     SERVER=$LOCAL_STANDARD_ENDPOINT
107     ENTITY=$EXAMPLE_ENTITY_4_BALANCER
108     createRunScript $EXE_LINK $KINDNESS $DEBUG &
109     ;;
110
111   dummy)
112     createRunScript $EXE_LINK $KINDNESS $DEBUG &
113     ;;
114
115 esac
116
117 echo
118 echo "Created 'run.sh' script !"
119 echo
120