1 # Copyright © 2018 AT&T, Amdocs, Bell Canada
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
18 if [ "$#" != 3 -a "$#" != 4 ]
20 echo "Usage $0 releaseDir loginId emailAddress [gitLocalRepository]"
21 echo "Note: Specify the gitLocalRepository path if you would want to be able to import flows from your local git repository"
24 if [ ! -e "releases" ]
29 name="Release $releaseDir"
32 dbHost="{{.Values.config.dbServiceName}}.{{.Release.Namespace}}"
36 dbPassword="{{.Values.config.dbSdnctlPassword}}"
37 gitLocalRepository="$4"
39 lastPort=$(find "releases/" -name "customSettings.js" |xargs grep uiPort|cut -d: -f2|sed -e s/,//|sort|tail -1)
40 echo $lastPort|grep uiPort >/dev/null 2>&1
43 lastPort=$(find "releases/" -name "customSettings.js" |xargs grep uiPort|cut -d: -f3|sed -e s/,//|sort|tail -1)
46 if [ "${lastPort}" == "" ]
50 let nextPort=$(expr $lastPort+1)
52 if [ ! -e "releases/$releaseDir" ]
54 mkdir releases/$releaseDir
55 cd releases/$releaseDir
58 mkdir flows/shared/backups
66 customSettingsFile="customSettings.js"
67 if [ ! -e "./$customSettingsFile" ]
69 echo "module.exports = {" >$customSettingsFile
70 echo " 'name' : '$name'," >>$customSettingsFile
71 echo " 'emailAddress' :'$emailid'," >>$customSettingsFile
72 echo " 'uiPort' :$nextPort," >>$customSettingsFile
73 echo " 'mqttReconnectTime': 15000," >>$customSettingsFile
74 echo " 'serialReconnectTime' : 15000," >>$customSettingsFile
75 echo " 'debugMaxLength': 1000," >>$customSettingsFile
76 echo " 'htmlPath': 'releases/$releaseDir/html/'," >>$customSettingsFile
77 echo " 'xmlPath': 'releases/$releaseDir/xml/'," >>$customSettingsFile
78 echo " 'flowFile' : 'releases/$releaseDir/flows/flows.json'," >>$customSettingsFile
79 echo " 'sharedDir': 'releases/$releaseDir/flows/shared'," >>$customSettingsFile
80 echo " 'userDir' : 'releases/$releaseDir'," >>$customSettingsFile
81 echo " 'httpAuth': {user:'$loginId',pass:'cc03e747a6afbbcbf8be7668acfebee5'}," >>$customSettingsFile
82 echo " 'dbHost': '$dbHost'," >>$customSettingsFile
83 echo " 'dbPort': '$dbPort'," >>$customSettingsFile
84 echo " 'dbName': '$dbName'," >>$customSettingsFile
85 echo " 'dbUser': '$dbUser'," >>$customSettingsFile
86 echo " 'dbPassword': '$dbPassword'," >>$customSettingsFile
87 echo " 'gitLocalRepository': '$gitLocalRepository'" >>$customSettingsFile
88 echo " 'restConfUrl': '$restConfUrl'," >>$customSettingsFile
89 echo " 'restConfUser': '$restConfUser'," >>$customSettingsFile
90 echo " 'restConfPassword': '$restConfPassword'," >>$customSettingsFile
91 echo " 'formatXML': '$formatXML'," >>$customSettingsFile
92 echo " 'formatJSON': '$formatJSON'," >>$customSettingsFile
93 echo " 'enableHttps': true" >>$customSettingsFile
94 echo " }" >>$customSettingsFile
96 #echo "Created custom settings file $customSettingsFile"
99 echo "ERROR:customSettings file $customSettingsFile already exists for $releaseDir"
102 #echo "Content of custom settings file"
103 #echo "============================================================================"
104 # cat $customSettingsFile
105 #echo "============================================================================"
106 svclogicPropFile="./conf/svclogic.properties"
107 if [ ! -d "${appDir}/yangFiles" ]
109 mkdir -p "${appDir}/yangFiles"
111 if [ ! -d "${appDir}/generatedJS" ]
113 mkdir -p "${appDir}/generatedJS"
116 if [ ! -e "./$svclogicPropFile" ]
118 echo "org.onap.ccsdk.sli.dbtype=jdbc" >$svclogicPropFile
119 echo "org.onap.ccsdk.sli.jdbc.url=jdbc:mysql://{{.Values.config.dbServiceName}}.{{.Release.Namespace}}:3306/sdnctl" >>$svclogicPropFile
120 echo "org.onap.ccsdk.sli.jdbc.database=sdnctl" >>$svclogicPropFile
121 echo "org.onap.ccsdk.sli.jdbc.user=sdnctl" >>$svclogicPropFile
122 echo "org.onap.ccsdk.sli.jdbc.password={{.Values.config.dbSdnctlPassword}}" >>$svclogicPropFile
124 if [ ! -e "${appDir}/flowShareUsers.js" ]
126 echo "module.exports = {\"flowShareUsers\":" >${appDir}/flowShareUsers.js
127 echo " [" >>${appDir}/flowShareUsers.js
128 echo " ]" >>${appDir}/flowShareUsers.js
129 echo "}" >>${appDir}/flowShareUsers.js
131 grep "$releaseDir" ${appDir}/flowShareUsers.js >/dev/null 2>&1
134 num_of_lines=$(cat ${appDir}/flowShareUsers.js|wc -l)
135 if [ $num_of_lines -gt 4 ]
137 content=$(head -n -2 ${appDir}/flowShareUsers.js)
138 echo "${content}," > ${appDir}/flowShareUsers.js
140 content=$(head -n -2 ${appDir}/flowShareUsers.js)
141 echo "$content" > ${appDir}/flowShareUsers.js
143 echo " {" >> ${appDir}/flowShareUsers.js
144 echo " \"name\" : \"$name\"," >> ${appDir}/flowShareUsers.js
145 echo " \"rootDir\" : \"$releaseDir\"" >> ${appDir}/flowShareUsers.js
146 echo " }" >> ${appDir}/flowShareUsers.js
147 echo " ]" >> ${appDir}/flowShareUsers.js
148 echo "}" >> ${appDir}/flowShareUsers.js