2
2
3
3
# Log all subsequent commands to logfile. FD 3 is now the console
4
4
# for things we want to show up in "docker logs".
5
+ LOGFILE=/opt/couchbase/var/lib/couchbase/logs/container-startup.log
5
6
# exec 3>&1 1>>${LOGFILE} 2>&1
6
7
8
+ CONFIG_DONE_FILE=/opt/couchbase/var/lib/couchbase/container-configured
7
9
config_done () {
10
+ touch ${CONFIG_DONE_FILE}
8
11
echo " Couchbase Admin UI: http://localhost:8091" \
9
12
" \nLogin credentials: Administrator / password" | tee /dev/fd/3
10
13
echo " Stopping config-couchbase service"
11
14
sv stop /etc/service/config-couchbase
12
15
}
13
16
14
- echo " Configuring Couchbase Server. Please wait (~60 sec)..." | tee /dev/fd/3
17
+ if [ -e ${CONFIG_DONE_FILE} ]; then
18
+ echo " Container previously configured." | tee /dev/fd/3
19
+ config_done
20
+ else
21
+ echo " Configuring Couchbase Server. Please wait (~60 sec)..." | tee /dev/fd/3
22
+ fi
15
23
16
24
export PATH=/opt/couchbase/bin:${PATH}
17
25
@@ -30,6 +38,23 @@ wait_for_uri() {
30
38
echo " $uri ready, continuing"
31
39
}
32
40
41
+
42
+ wait_for_uri_with_auth_and_data () {
43
+ uri=$1
44
+ data=$2
45
+ expected=$3
46
+ echo " Waiting for $uri to be available..."
47
+ while true ; do
48
+ status=$( curl -s -u Administrator:password -w " %{http_code}" -o /dev/null $uri -d " $data " )
49
+ if [ " x$status " = " x$expected " ]; then
50
+ break
51
+ fi
52
+ echo " $uri not up yet, waiting 2 seconds..."
53
+ sleep 2
54
+ done
55
+ echo " $uri ready, continuing"
56
+ }
57
+
33
58
panic () {
34
59
cat << EOF 1>&3
35
60
@@ -65,7 +90,7 @@ curl_check() {
65
90
wait_for_uri http://127.0.0.1:8091/ui/index.html 200
66
91
67
92
echo " Setting memory quotas with curl"
68
- curl_check http://127.0.0.1:8091/pools/default -d memoryQuota=256 -d indexMemoryQuota=256 -d ftsMemoryQuota=256 -d cbasMemoryQuota=1024
93
+ curl http://127.0.0.1:8091/pools/default -d memoryQuota=256 -d indexMemoryQuota=256 -d ftsMemoryQuota=256 -d cbasMemoryQuota=1024
69
94
echo
70
95
71
96
echo " Configuring Services with curl"
@@ -84,15 +109,34 @@ echo "Creating 'datadog-test' bucket with curl"
84
109
curl_check -u Administrator:password -X POST http://127.0.0.1:8091/pools/default/buckets -d name=datadog-test -d ramQuotaMB=100 -d authType=sasl \
85
110
-d replicaNumber=0 -d bucketType=couchbase
86
111
87
- wait_for_uri http://127.0.0.1:8093/query/service 400
112
+ wait_for_uri_with_auth_and_data http://127.0.0.1:8093/query/service ' statement=SELECT 1' 200
113
+
114
+ echo " Adding document to test bucket with curl"
115
+ curl -u Administrator:password -X POST http://127.0.0.1:8093/query/service \
116
+ -d ' statement=INSERT INTO `datadog-test` ( KEY, VALUE )
117
+ VALUES
118
+ (
119
+ "landmark_1",
120
+ {
121
+ "id": "1",
122
+ "type": "landmark",
123
+ "name": "La Tour Eiffel",
124
+ "location": "France"
125
+ }
126
+ )'
88
127
89
128
wait_for_uri http://127.0.0.1:8094/api/index 403
90
129
91
- echo " Creating test FTS index with curl: "
130
+ echo " Creating test FTS index with curl"
92
131
curl_check -u Administrator:password -X PUT http://127.0.0.1:8094/api/index/test -H Content-Type:application/json -d @/opt/couchbase/create-index.json
93
132
rm /opt/couchbase/create-index.json
94
133
echo
95
134
135
+ echo " Creating datadoc design document"
136
+ curl_check -u Administrator:password -X PUT http://127.0.0.1:8092/datadog-test/_design/datadoc -H Content-Type:application/json -d @/opt/couchbase/create-ddoc.json
137
+ rm /opt/couchbase/create-ddoc.json
138
+ echo
139
+
96
140
echo " Creating RBAC 'admin' user on datadog-test bucket"
97
141
couchbase_cli_check user-manage --set \
98
142
--rbac-username admin --rbac-password password \
0 commit comments