blob: 00d185f71da31ea114b72de216796d7d3a7653b8 [file] [log] [blame]
Chinthakayala, Sheshashailavas (sc2914)d1569972017-08-28 05:25:46 -09001#!/bin/bash
2export PATH=$PATH:.
3appDir=$(pwd)
4if [ "$#" != 3 -a "$#" != 4 ]
5then
6 echo "Usage $0 releaseDir loginId emailAddress [gitLocalRepository]"
7 echo "Note: Specify the gitLocalRepository path if you would want to be able to import flows from your local git repository"
8 exit
9fi
10if [ ! -e "releases" ]
11then
12 mkdir releases
13fi
14releaseDir="$1"
15name="Release $releaseDir"
16loginId="$2"
17emailid="$3"
18dbHost="dbhost"
19dbPort="3306"
20dbName="sdnctl"
21dbUser="sdnctl"
22dbPassword="gamma"
23gitLocalRepository="$4"
24
25lastPort=$(find "releases/" -name "customSettings.js" |xargs grep uiPort|cut -d: -f2|sed -e s/,//|sort|tail -1)
26echo $lastPort|grep uiPort >/dev/null 2>&1
27if [ "$?" == "0" ]
28then
29lastPort=$(find "releases/" -name "customSettings.js" |xargs grep uiPort|cut -d: -f3|sed -e s/,//|sort|tail -1)
30fi
31#echo $lastPort
32if [ "${lastPort}" == "" ]
33then
34 lastPort="3099"
35fi
36let nextPort=$(expr $lastPort+1)
37#echo $nextPort
38if [ ! -e "releases/$releaseDir" ]
39then
40mkdir releases/$releaseDir
41cd releases/$releaseDir
42mkdir flows
43mkdir flows/shared
44mkdir flows/shared/backups
45mkdir html
46mkdir xml
47mkdir lib
48mkdir lib/flows
49mkdir logs
50mkdir conf
51mkdir codecloud
52customSettingsFile="customSettings.js"
53if [ ! -e "./$customSettingsFile" ]
54then
55 echo "module.exports = {" >$customSettingsFile
56 echo " 'name' : '$name'," >>$customSettingsFile
57 echo " 'emailAddress' :'$emailid'," >>$customSettingsFile
58 echo " 'uiPort' :$nextPort," >>$customSettingsFile
59 echo " 'mqttReconnectTime': 15000," >>$customSettingsFile
60 echo " 'serialReconnectTime' : 15000," >>$customSettingsFile
61 echo " 'debugMaxLength': 1000," >>$customSettingsFile
62 echo " 'htmlPath': 'releases/$releaseDir/html/'," >>$customSettingsFile
63 echo " 'xmlPath': 'releases/$releaseDir/xml/'," >>$customSettingsFile
64 echo " 'flowFile' : 'releases/$releaseDir/flows/flows.json'," >>$customSettingsFile
65 echo " 'sharedDir': 'releases/$releaseDir/flows/shared'," >>$customSettingsFile
66 echo " 'userDir' : 'releases/$releaseDir'," >>$customSettingsFile
67 echo " 'httpAuth': {user:'$loginId',pass:'cc03e747a6afbbcbf8be7668acfebee5'}," >>$customSettingsFile
68 echo " 'dbHost': '$dbHost'," >>$customSettingsFile
69 echo " 'dbPort': '$dbPort'," >>$customSettingsFile
70 echo " 'dbName': '$dbName'," >>$customSettingsFile
71 echo " 'dbUser': '$dbUser'," >>$customSettingsFile
72 echo " 'dbPassword': '$dbPassword'," >>$customSettingsFile
73 echo " 'gitLocalRepository': '$gitLocalRepository'" >>$customSettingsFile
74 echo " }" >>$customSettingsFile
75fi
76 #echo "Created custom settings file $customSettingsFile"
77 echo "Done ....."
78else
79 echo "ERROR:customSettings file $customSettingsFile already exists for $releaseDir"
80 exit
81fi
82#echo "Content of custom settings file"
83#echo "============================================================================"
84# cat $customSettingsFile
85#echo "============================================================================"
86svclogicPropFile="./conf/svclogic.properties"
87if [ ! -d "${appDir}/yangFiles" ]
88then
89 mkdir -p "${appDir}/yangFiles"
90fi
91if [ ! -d "${appDir}/generatedJS" ]
92then
93 mkdir -p "${appDir}/generatedJS"
94fi
95
96if [ ! -e "./$svclogicPropFile" ]
97then
98 echo "org.onap.ccsdk.sli.dbtype=jdbc" >$svclogicPropFile
99 echo "org.onap.ccsdk.sli.jdbc.url=jdbc:mysql://dbhost:3306/sdnctl" >>$svclogicPropFile
100 echo "org.onap.ccsdk.sli.jdbc.database=sdnctl" >>$svclogicPropFile
101 echo "org.onap.ccsdk.sli.jdbc.user=sdnctl" >>$svclogicPropFile
102 echo "org.onap.ccsdk.sli.jdbc.password=gamma" >>$svclogicPropFile
103fi
104if [ ! -e "${appDir}/flowShareUsers.js" ]
105then
106 echo "module.exports = {\"flowShareUsers\":" >${appDir}/flowShareUsers.js
107 echo " [" >>${appDir}/flowShareUsers.js
108 echo " ]" >>${appDir}/flowShareUsers.js
109 echo "}" >>${appDir}/flowShareUsers.js
110fi
111grep "$releaseDir" ${appDir}/flowShareUsers.js >/dev/null 2>&1
112if [ "$?" != "0" ]
113then
114 num_of_lines=$(cat ${appDir}/flowShareUsers.js|wc -l)
115 if [ $num_of_lines -gt 4 ]
116 then
117 content=$(head -n -2 ${appDir}/flowShareUsers.js)
118 echo "${content}," > ${appDir}/flowShareUsers.js
119 else
120 content=$(head -n -2 ${appDir}/flowShareUsers.js)
121 echo "$content" > ${appDir}/flowShareUsers.js
122 fi
123 echo " {" >> ${appDir}/flowShareUsers.js
124 echo " \"name\" : \"$name\"," >> ${appDir}/flowShareUsers.js
125 echo " \"rootDir\" : \"$releaseDir\"" >> ${appDir}/flowShareUsers.js
126 echo " }" >> ${appDir}/flowShareUsers.js
127 echo " ]" >> ${appDir}/flowShareUsers.js
128 echo "}" >> ${appDir}/flowShareUsers.js
129fi