| 2084 |
rajveer |
1 |
#!/bin/bash
|
|
|
2 |
# resolve links - $0 may be a softlink
|
|
|
3 |
PRG="$0"
|
|
|
4 |
if [ $# -ne 1 ]
|
|
|
5 |
then
|
|
|
6 |
echo "Error - Invalid Arguments. Please enter itemid of ITEM table, which needs to be phased ot"
|
|
|
7 |
exit
|
|
|
8 |
fi
|
|
|
9 |
ITEM_ID=$1
|
|
|
10 |
echo $ITEM_ID
|
|
|
11 |
|
|
|
12 |
while [ -h "$PRG" ]; do
|
|
|
13 |
ls=`ls -ld "$PRG"`
|
|
|
14 |
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
|
15 |
if expr "$link" : '/.*' > /dev/null; then
|
|
|
16 |
PRG="$link"
|
|
|
17 |
else
|
|
|
18 |
PRG=`dirname "$PRG"`/"$link"
|
|
|
19 |
fi
|
|
|
20 |
done
|
|
|
21 |
|
|
|
22 |
# Get standard environment variables
|
|
|
23 |
PRGDIR=`dirname $(readlink -f "$PRG")`
|
|
|
24 |
|
|
|
25 |
SOLR_DIR=/root/solr/apache-solr-1.4.0/example/exampledocs
|
|
|
26 |
CONTENT_EXPORT_PATH="/var/lib/tomcat6/webapps/export/html/"
|
|
|
27 |
|
|
|
28 |
echo "Updating mysql database for id $ITEM_ID"
|
|
|
29 |
echo "======================================================="
|
|
|
30 |
mysql -uroot -pshop2020 catalog -e"update item set status=0, status_description=\"This item has been phased out\" where id = ${ITEM_ID}"
|
|
|
31 |
|
|
|
32 |
CATALOG_ID=`mysql -uroot -pshop2020 catalog -e"select catalog_item_id from item where id = ${ITEM_ID}"`
|
|
|
33 |
CATALOG_ID=`echo $CATALOG_ID | cut -c17-23`
|
|
|
34 |
#echo $CATALOG_ID
|
|
|
35 |
|
|
|
36 |
COUNT=`mysql -uroot -pshop2020 catalog -e"select count(*) from item where catalog_item_id = ${CATALOG_ID} and status not in(0)"`
|
|
|
37 |
COUNT=`echo $COUNT | cut -c9-20`
|
|
|
38 |
#echo $COUNT
|
|
|
39 |
if [ $COUNT -le 0 ]
|
|
|
40 |
then
|
|
|
41 |
echo "Not a single item is active or out of stock. Removing content from solr and removing item from website."
|
|
|
42 |
|
|
|
43 |
echo "Deleting data from solr for entity id $CATALOG_ID"
|
|
|
44 |
echo "======================================================="
|
|
|
45 |
cd ${SOLR_DIR}
|
|
|
46 |
./deleteOne.sh $CATALOG_ID
|
|
|
47 |
echo "Done deleting data from solr for entity id $CATALOG_ID"
|
|
|
48 |
|
|
|
49 |
|
|
|
50 |
echo "======================================================="
|
|
|
51 |
echo "Removing content snippets for entity id $CATALOG_ID "
|
|
|
52 |
echo "======================================================="
|
|
|
53 |
cd ${CONTENT_EXPORT_PATH}
|
|
|
54 |
rm -rf entities/$CATALOG_ID
|
|
|
55 |
echo "Done removing content for entity id $CATALOG_ID"
|
|
|
56 |
echo "======================================================="
|
|
|
57 |
fi
|
|
|
58 |
|