Skip to content

Instantly share code, notes, and snippets.

@jayankandathil
Created July 6, 2015 16:32
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save jayankandathil/d39cbb4966910eec834b to your computer and use it in GitHub Desktop.
Save jayankandathil/d39cbb4966910eec834b to your computer and use it in GitHub Desktop.
Script to Trigger Repository Check in AEM 6.0 and 6.1 CRX3
#!/bin/bash
# Bash script to run AEM 6.0 and 6.1 Repository Check
# Author : Jayan Kandathil
# Version : 0.1
# Last updated : July 6, 2015
# Instructions : Copy to CQ's /bin folder, make necessary changes, enable the execute bit and run
# Echo on (for debugging purposes)
# set -x verbose
# Host that CQ runs on
HOST=localhost
# TCP port CQ listens on
PORT=4502
# CQ Admin user ID
USER=admin
# CQ Admin user password
PASSWORD=admin
# CQ Home
CQ_HOME=/opt/aem/author/crx-quickstart
# CQ Maintenance in progress file
MAINTENANCE_FILE=$CQ_HOME/logs/repocheck_in_progress.txt
# CQ Maintenance log file
LOG_FILE=$CQ_HOME/logs/aem_repository_check.log
# ------------------------------------------------
# Do not configure below this point
# ------------------------------------------------
# Log timestamp
date | tee -a $LOG_FILE
# Back off if the previous maintenance operation is still in progress
if [ -f $MAINTENANCE_FILE ];
then
echo $'\n'"Previous maintenance operation still in progress..., backing off till next time."$'\n' | tee -a $LOG_FILE
else
#Create an empty text file indicating maintenance in progress
touch $MAINTENANCE_FILE | tee -a $LOG_FILE
echo "Starting Repository check..."$'\n'
START=$(date +%s)
time curl -u $USER:$PASSWORD -X POST --data "workspace=crx.default&path=%2F&traversal=on&fixinconsistencies=on&datastoreconsistency=on" http://$HOST:$PORT/system/console/repositorycheck | tee -a $LOG_FILE
END=$(date +%s)
DIFF=$(( $END - $START ))
echo "Finished."$'\n'
echo "Took $DIFF seconds"$'\n'
# Remove file which indicates that maintenance is in progress
rm $MAINTENANCE_FILE | tee -a $LOG_FILE
fi
# Log timestamp
date | tee -a $LOG_FILE
echo $'\n'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment