Hi
I have the reindex script configured to fire the reindex process on Jira 4.4 and it works nice.
It is based on something similar to this one: https://answers.atlassian.com/questions/92800/activating-jira-indexing-via-script
#!/bin/sh
# This script detects if Jira is suggesting a re-index is necessary
# and triggers it if this is the case.
# This script is designed to be run from cron
THISPROC=`basename $0` # Set our name to the called command name
MAILFILE=/tmp/jiramail-$$
echo "[$THISPROC - Version 1.02 - 28-Mar-2012]" | tee ${MAILFILE}
echo " " | tee ${MAILFILE}
if [[ ${1} == "" ]]; then
echo "Need to specify Jira hostname" | tee -a ${MAILFILE}
rm $MAILFILE
exit
fi
JIRA_URL=${1}
DASHBOARD_PAGE_URL=http://${JIRA_URL}/secure/Dashboard.jspa
PROJECT_PAGE_URL=http://${JIRA_URL}/secure/project/ViewProjects.jspa
INDEX_PAGE_URL=http://${JIRA_URL}/secure/admin/jira/IndexReIndex.jspa
WEBSUDO_PAGE_URL=http://${JIRA_URL}/jira/secure/admin/WebSudoAuthenticate.jspa
MAIL_USERS="someuser@somemail.com"
COOKIE="/tmp/jiracoookie-$(date +%s)"
PASSWORD=$(grep ${JIRA_URL} ~/.netrc | cut -f6 -d" ")
echo "$(hostname): Starting Jira reindex $(date)" >> ${MAILFILE}
echo " " >> ${MAILFILE}
RESULT=$(curl -s -n --cookie-jar ${COOKIE} ${PROJECT_PAGE_URL} | grep "It is recommended that you perform a re-index")
if [[ ${RESULT} != "" ]]; then
echo " * Re-index required - starting that now *" >> ${MAILFILE}
# Set the web sudo token
curl -s -n --cookie ${COOKIE} -d "webSudoPassword=${PASSWORD}" $WEBSUDO_PAGE_URL
# Kick off the re-index
curl -s -n --cookie ${COOKIE} --header "X-Atlassian-Token: no-check" -d "indexPathOption=DEFAULT" -d "Re-Index=Re-Index" -d "indexPath=" --output /dev/null ${INDEX_PAGE_URL}
else
echo " No need to re-index this time" >> ${MAILFILE}
fi
cat ${MAILFILE} | mail -s "Jira re-index script - ${JIRA_URL}" ${MAIL_USERS}
rm -f ${MAILFILE} ${COOKIE}
This scripts perfectly detects if it necessary to Reindex instance for both Jira 4.4 and Jira 5.2.8 versions but it is failing to start ReIndex process on Jira 5.2.8.
I even tried to add the " -d "indexingStrategy=1" " option for Backround Index in Jira 5 but it does not help at all.
curl -s -n --cookie ${COOKIE} --header "X-Atlassian-Token: no-check" -d "indexPathOption=DEFAULT" -d "Re-Index=Re-Index" -d "indexPath=" --output /dev/null ${INDEX_PAGE_URL}
Does anyone done this and got working script?
Regards,
Areg