|
#!/bin/bash |
|
|
|
## Ensure that java 8 is being used |
|
export JAVA_HOME="$(/usr/libexec/java_home -v 1.8)" |
|
export PATH=$JAVA_HOME/bin:$PATH |
|
|
|
function timeout() { |
|
perl -e 'alarm shift; exec @ARGV' "$@" |
|
} |
|
|
|
function returnsCode() { |
|
local url=${1:-http://localhost:4502} |
|
local code=${2:-500} |
|
local status=$(curl --head --location --connect-timeout 5 --write-out %{http_code} --silent --output /dev/null ${url}) |
|
[[ $status == ${code} ]] |
|
} |
|
|
|
export -f returnsCode |
|
|
|
if [ "$1" == "quickstart" ]; then |
|
/usr/local/bin/aem/crx-quickstart/bin/quickstart > /dev/null 2>&1 & disown |
|
fi |
|
|
|
if [ "$1" == "stop" ]; then |
|
/usr/local/bin/aem/crx-quickstart/bin/stop |
|
timeout 60 bash -c 'until returnsCode http://localhost:4502 000; do sleep 0.5; done' |
|
fi |
|
|
|
if [ "$1" == "start" ]; then |
|
/usr/local/bin/aem/crx-quickstart/bin/start |
|
timeout 60 bash -c 'until returnsCode http://localhost:4502 401; do sleep 0.5; done' |
|
fi |
|
|
|
if [ "$1" == "status" ]; then |
|
/usr/local/bin/aem/crx-quickstart/bin/status |
|
fi |
|
|
|
if [ "$1" == "log" ]; then |
|
tail -f /usr/local/bin/aem/crx-quickstart/logs/error.log |
|
fi |
|
|
|
if [ "$1" == "install" ]; then |
|
cp "${@:2}" /usr/local/bin/aem/crx-quickstart/install/ |
|
fi |
|
|
|
if [ "$1" == "restart" ]; then |
|
/usr/local/bin/aem/crx-quickstart/bin/stop |
|
timeout 60 bash -c 'until returnsCode http://localhost:4502 000; do sleep 0.5; done' |
|
/usr/local/bin/aem/crx-quickstart/bin/start |
|
timeout 60 bash -c 'until returnsCode http://localhost:4502 401; do sleep 0.5; done' |
|
fi |
|
|
|
if [ "$1" == "cleanup" ]; then |
|
/usr/local/bin/aem/crx-quickstart/bin/stop |
|
timeout 60 bash -c 'until returnsCode http://localhost:4502 000; do sleep 0.5; done' |
|
java -jar /usr/local/bin/aem/oak-run-1.6.6.jar checkpoints /usr/local/bin/aem/crx-quickstart/repository/segmentstore |
|
java -jar /usr/local/bin/aem/oak-run-1.6.6.jar checkpoints /usr/local/bin/aem/crx-quickstart/repository/segmentstore rm-unreferenced |
|
java -jar /usr/local/bin/aem/oak-run-1.6.6.jar compact /usr/local/bin/aem/crx-quickstart/repository/segmentstore |
|
/usr/local/bin/aem/crx-quickstart/bin/start |
|
timeout 60 bash -c 'until returnsCode http://localhost:4502 401; do sleep 0.5; done' |
|
fi |