Created
December 10, 2015 15:19
-
-
Save RaimondKempees/dffd772465bb90cb739b 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 | |
# | |
# Creates a query server instance based on a Fredhopper installation | |
# | |
# Required Fredhopper variables: | |
# | |
# fredhopper base bath (eg /usr/share/fredhopper) | |
# memory (=1500) | |
# instance_preset (=1) | |
# instance_name (=query-server-00x) | |
# syncserver_port (=8100). This is the port of the indexer. | |
# syncserver_host (=index-1.domain.net). This is the host of the indexer | |
FREDHOPPER_BASE_PATH= | |
QSERVER_MEMORY= | |
INSTANCE_NAME= | |
INSTANCE_PRESET= | |
SYNCSERVER_PORT= | |
SYNCSERVER_HOST= | |
AUTOSTART="false" | |
REMOVEINDEX="false" | |
AUTODEPLOY="false" | |
THISHOST=`hostname` | |
DA=deployment-agent | |
getDAversion() { | |
wget -O - http://localhost:8177 2>/dev/null | grep deployment-agent.version | wc -l | |
} | |
usage() | |
{ | |
echo | |
echo "usage: $0 options" | |
echo | |
echo " Parameters:" | |
echo " -h Show this message" | |
echo " -b Base path of Fredhopper installation" | |
echo " -m memory Set memory for qserver (default 1500)" | |
echo " -i instance Instance name for this query server" | |
echo " -p instance_preset Configuration preset of this new query instance" | |
echo " -s syncserver_port This is the port of the syncserver on the indexer" | |
echo " -n syncserver_host This is the host of the indexer" | |
echo " -a autostart Use this option to autostart the query server" | |
echo " -r remove base index Use this option to remove base the index. USE ONLY WHEN THIS SERVER IS A QSERVER ONLY!" | |
echo " -y say yes to prompt Use this option in automated deployments" | |
echo | |
} | |
while getopts "hm:i:p:s:n:ary" opt; do | |
case $opt in | |
h) | |
usage | |
exit 1 | |
;; | |
b) | |
FREDHOPPER_BASE_PATH=$OPTARG | |
;; | |
m) | |
QSERVER_MEMORY=$OPTARG | |
;; | |
i) | |
INSTANCE_NAME=$OPTARG | |
;; | |
p) | |
INSTANCE_PRESET=$OPTARG | |
;; | |
s) | |
SYNCSERVER_PORT=$OPTARG | |
;; | |
n) | |
SYNCSERVER_HOST=$OPTARG | |
;; | |
a) | |
AUTOSTART="true" | |
;; | |
r) | |
REMOVEINDEX="true" | |
;; | |
y) | |
AUTODEPLOY="true" | |
;; | |
esac | |
done | |
if [[ -z $FREDHOPPER_BASE_PATH ]] || [[ -z $QSERVER_MEMORY ]] || [[ -z $INSTANCE_NAME ]] || [[ -z $INSTANCE_PRESET ]] || [[ -z $SYNCSERVER_PORT ]] || [[ -z SYNCSERVER_HOST ]] | |
then | |
echo "ERROR: One or more parameters not set." | |
usage | |
exit 1 | |
fi | |
echo | |
echo "New query instance name : $INSTANCE_NAME" | |
echo "New query instance preset: $INSTANCE_PRESET" | |
echo "New instance memory : $QSERVER_MEMORY" | |
echo "Sync Server host : $SYNCSERVER_HOST" | |
echo "Sync Server port : $SYNCSERVER_PORT" | |
echo | |
echo "Checking environment..." | |
echo | |
# 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 | |
if [ "$AUTODEPLOY" = "false" ] | |
then | |
read -p "Are you sure? (y/Y to start immediately!) " -n 1 -r | |
echo | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then | |
AUTODEPLOY="true" | |
fi | |
fi | |
if [ "$AUTODEPLOY" = "true" ] | |
then | |
echo "Creating query server instance..." | |
echo | |
$FREDHOPPER_BASE_PATH/bin/deployment-agent-client create -I $INSTANCE_PRESET $INSTANCE_NAME FAS | |
$FREDHOPPER_BASE_PATH/bin/deployment-agent-client set-option $INSTANCE_NAME qserver_memory=$QSERVER_MEMORY | |
$FREDHOPPER_BASE_PATH/bin/deployment-agent-client set-option $INSTANCE_NAME syncclient_serverport=$SYNCSERVER_PORT | |
$FREDHOPPER_BASE_PATH/bin/deployment-agent-client set-option $INSTANCE_NAME syncclient_server=$SYNCSERVER_HOST | |
#TODO: role is live should be an option | |
$FREDHOPPER_BASE_PATH/bin/deployment-agent-client add-role $INSTANCE_NAME http://localhost:8177/static/live.xml | |
if [ "$REMOVEINDEX" = "true" ] | |
then | |
echo "Removing base index instance" | |
$FREDHOPPER_BASE_PATH/bin/deployment-agent-client remove proto-smarttarget-index | |
echo "Removing base index root folder" | |
rm -rf $FREDHOPPER_BASE_PATH/proto-smarttarget-index | |
echo "Done" | |
fi | |
if [ "$AUTOSTART" = "true" ] | |
then | |
echo "Autostarting $INSTANCE_NAME" | |
$FREDHOPPER_BASE_PATH/bin/deployment-agent-client invoke $INSTANCE_NAME syncclient start | |
$FREDHOPPER_BASE_PATH/bin/deployment-agent-client invoke $INSTANCE_NAME qserver start -Drole=live | |
echo "Done!" | |
fi | |
echo | |
echo "Don't forget to edit topology.txt on the index instance" | |
echo | |
else | |
echo "Exiting normally without doing anything" | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment