forked from jpcs/queryplan-viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·73 lines (63 loc) · 1.47 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#! /bin/bash
usage()
{
cat <<-EOF 1>&2
use: setup.sh [OPTIONS]*
Options: Default
--host=HOST localhost
--port=PORT 9999
--user=USE admin
--pass=PAS admin
--dir=DIR current dir
--group=GROUP Default
EOF
exit 1
}
HOST=localhost
PORT=9999
USER=admin
PASS=admin
DIR="$PWD/${1#./}"
GROUP="Default"
while [ $# != 0 ]; do
case "$1" in
--host=*)
HOST=$(echo $1 | sed 's%--host=%%')
shift;;
--port=*)
PORT=$(echo $1 | sed 's%--port=%%')
shift;;
--dir=*)
DIR=$(echo $1 | sed 's%--dir=%%')
shift;;
--user=*)
USER=$(echo $1 | sed 's%--user=%%')
shift;;
--pass=*)
PASS=$(echo $1 | sed 's%--pass=%%')
shift;;
--group=*)
GROUP=$(echo $1 | sed 's%--group=%%')
shift;;
-?)
usage
;;
*)
echo "Bad option - $1"
usage
;;
esac
done
CURL="curl --anyauth --user ${USER}:${PASS} -s -S"
$CURL -X POST -d @- -H "Content-type: application/json" \
"http://${HOST}:8002/manage/v2/servers" <<-EOF
{ "server-name": "${PORT}-queryplan-viewer",
"server-type": "http",
"group-name": "$GROUP",
"root": "${DIR}",
"port": $PORT,
"content-database": "Documents",
"threads": 32,
"error-handler" : "/MarkLogic/rest-api/error-handler.xqy"
}
EOF