|
| 1 | +#!/bin/sh |
| 2 | +# |
| 3 | +# Initializes a virgin MarkLogic installation. |
| 4 | + |
| 5 | +HOST=localhost |
| 6 | +ADMINUSER=admin |
| 7 | +ADMINPASSWORD=admin |
| 8 | + |
| 9 | +/tmp/startml.sh |
| 10 | + |
| 11 | +until curl -fsS --head --digest --user "$ADMINUSER":"$ADMINPASSWORD" http://"$HOST":8001/admin/v1/timestamp # &>/dev/null |
| 12 | +do |
| 13 | + echo "MarkLogic hasn't started yet. Retrying in 3 seconds…" |
| 14 | + sleep 3 |
| 15 | +done |
| 16 | + |
| 17 | +# curl -X POST --data "" http://"$HOST":8001/admin/v1/init |
| 18 | +echo "Initializing…" |
| 19 | +curl --fail --show-error --silent -X POST --data "" http://"$HOST":8001/admin/v1/init 1>/dev/null |
| 20 | +if [[ $? != 0 ]] ; then |
| 21 | + echo "error on init" |
| 22 | + exit 1 |
| 23 | +fi |
| 24 | +echo "Completed initialization. Waiting for restart…" |
| 25 | +sleep 20 |
| 26 | + |
| 27 | +# curl -fsS --head --digest --user admin:"$ADMINPASSWORD" http://"$HOST":8001/admin/v1/timestamp |
| 28 | +# One liner: until curl -fsS --head http://192.168.56.101:8001/admin/v1/timestamp --digest --user admin:admin; do sleep 5; done |
| 29 | + |
| 30 | + |
| 31 | +until curl -fsS --head --digest --user "$ADMINUSER":"$ADMINPASSWORD" http://"$HOST":8001/admin/v1/timestamp &>/dev/null |
| 32 | +do |
| 33 | + echo "Restart hasn't completed. Retrying in 3 seconds…" |
| 34 | + sleep 3 |
| 35 | +done |
| 36 | + |
| 37 | +# curl -X POST -H "Content-type: application/x-www-form-urlencoded" --data "admin-username=admin" --data "admin-password=********" http://localhost:8001/admin/v1/instance-admin |
| 38 | +echo "Starting instance administration…" |
| 39 | +curl --fail --show-error --silent \ |
| 40 | + -X POST -H "Content-type: application/x-www-form-urlencoded" \ |
| 41 | + --data "admin-username=${ADMINUSER}" --data "admin-password=${ADMINPASSWORD}" --data "realm=public" \ |
| 42 | + http://"$HOST":8001/admin/v1/instance-admin 1>/dev/null |
| 43 | +if [[ $? != 0 ]] ; then |
| 44 | + echo "Error on instance-admin" |
| 45 | + exit 1 |
| 46 | +fi |
| 47 | + |
| 48 | +echo "Completed instance administration. Waiting for restart…" |
| 49 | +sleep 10 |
| 50 | +until curl -fsS --head --digest --user admin:"$ADMINPASSWORD" http://"$HOST":8001/admin/v1/timestamp &>/dev/null |
| 51 | +do |
| 52 | + echo "Restart hasn't completed. Retrying in 5 seconds…" |
| 53 | + sleep 5 |
| 54 | +done |
| 55 | + |
| 56 | +echo "Turning off log file rotation" |
| 57 | +curl --fail --show-error --silent \ |
| 58 | + -X PUT --digest -u "$ADMINUSER":"$ADMINPASSWORD" -H "Content-type: application/json" \ |
| 59 | + -d '{"rotate-log-files":"never"}' http://"$HOST":8002/manage/v2/groups/Default/properties &>/dev/null |
| 60 | + |
| 61 | +echo "Done!" |
| 62 | +exit 0 |
0 commit comments