blob: eff8485a358e08ce7d2ed63cf4cc3496da1e2c43 [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"
Chinthakayala,Sheshashailavas(sc2914)8f6a6c42018-06-27 16:11:44 +000024restConfUrl="http://localhost:8181/restconf/operations/SLI-API:execute-graph"
25restConfUser="admin"
26restConfPassword="admin"
27formatXML="Y"
28formatJSON="Y"
Chinthakayala, Sheshashailavas (sc2914)d1569972017-08-28 05:25:46 -090029
30lastPort=$(find "releases/" -name "customSettings.js" |xargs grep uiPort|cut -d: -f2|sed -e s/,//|sort|tail -1)
31echo $lastPort|grep uiPort >/dev/null 2>&1
32if [ "$?" == "0" ]
33then
34lastPort=$(find "releases/" -name "customSettings.js" |xargs grep uiPort|cut -d: -f3|sed -e s/,//|sort|tail -1)
35fi
36#echo $lastPort
37if [ "${lastPort}" == "" ]
38then
39 lastPort="3099"
40fi
41let nextPort=$(expr $lastPort+1)
42#echo $nextPort
43if [ ! -e "releases/$releaseDir" ]
44then
45mkdir releases/$releaseDir
46cd releases/$releaseDir
47mkdir flows
48mkdir flows/shared
49mkdir flows/shared/backups
50mkdir html
51mkdir xml
52mkdir lib
53mkdir lib/flows
54mkdir logs
55mkdir conf
56mkdir codecloud
57customSettingsFile="customSettings.js"
58if [ ! -e "./$customSettingsFile" ]
59then
60 echo "module.exports = {" >$customSettingsFile
61 echo " 'name' : '$name'," >>$customSettingsFile
Chinthakayala,Sheshashailavas(sc2914)8f6a6c42018-06-27 16:11:44 +000062 echo " 'loginId' :'$loginId'," >>$customSettingsFile
Chinthakayala, Sheshashailavas (sc2914)d1569972017-08-28 05:25:46 -090063 echo " 'emailAddress' :'$emailid'," >>$customSettingsFile
64 echo " 'uiPort' :$nextPort," >>$customSettingsFile
65 echo " 'mqttReconnectTime': 15000," >>$customSettingsFile
66 echo " 'serialReconnectTime' : 15000," >>$customSettingsFile
67 echo " 'debugMaxLength': 1000," >>$customSettingsFile
68 echo " 'htmlPath': 'releases/$releaseDir/html/'," >>$customSettingsFile
69 echo " 'xmlPath': 'releases/$releaseDir/xml/'," >>$customSettingsFile
70 echo " 'flowFile' : 'releases/$releaseDir/flows/flows.json'," >>$customSettingsFile
71 echo " 'sharedDir': 'releases/$releaseDir/flows/shared'," >>$customSettingsFile
72 echo " 'userDir' : 'releases/$releaseDir'," >>$customSettingsFile
73 echo " 'httpAuth': {user:'$loginId',pass:'cc03e747a6afbbcbf8be7668acfebee5'}," >>$customSettingsFile
74 echo " 'dbHost': '$dbHost'," >>$customSettingsFile
75 echo " 'dbPort': '$dbPort'," >>$customSettingsFile
76 echo " 'dbName': '$dbName'," >>$customSettingsFile
77 echo " 'dbUser': '$dbUser'," >>$customSettingsFile
78 echo " 'dbPassword': '$dbPassword'," >>$customSettingsFile
Chinthakayala,Sheshashailavas(sc2914)8f6a6c42018-06-27 16:11:44 +000079 echo " 'gitLocalRepository': '$gitLocalRepository'," >>$customSettingsFile
80 echo " 'restConfUrl': '$restConfUrl'," >>$customSettingsFile
81 echo " 'restConfUser': '$restConfUser'," >>$customSettingsFile
82 echo " 'restConfPassword': '$restConfPassword'," >>$customSettingsFile
83 echo " 'formatXML': '$formatXML'," >>$customSettingsFile
84 echo " 'formatJSON': '$formatJSON'" >>$customSettingsFile
Chinthakayala, Sheshashailavas (sc2914)d1569972017-08-28 05:25:46 -090085 echo " }" >>$customSettingsFile
86fi
87 #echo "Created custom settings file $customSettingsFile"
88 echo "Done ....."
89else
90 echo "ERROR:customSettings file $customSettingsFile already exists for $releaseDir"
91 exit
92fi
93#echo "Content of custom settings file"
94#echo "============================================================================"
95# cat $customSettingsFile
96#echo "============================================================================"
97svclogicPropFile="./conf/svclogic.properties"
98if [ ! -d "${appDir}/yangFiles" ]
99then
100 mkdir -p "${appDir}/yangFiles"
101fi
102if [ ! -d "${appDir}/generatedJS" ]
103then
104 mkdir -p "${appDir}/generatedJS"
105fi
106
107if [ ! -e "./$svclogicPropFile" ]
108then
109 echo "org.onap.ccsdk.sli.dbtype=jdbc" >$svclogicPropFile
110 echo "org.onap.ccsdk.sli.jdbc.url=jdbc:mysql://dbhost:3306/sdnctl" >>$svclogicPropFile
111 echo "org.onap.ccsdk.sli.jdbc.database=sdnctl" >>$svclogicPropFile
112 echo "org.onap.ccsdk.sli.jdbc.user=sdnctl" >>$svclogicPropFile
113 echo "org.onap.ccsdk.sli.jdbc.password=gamma" >>$svclogicPropFile
114fi
115if [ ! -e "${appDir}/flowShareUsers.js" ]
116then
117 echo "module.exports = {\"flowShareUsers\":" >${appDir}/flowShareUsers.js
118 echo " [" >>${appDir}/flowShareUsers.js
119 echo " ]" >>${appDir}/flowShareUsers.js
120 echo "}" >>${appDir}/flowShareUsers.js
121fi
122grep "$releaseDir" ${appDir}/flowShareUsers.js >/dev/null 2>&1
123if [ "$?" != "0" ]
124then
125 num_of_lines=$(cat ${appDir}/flowShareUsers.js|wc -l)
126 if [ $num_of_lines -gt 4 ]
127 then
128 content=$(head -n -2 ${appDir}/flowShareUsers.js)
129 echo "${content}," > ${appDir}/flowShareUsers.js
130 else
131 content=$(head -n -2 ${appDir}/flowShareUsers.js)
132 echo "$content" > ${appDir}/flowShareUsers.js
133 fi
134 echo " {" >> ${appDir}/flowShareUsers.js
135 echo " \"name\" : \"$name\"," >> ${appDir}/flowShareUsers.js
136 echo " \"rootDir\" : \"$releaseDir\"" >> ${appDir}/flowShareUsers.js
137 echo " }" >> ${appDir}/flowShareUsers.js
138 echo " ]" >> ${appDir}/flowShareUsers.js
139 echo "}" >> ${appDir}/flowShareUsers.js
140fi