First commit
[anna.git] / example / diameter / launcher / scripts / tests / createPackage.sh
1 #!/bin/ksh
2
3 # Functions & variables
4
5 _exit () {
6    echo
7    echo $1
8    echo
9    exit
10 }
11
12 createRunScript () {
13
14 echo "#!/bin/ksh" > run.sh
15 echo "EXE=\`cat .exe 2>/dev/null\`" >> run.sh
16 echo "STARTED=\`ps -fea | grep \"\$EXE\" | grep -v grep\`" >> run.sh
17 echo "[ \"\$EXE\" != \"\" -a \"\$STARTED\" != \"\" ] && { echo \"Already started!\"; echo \"\$STARTED\" ; exit ; }" >> run.sh
18 echo "pre-start.sh" >> run.sh
19 echo "> launcher.traces" >> run.sh
20 echo "EXE=\"ndl_\`date '+%Y%m%d%H%M%S'\`\"" >> run.sh
21 echo "echo \$EXE > .exe"  >> run.sh
22 #echo "rm \$EXE 2>/dev/null" >> run.sh
23 echo "echo ; echo \"Executable paths:\" ; echo" >> run.sh
24 echo "for i in \`ls execs/.*/*\` ; do echo \$i ; done" >> run.sh
25 echo "echo ; echo \"Input the executable path:\" ; read path ; while test \"\$path\" = \"\" ; do read path ; done" >> run.sh
26 echo "ln -s \$path \$EXE" >> run.sh
27 echo >> run.sh
28 echo -n "\$EXE " >> run.sh
29 for i in `cat args.txt | grep -v "^#"`
30 do
31    echo -n "$i " >> run.sh
32 done
33 echo "&" >> run.sh
34 chmod a+x run.sh
35 rm args.txt
36 }
37
38 createDictionaryPaths () {
39
40 BASE_PROT=commands_baseProtocol.xml
41
42 for i in stacks/*commands*xml
43 do
44    stacks/dependence.sh $i >/dev/null
45    stack=`basename $i`
46    if test "$stack" != "$BASE_PROT"
47    then
48       > .dictionary__${stack}
49       for j in `cat ${i}.dep`
50       do
51          echo "${j},\c" >> .dictionary__${stack}
52       done
53       echo "stacks/$BASE_PROT,stacks/${stack}" >> .dictionary__${stack}
54    fi
55 done
56
57 # Default:
58 ln -s .dictionary__commands_qosControl.xml .dictionary
59 }
60
61 #############
62 # EXECUTION #
63 #############
64 echo
65 echo "------------------"
66 echo "ADL Patch Creation"
67 echo "------------------"
68 echo
69 # Check BASEPJ:
70 [[ "$BASEPJ" = "" ]] && _exit "Run 'configure' before continue (BASEPJ must be defined)"
71
72 echo "BASEPJ=$BASEPJ"
73 echo "Correct ? (y/n) [y]"
74 read correct
75 [[ "$correct" = "" ]] && correct=y
76 [[ "$correct" != "y" ]] && _exit "Load the correct 'configure'"
77
78 # Copy staff:
79 rm -rf tmp
80 mkdir -p tmp
81 echo "Packaging ..."
82 cp /opt/bin/anna/example_diameter_launcher tmp/exec/launcher 
83 cp ../../*sh tmp
84 rm tmp/batch.sh
85 cp ../../*msk tmp
86 cp ../../args.txt tmp
87 mkdir tmp/stacks
88 SETUPS_DIR=../../../../../source/diameter/stack/setups/
89 cp $SETUPS_DIR/*xml tmp/stacks
90 cp $SETUPS_DIR/*sh tmp/stacks
91 cp ../../../../../source/diameter/codec/message.dtd tmp
92 # Prepare:
93 cd tmp
94 createRunScript
95 createDictionaryPaths
96 cd ..
97
98 # Help:
99 echo "Stacks available at '.dictionary__<stack description>', create a symbolic link from '.dictionary'." >> tmp/README
100 echo "Template for xml messages: message.dtd (informative, not actually required by process)" >> tmp/README
101 echo "Start with 'run.sh'" >> tmp/README
102
103 mv tmp ADL-installer
104 tar cvfz ADL-installer.tar.gz ADL-installer
105 rm -rf ADL-installer
106
107 echo
108 echo "Created ADL-installer.tar.gz !"
109 echo
110
111