Allow separate stacks registration through services operation
[anna.git] / source / diameter / stack / setups / makeAutonomous.sh
1 #!/bin/bash
2
3 #############
4 # VARIABLES #
5 #############
6 BASE_PROTOCOL_XML=commands_baseProtocol.xml
7
8 #############
9 # FUNCTIONS #
10 #############
11 _exit () {
12   echo
13   echo $1
14   echo
15   exit 1
16 }
17
18 usage () {
19   echo
20   echo
21   echo "Usage: makeAutonomous.sh <incomplete dictionary> <stack management executable>"
22   echo
23   echo "       For example:"
24   echo "          makeAutonomous.sh commands_qosControl.xml ./stack-mgmt"
25   echo
26   echo "       A new dictionary will be created: autonomous.commands_qosControl.xml"
27   _exit
28 }
29
30 #############
31 # EXECUTION #
32 #############
33 [ -z "$2" ] && usage
34
35 COMMAND_XML=$1
36 [ "$COMMAND_XML" = "$BASE_PROTOCOL_XML" ] && _exit "$COMMAND_XML skipped !"
37
38 STACK_EXE=`readlink -f $2`
39 target=autonomous.${COMMAND_XML}
40 cd `dirname $0`
41
42 echo -n "Creating $target ... "
43 0>.dict_list
44 ./dependence.sh $COMMAND_XML >/dev/null
45 for i in `cat ${COMMAND_XML}.dep`; do echo -n "$i " >> .dict_list ; done
46 echo "$BASE_PROTOCOL_XML $COMMAND_XML" >> .dict_list
47
48 # Create autonomous dictionary:
49 $STACK_EXE `cat .dict_list` >/dev/null
50 mv result.xml $target
51
52 # Cleanup:
53 rm -f *.dep
54 rm -f example_diameter_stackManagement.trace*
55 rm .dict_list
56 echo "Done!"
57