Merge "Change RANGE_RULE table to support multiple ranges"
[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 "          }" >>$customSettingsFile
86 fi
87         #echo "Created custom settings  file $customSettingsFile"
88         echo "Done ....."
89 else
90         echo "ERROR:customSettings file $customSettingsFile already exists for $releaseDir"     
91         exit
92 fi
93 #echo "Content of custom settings file"
94 #echo "============================================================================"
95 #       cat $customSettingsFile
96 #echo "============================================================================"
97 svclogicPropFile="./conf/svclogic.properties"
98 if [ ! -d "${appDir}/yangFiles" ]
99 then
100         mkdir -p "${appDir}/yangFiles" 
101 fi
102 if [ ! -d "${appDir}/generatedJS" ]
103 then
104         mkdir -p "${appDir}/generatedJS" 
105 fi
106
107 if [ ! -e "./$svclogicPropFile" ]
108 then
109         echo "org.onap.ccsdk.sli.dbtype=jdbc" >$svclogicPropFile
110         echo "org.onap.ccsdk.sli.jdbc.url=jdbc:mysql://dbhost:3306/sdnctl" >>$svclogicPropFile
111         echo "org.onap.ccsdk.sli.jdbc.database=sdnctl" >>$svclogicPropFile
112         echo "org.onap.ccsdk.sli.jdbc.user=sdnctl" >>$svclogicPropFile
113         echo "org.onap.ccsdk.sli.jdbc.password=gamma" >>$svclogicPropFile
114 fi
115 if [ ! -e "${appDir}/flowShareUsers.js" ]
116 then
117         echo "module.exports = {\"flowShareUsers\":" >${appDir}/flowShareUsers.js
118         echo "  [" >>${appDir}/flowShareUsers.js
119         echo "  ]" >>${appDir}/flowShareUsers.js
120         echo "}" >>${appDir}/flowShareUsers.js
121 fi
122 grep "$releaseDir" ${appDir}/flowShareUsers.js >/dev/null 2>&1
123 if [ "$?" != "0" ]
124 then
125         num_of_lines=$(cat ${appDir}/flowShareUsers.js|wc -l)
126         if [ $num_of_lines -gt 4 ]
127         then
128                 content=$(head -n -2 ${appDir}/flowShareUsers.js)
129                 echo "${content}," > ${appDir}/flowShareUsers.js
130         else
131                 content=$(head -n -2 ${appDir}/flowShareUsers.js)
132                 echo "$content" > ${appDir}/flowShareUsers.js
133         fi
134         echo "  {" >> ${appDir}/flowShareUsers.js
135         echo "          \"name\" : \"$name\"," >> ${appDir}/flowShareUsers.js
136         echo "          \"rootDir\" : \"$releaseDir\"" >> ${appDir}/flowShareUsers.js
137         echo "  }" >> ${appDir}/flowShareUsers.js
138         echo "  ]" >> ${appDir}/flowShareUsers.js
139         echo "}" >> ${appDir}/flowShareUsers.js
140 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