blob: 961792be3f18972131d23a302b085e27655aa99e [file] [log] [blame]
BorislavG8bfc6cf2018-02-27 15:04:26 +00001#!/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
jmac4f76af42018-03-28 20:36:47 +00009fi
BorislavG8bfc6cf2018-02-27 15:04:26 +000010if [ ! -e "releases" ]
11then
12 mkdir releases
13fi
14releaseDir="$1"
15name="Release $releaseDir"
16loginId="$2"
17emailid="$3"
jmac4f76af42018-03-28 20:36:47 +000018dbHost="{{.Values.config.dbServiceName}}.{{.Release.Namespace}}"
BorislavG8bfc6cf2018-02-27 15:04:26 +000019dbPort="3306"
20dbName="sdnctl"
21dbUser="sdnctl"
jmac70863e12018-05-16 14:53:03 +000022dbPassword="{{.Values.config.dbSdnctlPassword}}"
BorislavG8bfc6cf2018-02-27 15:04:26 +000023gitLocalRepository="$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
jmac4f76af42018-03-28 20:36:47 +000079 echo "ERROR:customSettings file $customSettingsFile already exists for $releaseDir"
BorislavG8bfc6cf2018-02-27 15:04:26 +000080 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
jmac4f76af42018-03-28 20:36:47 +000089 mkdir -p "${appDir}/yangFiles"
BorislavG8bfc6cf2018-02-27 15:04:26 +000090fi
91if [ ! -d "${appDir}/generatedJS" ]
92then
jmac4f76af42018-03-28 20:36:47 +000093 mkdir -p "${appDir}/generatedJS"
BorislavG8bfc6cf2018-02-27 15:04:26 +000094fi
95
96if [ ! -e "./$svclogicPropFile" ]
97then
98 echo "org.onap.ccsdk.sli.dbtype=jdbc" >$svclogicPropFile
jmac4f76af42018-03-28 20:36:47 +000099 echo "org.onap.ccsdk.sli.jdbc.url=jdbc:mysql://{{.Values.config.dbServiceName}}.{{.Release.Namespace}}:3306/sdnctl" >>$svclogicPropFile
BorislavG8bfc6cf2018-02-27 15:04:26 +0000100 echo "org.onap.ccsdk.sli.jdbc.database=sdnctl" >>$svclogicPropFile
101 echo "org.onap.ccsdk.sli.jdbc.user=sdnctl" >>$svclogicPropFile
jmac70863e12018-05-16 14:53:03 +0000102 echo "org.onap.ccsdk.sli.jdbc.password={{.Values.config.dbSdnctlPassword}}" >>$svclogicPropFile
BorislavG8bfc6cf2018-02-27 15:04:26 +0000103fi
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