Rev 2175 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
#!/bin/bash# resolve links - $0 may be a softlinkPRG="$0"if [ $# -ne 1 ]thenecho "Error - Invalid Arguments. Please enter itemid of ITEM table, which needs to be phased ot"exitfiITEM_ID=$1echo $ITEM_IDwhile [ -h "$PRG" ]; dols=`ls -ld "$PRG"`link=`expr "$ls" : '.*-> \(.*\)$'`if expr "$link" : '/.*' > /dev/null; thenPRG="$link"elsePRG=`dirname "$PRG"`/"$link"fidone# Get standard environment variablesPRGDIR=`dirname $(readlink -f "$PRG")`SOLR_DIR=/root/solr/apache-solr-1.4.0/example/exampledocsCONTENT_EXPORT_PATH="/var/lib/tomcat6/webapps/export/html/"echo "Updating mysql database for id $ITEM_ID"echo "======================================================="mysql -uroot -pshop2020 catalog -e"update item set status=0, status_description=\"This item has been phased out\" where id = ${ITEM_ID}"CATALOG_ID=`mysql -uroot -pshop2020 catalog -e"select catalog_item_id from item where id = ${ITEM_ID}"`CATALOG_ID=`echo $CATALOG_ID | cut -c17-23`#echo $CATALOG_IDCOUNT=`mysql -uroot -pshop2020 catalog -e"select count(*) from item where catalog_item_id = ${CATALOG_ID} and status not in(0)"`COUNT=`echo $COUNT | cut -c9-20`#echo $COUNTif [ $COUNT -le 0 ]thenecho "Not a single item is active or out of stock. Removing content from solr and removing item from website."echo "Deleting data from solr for entity id $CATALOG_ID"echo "======================================================="cd ${SOLR_DIR}./deleteOne.sh $CATALOG_IDecho "Done deleting data from solr for entity id $CATALOG_ID"echo "======================================================="echo "Removing content snippets for entity id $CATALOG_ID "echo "======================================================="cd ${CONTENT_EXPORT_PATH}rm -rf entities/$CATALOG_IDecho "Done removing content for entity id $CATALOG_ID"echo "======================================================="fi