vaibhavjayas | ea9aee0 | 2018-08-31 06:22:26 +0000 | [diff] [blame] | 1 | # 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 | |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 15 | #!/bin/bash |
| 16 | export PATH=$PATH:. |
| 17 | appDir=$(pwd) |
| 18 | if [ "$#" != 3 -a "$#" != 4 ] |
| 19 | then |
| 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 |
jmac | 4f76af4 | 2018-03-28 20:36:47 +0000 | [diff] [blame] | 23 | fi |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 24 | if [ ! -e "releases" ] |
| 25 | then |
| 26 | mkdir releases |
| 27 | fi |
| 28 | releaseDir="$1" |
| 29 | name="Release $releaseDir" |
| 30 | loginId="$2" |
| 31 | emailid="$3" |
jmac | 4f76af4 | 2018-03-28 20:36:47 +0000 | [diff] [blame] | 32 | dbHost="{{.Values.config.dbServiceName}}.{{.Release.Namespace}}" |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 33 | dbPort="3306" |
| 34 | dbName="sdnctl" |
| 35 | dbUser="sdnctl" |
jmac | 70863e1 | 2018-05-16 14:53:03 +0000 | [diff] [blame] | 36 | dbPassword="{{.Values.config.dbSdnctlPassword}}" |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 37 | gitLocalRepository="$4" |
| 38 | |
| 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 |
| 41 | if [ "$?" == "0" ] |
| 42 | then |
| 43 | lastPort=$(find "releases/" -name "customSettings.js" |xargs grep uiPort|cut -d: -f3|sed -e s/,//|sort|tail -1) |
| 44 | fi |
| 45 | #echo $lastPort |
| 46 | if [ "${lastPort}" == "" ] |
| 47 | then |
| 48 | lastPort="3099" |
| 49 | fi |
| 50 | let nextPort=$(expr $lastPort+1) |
| 51 | #echo $nextPort |
| 52 | if [ ! -e "releases/$releaseDir" ] |
| 53 | then |
| 54 | mkdir releases/$releaseDir |
| 55 | cd releases/$releaseDir |
| 56 | mkdir flows |
| 57 | mkdir flows/shared |
| 58 | mkdir flows/shared/backups |
| 59 | mkdir html |
| 60 | mkdir xml |
| 61 | mkdir lib |
| 62 | mkdir lib/flows |
| 63 | mkdir logs |
| 64 | mkdir conf |
| 65 | mkdir codecloud |
| 66 | customSettingsFile="customSettings.js" |
| 67 | if [ ! -e "./$customSettingsFile" ] |
| 68 | then |
| 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 |
| 89 | fi |
| 90 | #echo "Created custom settings file $customSettingsFile" |
| 91 | echo "Done ....." |
| 92 | else |
jmac | 4f76af4 | 2018-03-28 20:36:47 +0000 | [diff] [blame] | 93 | echo "ERROR:customSettings file $customSettingsFile already exists for $releaseDir" |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 94 | exit |
| 95 | fi |
| 96 | #echo "Content of custom settings file" |
| 97 | #echo "============================================================================" |
| 98 | # cat $customSettingsFile |
| 99 | #echo "============================================================================" |
| 100 | svclogicPropFile="./conf/svclogic.properties" |
| 101 | if [ ! -d "${appDir}/yangFiles" ] |
| 102 | then |
jmac | 4f76af4 | 2018-03-28 20:36:47 +0000 | [diff] [blame] | 103 | mkdir -p "${appDir}/yangFiles" |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 104 | fi |
| 105 | if [ ! -d "${appDir}/generatedJS" ] |
| 106 | then |
jmac | 4f76af4 | 2018-03-28 20:36:47 +0000 | [diff] [blame] | 107 | mkdir -p "${appDir}/generatedJS" |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 108 | fi |
| 109 | |
| 110 | if [ ! -e "./$svclogicPropFile" ] |
| 111 | then |
| 112 | echo "org.onap.ccsdk.sli.dbtype=jdbc" >$svclogicPropFile |
jmac | 4f76af4 | 2018-03-28 20:36:47 +0000 | [diff] [blame] | 113 | echo "org.onap.ccsdk.sli.jdbc.url=jdbc:mysql://{{.Values.config.dbServiceName}}.{{.Release.Namespace}}:3306/sdnctl" >>$svclogicPropFile |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 114 | echo "org.onap.ccsdk.sli.jdbc.database=sdnctl" >>$svclogicPropFile |
| 115 | echo "org.onap.ccsdk.sli.jdbc.user=sdnctl" >>$svclogicPropFile |
jmac | 70863e1 | 2018-05-16 14:53:03 +0000 | [diff] [blame] | 116 | echo "org.onap.ccsdk.sli.jdbc.password={{.Values.config.dbSdnctlPassword}}" >>$svclogicPropFile |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 117 | fi |
| 118 | if [ ! -e "${appDir}/flowShareUsers.js" ] |
| 119 | then |
| 120 | echo "module.exports = {\"flowShareUsers\":" >${appDir}/flowShareUsers.js |
| 121 | echo " [" >>${appDir}/flowShareUsers.js |
| 122 | echo " ]" >>${appDir}/flowShareUsers.js |
| 123 | echo "}" >>${appDir}/flowShareUsers.js |
| 124 | fi |
| 125 | grep "$releaseDir" ${appDir}/flowShareUsers.js >/dev/null 2>&1 |
| 126 | if [ "$?" != "0" ] |
| 127 | then |
| 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 |
| 143 | fi |