blob: aaf7a2615cdd7ba33e202ec8da660a81030b33c1 [file] [log] [blame]
vaibhavjayasea9aee02018-08-31 06:22:26 +00001# Copyright © 2018 AT&T, Amdocs, Bell Canada
2#
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
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
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.
14
BorislavG8bfc6cf2018-02-27 15:04:26 +000015#!/bin/bash
16export PATH=$PATH:.
17appDir=$(pwd)
18if [ "$#" != 3 -a "$#" != 4 ]
19then
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"
22 exit
jmac4f76af42018-03-28 20:36:47 +000023fi
BorislavG8bfc6cf2018-02-27 15:04:26 +000024if [ ! -e "releases" ]
25then
26 mkdir releases
27fi
28releaseDir="$1"
29name="Release $releaseDir"
30loginId="$2"
31emailid="$3"
jmac4f76af42018-03-28 20:36:47 +000032dbHost="{{.Values.config.dbServiceName}}.{{.Release.Namespace}}"
BorislavG8bfc6cf2018-02-27 15:04:26 +000033dbPort="3306"
34dbName="sdnctl"
35dbUser="sdnctl"
jmac70863e12018-05-16 14:53:03 +000036dbPassword="{{.Values.config.dbSdnctlPassword}}"
BorislavG8bfc6cf2018-02-27 15:04:26 +000037gitLocalRepository="$4"
38
39lastPort=$(find "releases/" -name "customSettings.js" |xargs grep uiPort|cut -d: -f2|sed -e s/,//|sort|tail -1)
40echo $lastPort|grep uiPort >/dev/null 2>&1
41if [ "$?" == "0" ]
42then
43lastPort=$(find "releases/" -name "customSettings.js" |xargs grep uiPort|cut -d: -f3|sed -e s/,//|sort|tail -1)
44fi
45#echo $lastPort
46if [ "${lastPort}" == "" ]
47then
48 lastPort="3099"
49fi
50let nextPort=$(expr $lastPort+1)
51#echo $nextPort
52if [ ! -e "releases/$releaseDir" ]
53then
54mkdir releases/$releaseDir
55cd releases/$releaseDir
56mkdir flows
57mkdir flows/shared
58mkdir flows/shared/backups
59mkdir html
60mkdir xml
61mkdir lib
62mkdir lib/flows
63mkdir logs
64mkdir conf
65mkdir codecloud
66customSettingsFile="customSettings.js"
67if [ ! -e "./$customSettingsFile" ]
68then
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
89fi
90 #echo "Created custom settings file $customSettingsFile"
91 echo "Done ....."
92else
jmac4f76af42018-03-28 20:36:47 +000093 echo "ERROR:customSettings file $customSettingsFile already exists for $releaseDir"
BorislavG8bfc6cf2018-02-27 15:04:26 +000094 exit
95fi
96#echo "Content of custom settings file"
97#echo "============================================================================"
98# cat $customSettingsFile
99#echo "============================================================================"
100svclogicPropFile="./conf/svclogic.properties"
101if [ ! -d "${appDir}/yangFiles" ]
102then
jmac4f76af42018-03-28 20:36:47 +0000103 mkdir -p "${appDir}/yangFiles"
BorislavG8bfc6cf2018-02-27 15:04:26 +0000104fi
105if [ ! -d "${appDir}/generatedJS" ]
106then
jmac4f76af42018-03-28 20:36:47 +0000107 mkdir -p "${appDir}/generatedJS"
BorislavG8bfc6cf2018-02-27 15:04:26 +0000108fi
109
110if [ ! -e "./$svclogicPropFile" ]
111then
112 echo "org.onap.ccsdk.sli.dbtype=jdbc" >$svclogicPropFile
jmac4f76af42018-03-28 20:36:47 +0000113 echo "org.onap.ccsdk.sli.jdbc.url=jdbc:mysql://{{.Values.config.dbServiceName}}.{{.Release.Namespace}}:3306/sdnctl" >>$svclogicPropFile
BorislavG8bfc6cf2018-02-27 15:04:26 +0000114 echo "org.onap.ccsdk.sli.jdbc.database=sdnctl" >>$svclogicPropFile
115 echo "org.onap.ccsdk.sli.jdbc.user=sdnctl" >>$svclogicPropFile
jmac70863e12018-05-16 14:53:03 +0000116 echo "org.onap.ccsdk.sli.jdbc.password={{.Values.config.dbSdnctlPassword}}" >>$svclogicPropFile
BorislavG8bfc6cf2018-02-27 15:04:26 +0000117fi
118if [ ! -e "${appDir}/flowShareUsers.js" ]
119then
120 echo "module.exports = {\"flowShareUsers\":" >${appDir}/flowShareUsers.js
121 echo " [" >>${appDir}/flowShareUsers.js
122 echo " ]" >>${appDir}/flowShareUsers.js
123 echo "}" >>${appDir}/flowShareUsers.js
124fi
125grep "$releaseDir" ${appDir}/flowShareUsers.js >/dev/null 2>&1
126if [ "$?" != "0" ]
127then
128 num_of_lines=$(cat ${appDir}/flowShareUsers.js|wc -l)
129 if [ $num_of_lines -gt 4 ]
130 then
131 content=$(head -n -2 ${appDir}/flowShareUsers.js)
132 echo "${content}," > ${appDir}/flowShareUsers.js
133 else
134 content=$(head -n -2 ${appDir}/flowShareUsers.js)
135 echo "$content" > ${appDir}/flowShareUsers.js
136 fi
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
143fi