Last active
December 10, 2015 15:17
-
-
Save RaimondKempees/48a16a70ccbf74a2098e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
ACTION=$1 | |
INSTANCE_NAME=$2 | |
AUTOSTART=$3 | |
#Change the two variables below to suit your situation | |
BASE_PACKAGE_LOCATION="http://distribution-server.domain.net/fredhopper/fredhopper-st-base-1.0.0.zip" | |
FREDHOPPER_ST_BASE_FILE="fredhopper-st-base-1.0.0.zip" | |
DA=deployment-agent | |
download() { | |
echo "downloading base package from $BASE_PACKAGE_LOCATION" | |
curl -O $BASE_PACKAGE_LOCATION | |
echo "Done." | |
} | |
unzipPackage() { | |
if [ -e "./$FREDHOPPER_ST_BASE_FILE" ] | |
then | |
echo "Unzipping " | |
unzip "./$FREDHOPPER_ST_BASE_FILE" | |
echo "Done." | |
else | |
echo "ERROR: $FREDHOPPER_ST_BASE_FILE not found!" | |
exit 1 | |
fi | |
} | |
getDAversion() { | |
wget -O - http://localhost:8177 2>/dev/null | grep deployment-agent.version | wc -l | |
} | |
verifyDAisRunning() { | |
# Check if deployment agent is running | |
if [ x`getDAversion` = "x1" ]; then | |
echo "INFO: $DA is up on host: $THISHOST, so that is fabulous" | |
else | |
echo "ERROR: $DA is not running on host: $THISHOST. Exiting!" | |
exit 1 | |
fi | |
} | |
startAgent() { | |
if [ -e ./bin/fredhopper ] | |
then | |
echo "starting deployment agent" | |
./bin/fredhopper start | |
verifyDAisRunning | |
echo "Done." | |
else | |
echo "ERROR: deployment agent not started. ./bin/fredhopper not found" | |
exit 1 | |
fi | |
} | |
setupIndex() { | |
if [ -n $INSTANCE_NAME ] && [ "$INSTANCE_NAME" != "autostart" ] | |
then | |
echo "Setting up index with name: $INSTANCE_NAME" | |
verifyDAisRunning | |
#take the prepared base index and rename that | |
#NOTE: this script can now only be run from the fredhopper base dir | |
./bin/deployment-agent-client --location localhost rename-instance --force proto-smarttarget-index $INSTANCE_NAME | |
echo "moving directory ./proto-smarttarget-index to ./$INSTANCE_NAME" | |
mv ./proto-smarttarget-index ./$INSTANCE_NAME | |
echo "Replacing proto-smarttarget-index for $INSTANCE_NAME in config/topology.txt" | |
sed -i "s/proto-smarttarget-index/$INSTANCE_NAME/g" ./config/topology.txt | |
echo "Done" | |
if [ -n $AUTOSTART ] && [ "$AUTOSTART" == "autostart" ] | |
then | |
echo "Index setup, starting the index as the autostart parameter was given" | |
./bin/instance $INSTANCE_NAME start | |
fi | |
else | |
echo "ERROR: specify index name as second parameter (and not autostart in case you did that)" | |
exit 1 | |
fi | |
} | |
case "$ACTION" in | |
download) | |
download | |
;; | |
download:unzip) | |
download | |
unzipPackage | |
;; | |
start-agent) | |
startAgent | |
;; | |
download:unzip:start-agent) | |
download | |
unzipPackage | |
startAgent | |
;; | |
setup:index) | |
setupIndex | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment