| 2366 |
rajveer |
1 |
#!/bin/bash
|
|
|
2 |
|
| 3906 |
chandransh |
3 |
if [ $# -lt 1 -o $# -gt 2 ]
|
| 2366 |
rajveer |
4 |
then
|
| 3899 |
chandransh |
5 |
echo "Usage: $0 <Entity Id> [CONTENT | CATALOG]"
|
| 2366 |
rajveer |
6 |
exit
|
|
|
7 |
fi
|
| 3899 |
chandransh |
8 |
|
| 2366 |
rajveer |
9 |
ENTITY_ID=$1
|
|
|
10 |
echo $ENTITY_ID
|
| 3899 |
chandransh |
11 |
|
|
|
12 |
TYPE="CATALOG"
|
|
|
13 |
if [ $# -eq 2 ]
|
|
|
14 |
then
|
|
|
15 |
TYPE=$2
|
|
|
16 |
fi
|
|
|
17 |
|
| 3906 |
chandransh |
18 |
if [ "$TYPE" != "CONTENT" -a "$TYPE" != "CATALOG" ]
|
| 3899 |
chandransh |
19 |
then
|
|
|
20 |
echo "Usage: $0 <Entity Id> [CONTENT | CATALOG]"
|
|
|
21 |
exit
|
|
|
22 |
fi
|
|
|
23 |
|
| 2366 |
rajveer |
24 |
# resolve links - $0 may be a softlink
|
|
|
25 |
PRG="$0"
|
|
|
26 |
|
|
|
27 |
while [ -h "$PRG" ]; do
|
|
|
28 |
ls=`ls -ld "$PRG"`
|
|
|
29 |
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
|
30 |
if expr "$link" : '/.*' > /dev/null; then
|
|
|
31 |
PRG="$link"
|
|
|
32 |
else
|
|
|
33 |
PRG=`dirname "$PRG"`/"$link"
|
|
|
34 |
fi
|
|
|
35 |
done
|
|
|
36 |
|
|
|
37 |
# Get standard environment variables
|
|
|
38 |
PRGDIR=`dirname $(readlink -f "$PRG")`
|
|
|
39 |
|
|
|
40 |
PROJECT_DIR="`dirname ${PRGDIR}`"
|
|
|
41 |
LOG_DIR="/var/log/content-generation"
|
|
|
42 |
DATE=`date +%Y-%b-%d-%Hh%Mm%Ss`
|
|
|
43 |
MYSQL_DUMP="${PRGDIR}/partial-catalog-${DATE}.sql"
|
|
|
44 |
CONTENT_LOG="${LOG_DIR}/content-generation-${DATE}.log"
|
|
|
45 |
SOLR_IRDATA=/var/lib/tomcat6/webapps/export/solr/
|
|
|
46 |
|
| 20670 |
amit.gupta |
47 |
STATIC_SERVERS="static0"
|
| 20669 |
amit.gupta |
48 |
PROD_SERVERS="192.168.166.159 192.168.161.5"
|
| 2366 |
rajveer |
49 |
PROD_ENTITIES_EXPORT_PATH="entities-saholic"
|
|
|
50 |
|
|
|
51 |
ENTITIES_DEST_PATH="/var/lib/tomcat6/webapps/export/html/entities/"
|
|
|
52 |
|
|
|
53 |
MAVEN_REPO="${HOME}/.m2/repository"
|
| 9223 |
amit.gupta |
54 |
M2_CLASSPATH="${MAVEN_REPO}/in/shop2020/ContentStore/1.0-SNAPSHOT/ContentStore-1.0-SNAPSHOT.jar:${MAVEN_REPO}/in/shop2020/ThriftConfig/1.0-SNAPSHOT/ThriftConfig-1.0-SNAPSHOT.jar:${MAVEN_REPO}/in/shop2020/Common/1.0-SNAPSHOT/Common-1.0-SNAPSHOT.jar:${MAVEN_REPO}/readonly/apache/velocity/1.6.3/velocity-1.6.3.jar:${MAVEN_REPO}/readonly/apache/commons-lang/2.4/commons-lang-2.4.jar:${MAVEN_REPO}/readonly/apache/commons-collections/3.2.1/commons-collections-3.2.1.jar:${MAVEN_REPO}/org/apache/thrift/libthrift/0.7.0/libthrift-0.7.0.jar:${MAVEN_REPO}/readonly/slf4j/slf4j-api/1.5.8/slf4j-api-1.5.8.jar:${MAVEN_REPO}/readonly/slf4j/slf4j-simple/1.5.8/slf4j-simple-1.5.8.jar:${MAVEN_REPO}/readonly/apache/commons-logging-api/1.1/commons-logging-api-1.1.jar:${MAVEN_REPO}/readonly/bdb/je/4.1.7/je-4.1.7.jar:${MAVEN_REPO}/readonly/jython/2.5.1/jython-2.5.1.jar:${MAVEN_REPO}/commons-cli/commons-cli/1.2/commons-cli-1.2.jar:${MAVEN_REPO}/readonly/apache/commons-io/1.3.2/commons-io-1.3.2.jar:${MAVEN_REPO}/org/json/json/20090211/json-20090211.jar:${MAVEN_REPO}/org/apache/velocity/velocity-tools/2.0/velocity-tools-2.0.jar:${MAVEN_REPO}/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar:${MAVEN_REPO}/javax/mail/mail/1.4/mail-1.4.jar:${MAVEN_REPO}/commons-net/commons-net/3.0.1/commons-net-3.0.1.jar:${MAVEN_REPO}/commons-vfs/commons-vfs/1.0/commons-vfs-1.0.jar:${MAVEN_REPO}/com/jcraft/jsch/0.1.31/jsch-0.1.31.jar:${MAVEN_REPO}/org/mongodb/mongo-java-driver/2.11.0/mongo-java-driver-2.11.0.jar"
|
| 2366 |
rajveer |
55 |
|
|
|
56 |
echo "Generating content for one entities ${PROJECT_DIR}"
|
|
|
57 |
echo "======================================================="
|
|
|
58 |
cd ${PROJECT_DIR}/ContentStore
|
| 3901 |
chandransh |
59 |
echo "Executing command java -cp ${M2_CLASSPATH} in.shop2020.util.ContentGenerationUtility -u CATALOG -t ONE -e ${ENTITY_ID}"
|
| 3899 |
chandransh |
60 |
java -cp ${M2_CLASSPATH} in.shop2020.util.ContentGenerationUtility -u ${TYPE} -t ONE -e ${ENTITY_ID} > ${CONTENT_LOG}
|
| 2366 |
rajveer |
61 |
echo "======================================================="
|
|
|
62 |
echo "Content generation completed"
|
| 11794 |
amit.gupta |
63 |
mongodump -d CONTENT -c siteContent -q {"_id":${ENTITY_ID}} -o /tmp
|
| 3899 |
chandransh |
64 |
for PROD_SERVER in $PROD_SERVERS
|
|
|
65 |
do
|
| 11796 |
amit.gupta |
66 |
echo "Mongo restore on server ${PROD_SERVER}"
|
| 11800 |
amit.gupta |
67 |
mongo CONTENT -host ${PROD_SERVER} --quiet --eval "db.siteContent.remove({"_id":${ENTITY_ID}})" --shell
|
| 11799 |
amit.gupta |
68 |
mongorestore -host ${PROD_SERVER} -d CONTENT -c siteContent /tmp/CONTENT/siteContent.bson
|
| 3899 |
chandransh |
69 |
echo "Copying generated content to production server ${PROD_SERVER}"
|
|
|
70 |
echo "======================================================="
|
|
|
71 |
#Update entities on staging using the entities-shop2020 direcotry
|
|
|
72 |
cd /var/lib/tomcat6/webapps/export/html
|
|
|
73 |
scp -r ${PROD_ENTITIES_EXPORT_PATH}/${ENTITY_ID} ${PROD_SERVER}:${ENTITIES_DEST_PATH}
|
| 2366 |
rajveer |
74 |
|
| 3899 |
chandransh |
75 |
#Update solr data on staging and production servers
|
|
|
76 |
scp ${SOLR_IRDATA}${ENTITY_ID}_irdata_solr.xml ${PROD_SERVER}:${SOLR_IRDATA}
|
| 2366 |
rajveer |
77 |
|
| 3899 |
chandransh |
78 |
echo "Done copying content to production server ${PROD_SERVER}"
|
|
|
79 |
echo "======================================================="
|
| 2366 |
rajveer |
80 |
|
| 3899 |
chandransh |
81 |
echo "Posting data to solr on prod server ${PROD_SERVER}"
|
|
|
82 |
echo "======================================================="
|
| 3908 |
chandransh |
83 |
ssh ${PROD_SERVER} "cd /root/solr/example/exampledocs; java -jar post.jar ${SOLR_IRDATA}${ENTITY_ID}_irdata_solr.xml"
|
| 3899 |
chandransh |
84 |
echo "Posted data to solr on prod server ${PROD_SERVER}"
|
|
|
85 |
echo "======================================================="
|
| 4257 |
rajveer |
86 |
echo "Removing cached snippets for the server"
|
| 10832 |
amit.gupta |
87 |
wget --user=saholic --password=shop2020 http://${PROD_SERVER}:8080/cache-admin/ProductPageSnippets?_method=delete -O /tmp/cacheadmin.html
|
|
|
88 |
wget --user=saholic --password=shop2020 http://${PROD_SERVER}:8080/cache-admin/SearchSnippets?_method=delete -O /tmp/cacheadmin.html
|
| 10576 |
amit.gupta |
89 |
# wget --user=saholic --password=shop2020 http://${PROD_SERVER}:8080/cache-admin/HomePageSnippets?_method=delete -O /tmp/cacheadmin.html
|
| 10832 |
amit.gupta |
90 |
wget --user=saholic --password=shop2020 http://${PROD_SERVER}:8080/cache-admin/ShowcasePageSnippets?_method=delete -O /tmp/cacheadmin.html
|
|
|
91 |
wget --user=saholic --password=shop2020 http://${PROD_SERVER}:8080/cache-admin/CategorySnippets?_method=delete -O /tmp/cacheadmin.html
|
| 3899 |
chandransh |
92 |
done
|
| 6258 |
rajveer |
93 |
|
|
|
94 |
for STATIC_SERVER in $STATIC_SERVERS
|
|
|
95 |
do
|
|
|
96 |
scp -r /var/lib/tomcat6/webapps/export/partners/saholicmobilephones.xml ${STATIC_SERVER}:/var/www/static.saholic.com/partners/saholicmobilephones.xml
|
|
|
97 |
done
|