BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | export PATH=$PATH:. |
| 3 | appDir=$(pwd) |
| 4 | if [ "$#" != 3 -a "$#" != 4 ] |
| 5 | then |
| 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 |
jmac | 4f76af4 | 2018-03-28 20:36:47 +0000 | [diff] [blame] | 9 | fi |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 10 | if [ ! -e "releases" ] |
| 11 | then |
| 12 | mkdir releases |
| 13 | fi |
| 14 | releaseDir="$1" |
| 15 | name="Release $releaseDir" |
| 16 | loginId="$2" |
| 17 | emailid="$3" |
jmac | 4f76af4 | 2018-03-28 20:36:47 +0000 | [diff] [blame] | 18 | dbHost="{{.Values.config.dbServiceName}}.{{.Release.Namespace}}" |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 19 | dbPort="3306" |
| 20 | dbName="sdnctl" |
| 21 | dbUser="sdnctl" |
jmac | 70863e1 | 2018-05-16 14:53:03 +0000 | [diff] [blame] | 22 | dbPassword="{{.Values.config.dbSdnctlPassword}}" |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 23 | gitLocalRepository="$4" |
| 24 | |
| 25 | lastPort=$(find "releases/" -name "customSettings.js" |xargs grep uiPort|cut -d: -f2|sed -e s/,//|sort|tail -1) |
| 26 | echo $lastPort|grep uiPort >/dev/null 2>&1 |
| 27 | if [ "$?" == "0" ] |
| 28 | then |
| 29 | lastPort=$(find "releases/" -name "customSettings.js" |xargs grep uiPort|cut -d: -f3|sed -e s/,//|sort|tail -1) |
| 30 | fi |
| 31 | #echo $lastPort |
| 32 | if [ "${lastPort}" == "" ] |
| 33 | then |
| 34 | lastPort="3099" |
| 35 | fi |
| 36 | let nextPort=$(expr $lastPort+1) |
| 37 | #echo $nextPort |
| 38 | if [ ! -e "releases/$releaseDir" ] |
| 39 | then |
| 40 | mkdir releases/$releaseDir |
| 41 | cd releases/$releaseDir |
| 42 | mkdir flows |
| 43 | mkdir flows/shared |
| 44 | mkdir flows/shared/backups |
| 45 | mkdir html |
| 46 | mkdir xml |
| 47 | mkdir lib |
| 48 | mkdir lib/flows |
| 49 | mkdir logs |
| 50 | mkdir conf |
| 51 | mkdir codecloud |
| 52 | customSettingsFile="customSettings.js" |
| 53 | if [ ! -e "./$customSettingsFile" ] |
| 54 | then |
| 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 |
| 75 | fi |
| 76 | #echo "Created custom settings file $customSettingsFile" |
| 77 | echo "Done ....." |
| 78 | else |
jmac | 4f76af4 | 2018-03-28 20:36:47 +0000 | [diff] [blame] | 79 | echo "ERROR:customSettings file $customSettingsFile already exists for $releaseDir" |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 80 | exit |
| 81 | fi |
| 82 | #echo "Content of custom settings file" |
| 83 | #echo "============================================================================" |
| 84 | # cat $customSettingsFile |
| 85 | #echo "============================================================================" |
| 86 | svclogicPropFile="./conf/svclogic.properties" |
| 87 | if [ ! -d "${appDir}/yangFiles" ] |
| 88 | then |
jmac | 4f76af4 | 2018-03-28 20:36:47 +0000 | [diff] [blame] | 89 | mkdir -p "${appDir}/yangFiles" |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 90 | fi |
| 91 | if [ ! -d "${appDir}/generatedJS" ] |
| 92 | then |
jmac | 4f76af4 | 2018-03-28 20:36:47 +0000 | [diff] [blame] | 93 | mkdir -p "${appDir}/generatedJS" |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 94 | fi |
| 95 | |
| 96 | if [ ! -e "./$svclogicPropFile" ] |
| 97 | then |
| 98 | echo "org.onap.ccsdk.sli.dbtype=jdbc" >$svclogicPropFile |
jmac | 4f76af4 | 2018-03-28 20:36:47 +0000 | [diff] [blame] | 99 | 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] | 100 | echo "org.onap.ccsdk.sli.jdbc.database=sdnctl" >>$svclogicPropFile |
| 101 | echo "org.onap.ccsdk.sli.jdbc.user=sdnctl" >>$svclogicPropFile |
jmac | 70863e1 | 2018-05-16 14:53:03 +0000 | [diff] [blame] | 102 | echo "org.onap.ccsdk.sli.jdbc.password={{.Values.config.dbSdnctlPassword}}" >>$svclogicPropFile |
BorislavG | 8bfc6cf | 2018-02-27 15:04:26 +0000 | [diff] [blame] | 103 | fi |
| 104 | if [ ! -e "${appDir}/flowShareUsers.js" ] |
| 105 | then |
| 106 | echo "module.exports = {\"flowShareUsers\":" >${appDir}/flowShareUsers.js |
| 107 | echo " [" >>${appDir}/flowShareUsers.js |
| 108 | echo " ]" >>${appDir}/flowShareUsers.js |
| 109 | echo "}" >>${appDir}/flowShareUsers.js |
| 110 | fi |
| 111 | grep "$releaseDir" ${appDir}/flowShareUsers.js >/dev/null 2>&1 |
| 112 | if [ "$?" != "0" ] |
| 113 | then |
| 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 |
| 129 | fi |