Align requestID, subrequestID for DMAAP msgs
[ccsdk/distribution.git] / dgbuilder / createReleaseDir.sh
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
9 fi 
10 if [ ! -e "releases" ]
11 then
12         mkdir releases
13 fi
14 releaseDir="$1"
15 name="Release $releaseDir"
16 loginId="$2"
17 emailid="$3"
18 dbHost="dbhost"
19 dbPort="3306"
20 dbName="sdnctl"
21 dbUser="sdnctl"
22 dbPassword="gamma"
23 gitLocalRepository="$4"
24 restConfUrl="http://localhost:8181/restconf/operations/SLI-API:execute-graph"
25 restConfUser="admin"
26 restConfPassword="admin"
27 formatXML="Y"
28 formatJSON="Y"
29
30 lastPort=$(find "releases/" -name "customSettings.js" |xargs grep uiPort|cut -d: -f2|sed -e s/,//|sort|tail -1)
31 echo $lastPort|grep uiPort >/dev/null 2>&1
32 if [ "$?" == "0" ]
33 then
34 lastPort=$(find "releases/" -name "customSettings.js" |xargs grep uiPort|cut -d: -f3|sed -e s/,//|sort|tail -1)
35 fi
36 #echo $lastPort
37 if [ "${lastPort}" == "" ]
38 then
39         lastPort="3099"
40 fi
41 let nextPort=$(expr $lastPort+1)
42 #echo $nextPort
43 if [ ! -e "releases/$releaseDir" ]
44 then
45 mkdir releases/$releaseDir
46 cd releases/$releaseDir
47 mkdir flows
48 mkdir flows/shared
49 mkdir flows/shared/backups
50 mkdir html
51 mkdir xml
52 mkdir lib
53 mkdir lib/flows
54 mkdir logs
55 mkdir conf
56 mkdir codecloud
57 customSettingsFile="customSettings.js"
58 if [ ! -e "./$customSettingsFile" ]
59 then
60         echo "module.exports = {" >$customSettingsFile
61         echo "          'name' : '$name'," >>$customSettingsFile
62         echo "          'loginId' :'$loginId'," >>$customSettingsFile
63         echo "          'emailAddress' :'$emailid'," >>$customSettingsFile
64         echo "          'uiPort' :$nextPort," >>$customSettingsFile
65         echo "          'mqttReconnectTime': 15000," >>$customSettingsFile
66         echo "          'serialReconnectTime' : 15000,"  >>$customSettingsFile
67         echo "          'debugMaxLength': 1000," >>$customSettingsFile
68         echo "          'htmlPath': 'releases/$releaseDir/html/'," >>$customSettingsFile
69         echo "          'xmlPath': 'releases/$releaseDir/xml/'," >>$customSettingsFile
70         echo "          'flowFile' : 'releases/$releaseDir/flows/flows.json'," >>$customSettingsFile
71         echo "          'sharedDir': 'releases/$releaseDir/flows/shared'," >>$customSettingsFile
72         echo "          'userDir' : 'releases/$releaseDir'," >>$customSettingsFile
73         echo "          'httpAuth': {user:'$loginId',pass:'cc03e747a6afbbcbf8be7668acfebee5'}," >>$customSettingsFile
74         echo "          'dbHost': '$dbHost'," >>$customSettingsFile
75         echo "          'dbPort': '$dbPort'," >>$customSettingsFile
76         echo "          'dbName': '$dbName'," >>$customSettingsFile
77         echo "          'dbUser': '$dbUser'," >>$customSettingsFile
78         echo "          'dbPassword': '$dbPassword'," >>$customSettingsFile
79         echo "          'gitLocalRepository': '$gitLocalRepository'," >>$customSettingsFile
80         echo "          'restConfUrl': '$restConfUrl'," >>$customSettingsFile
81         echo "          'restConfUser': '$restConfUser'," >>$customSettingsFile
82         echo "          'restConfPassword': '$restConfPassword'," >>$customSettingsFile
83         echo "          'formatXML': '$formatXML'," >>$customSettingsFile
84         echo "          'formatJSON': '$formatJSON'," >>$customSettingsFile
85         echo "          'enableHttps': true" >>$customSettingsFile
86         echo "          }" >>$customSettingsFile
87 fi
88         #echo "Created custom settings  file $customSettingsFile"
89         echo "Done ....."
90 else
91         echo "ERROR:customSettings file $customSettingsFile already exists for $releaseDir"     
92         exit
93 fi
94 #echo "Content of custom settings file"
95 #echo "============================================================================"
96 #       cat $customSettingsFile
97 #echo "============================================================================"
98 svclogicPropFile="./conf/svclogic.properties"
99 if [ ! -d "${appDir}/yangFiles" ]
100 then
101         mkdir -p "${appDir}/yangFiles" 
102 fi
103 if [ ! -d "${appDir}/generatedJS" ]
104 then
105         mkdir -p "${appDir}/generatedJS" 
106 fi
107
108 if [ ! -e "./$svclogicPropFile" ]
109 then
110         echo "org.onap.ccsdk.sli.dbtype=jdbc" >$svclogicPropFile
111         echo "org.onap.ccsdk.sli.jdbc.url=jdbc:mysql://dbhost:3306/sdnctl" >>$svclogicPropFile
112         echo "org.onap.ccsdk.sli.jdbc.database=sdnctl" >>$svclogicPropFile
113         echo "org.onap.ccsdk.sli.jdbc.user=sdnctl" >>$svclogicPropFile
114         echo "org.onap.ccsdk.sli.jdbc.password=gamma" >>$svclogicPropFile
115 fi
116 if [ ! -e "${appDir}/flowShareUsers.js" ]
117 then
118         echo "module.exports = {\"flowShareUsers\":" >${appDir}/flowShareUsers.js
119         echo "  [" >>${appDir}/flowShareUsers.js
120         echo "  ]" >>${appDir}/flowShareUsers.js
121         echo "}" >>${appDir}/flowShareUsers.js
122 fi
123 grep "$releaseDir" ${appDir}/flowShareUsers.js >/dev/null 2>&1
124 if [ "$?" != "0" ]
125 then
126         num_of_lines=$(cat ${appDir}/flowShareUsers.js|wc -l)
127         if [ $num_of_lines -gt 4 ]
128         then
129                 content=$(head -n -2 ${appDir}/flowShareUsers.js)
130                 echo "${content}," > ${appDir}/flowShareUsers.js
131         else
132                 content=$(head -n -2 ${appDir}/flowShareUsers.js)
133                 echo "$content" > ${appDir}/flowShareUsers.js
134         fi
135         echo "  {" >> ${appDir}/flowShareUsers.js
136         echo "          \"name\" : \"$name\"," >> ${appDir}/flowShareUsers.js
137         echo "          \"rootDir\" : \"$releaseDir\"" >> ${appDir}/flowShareUsers.js
138         echo "  }" >> ${appDir}/flowShareUsers.js
139         echo "  ]" >> ${appDir}/flowShareUsers.js
140         echo "}" >> ${appDir}/flowShareUsers.js
141 fi

© 2017 ONAP. Copyright © The Linux Foundation ®. All Rights Reserved.
The Linux Foundation has registered trademarks and uses trademarks.
For a list of trademarks of The Linux Foundation, please see our Trademark Usage page.
Linux is a registered trademark of Linus Torvalds.
Privacy Policy and Terms of Use