[CCSDK-28] populated the seed code for dgbuilder
[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
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
79         echo "ERROR:customSettings file $customSettingsFile already exists for $releaseDir"     
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
89         mkdir -p "${appDir}/yangFiles" 
90 fi
91 if [ ! -d "${appDir}/generatedJS" ]
92 then
93         mkdir -p "${appDir}/generatedJS" 
94 fi
95
96 if [ ! -e "./$svclogicPropFile" ]
97 then
98         echo "org.onap.ccsdk.sli.dbtype=jdbc" >$svclogicPropFile
99         echo "org.onap.ccsdk.sli.jdbc.url=jdbc:mysql://dbhost:3306/sdnctl" >>$svclogicPropFile
100         echo "org.onap.ccsdk.sli.jdbc.database=sdnctl" >>$svclogicPropFile
101         echo "org.onap.ccsdk.sli.jdbc.user=sdnctl" >>$svclogicPropFile
102         echo "org.onap.ccsdk.sli.jdbc.password=gamma" >>$svclogicPropFile
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

© 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