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 " }" >>$customSettingsFile
90 #echo "Created custom settings file $customSettingsFile"
93 echo "ERROR:customSettings file $customSettingsFile already exists for $releaseDir"
96 #echo "Content of custom settings file"
97 #echo "============================================================================"
98 # cat $customSettingsFile
99 #echo "============================================================================"
100 svclogicPropFile="./conf/svclogic.properties"
101 if [ ! -d "${appDir}/yangFiles" ]
103 mkdir -p "${appDir}/yangFiles"
105 if [ ! -d "${appDir}/generatedJS" ]
107 mkdir -p "${appDir}/generatedJS"
110 if [ ! -e "./$svclogicPropFile" ]
112 echo "org.onap.ccsdk.sli.dbtype=jdbc" >$svclogicPropFile
113 echo "org.onap.ccsdk.sli.jdbc.url=jdbc:mysql://{{.Values.config.dbServiceName}}.{{.Release.Namespace}}:3306/sdnctl" >>$svclogicPropFile
114 echo "org.onap.ccsdk.sli.jdbc.database=sdnctl" >>$svclogicPropFile
115 echo "org.onap.ccsdk.sli.jdbc.user=sdnctl" >>$svclogicPropFile
116 echo "org.onap.ccsdk.sli.jdbc.password={{.Values.config.dbSdnctlPassword}}" >>$svclogicPropFile
118 if [ ! -e "${appDir}/flowShareUsers.js" ]
120 echo "module.exports = {\"flowShareUsers\":" >${appDir}/flowShareUsers.js
121 echo " [" >>${appDir}/flowShareUsers.js
122 echo " ]" >>${appDir}/flowShareUsers.js
123 echo "}" >>${appDir}/flowShareUsers.js
125 grep "$releaseDir" ${appDir}/flowShareUsers.js >/dev/null 2>&1
128 num_of_lines=$(cat ${appDir}/flowShareUsers.js|wc -l)
129 if [ $num_of_lines -gt 4 ]
131 content=$(head -n -2 ${appDir}/flowShareUsers.js)
132 echo "${content}," > ${appDir}/flowShareUsers.js
134 content=$(head -n -2 ${appDir}/flowShareUsers.js)
135 echo "$content" > ${appDir}/flowShareUsers.js
137 echo " {" >> ${appDir}/flowShareUsers.js
138 echo " \"name\" : \"$name\"," >> ${appDir}/flowShareUsers.js
139 echo " \"rootDir\" : \"$releaseDir\"" >> ${appDir}/flowShareUsers.js
140 echo " }" >> ${appDir}/flowShareUsers.js
141 echo " ]" >> ${appDir}/flowShareUsers.js
142 echo "}" >> ${appDir}/flowShareUsers.js